Partitions#
Imagine you have a disk drive that's 1TiB in size. It's presented by Linux as xvda
. You decide you want three disks instead.
Even though you only have one physical disk drive, you can create three partitions so that you get three "disks" you can format with whatever filesystem(s) you like. A partition is like a separate "virtual" disk that is backed by a single, physical device.
With your 1TiB of space, you divide the disk up into 500GiB, 250GiB and 250GiB partitions. This gives you xvda1
, xvda2
, and xvda3
. You can then format these partitions with filesystems (different ones if you like), which can then be mounted and used by you or other end users on your system.
Partitions are a way for you to isolate filesystems to prevent one filesystem from growing too big and overtaking another. For example, if you have a 1TiB disk and you just format it and use it for /
and everything below that, a user (in /home/user
) can start filling up the disk with huge files, perhaps downloaded from the Internet. This prevents other users from using the system and even prevents some system processes from using the filesystem too (although there tends to be a 5% reserve on EXT file systems.)
To prevent this, we can partition the disk up into two partitions: 900GiB for the /
and 100GiB for /home
. This means that users get a total of 100GiB to work with. If they fill it up, it doesn't affect the rest of the system. This is one of the primary reasons to partition a disk, although it's not that common anymore (in the server space, anyway.)