Disks & Partitions

A partition is a section of a disk, which can be mounted to your machine. A disk can, and often does have multiple partitions.

For example, the following is a typical partition layout

lsblk -k

# <device>        <dir>        <type>        <options>        <dump> <fsck>
/dev/sda1         /boot        vfat          defaults         0      2
/dev/sda2         /            ext4          defaults         0      1
/dev/sda3         /home        ext4          defaults         0      2
/dev/sda4         none         swap          defaults         0      0

/dev/sda is the disk, such as a solid state drive or hard drive, and each device with a suffix of a number refers to a partition on that disk.

  • The <dir> portion refers to the mountpoint of that partition. So from this, all data in your home folder /home/<YOUR_USERNAME> will be stored on the /dev/sda3 partition.
  • The <type> portion refers to the filesystem type. So from this, you can see that the /dev/sda3 partition is an ext4 filesystem, which is a commonly used filesystem for general storage on linux.
  • The <options> portion refers to the filesystem options. Options can include mounting the filesystem as readonly (ro), or as readwrite (rw).
  • The <dump> and <fsck> portions are used to determine if the filesystem is in a good state on boot/mount.

The "swap" partition is of a special type that acts as virtual memory or as "swap space", allowing the disk to store data when your RAM isn't enough.

Mounting a partition

Generally, unless you have a specific reason not to, partitions are often mounted somewhere from the /mnt directory.

mount /dev/sda3 /mnt/service_data

If you want this mount to be permanent, you can add it to your /etc/fstab file.

UUID=<UUID> /mnt/service_data ext4 rw,relatime,data=ordered 0 0

Use blkid to find the UUID of the partition you want to mount.