Translation(s): English - Italiano - Português (Brasil)


Tools

The following software allows working on disk partitions:

Partitioning schemes

There are several ways that partitions can be defined, the most common are called GPT and MBR. You can find which one you are using by running fdisk -l

GPT format partitions

Computers that use UEFI, and some that use a BIOS can use a partitioning format called Globally Unique Identifier (GUID) Partition Table (GPT).

MBR format partitions

Older computers that boot using a BIOS use a partitioning format called MBR. This format was designed for MS-DOS and only supports disks smaller than 2TB.

MBR defines three types of partitions:

For an end user there is no practical difference between a (non-extended) primary partition and the logical partitions: each can contains a filesystem (like ext4 or vfat) or be used as LVM physical volume, etc. The extended partition itself is not usable, as its space is used to define the logical partitions.

The primary partitions are always numbered 1 to 4.

Here is some annotated output from lsblk on an MBR-partitioned SATA disk.

# lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda             8:0    0 223.6G  0 disk
├─sda1          8:1    0   243M  0 part /boot         # primary (/boot, not in LVM on this machine)
├─sda2          8:2    0     1K  0 part               # extended: container for other partitions
└─sda5          8:5    0 223.3G  0 part               # logical: used as a LVM physical volume
  ├─vg-root   254:0    0  23.3G  0 lvm  /             #  LVM logical volume for /
  ├─vg-var    254:1    0  12.3G  0 lvm  /var          #  LVM logical volume for /var
  ├─vg-swap_1 254:2    0   7.9G  0 lvm  [SWAP]        #  LVM logical volume for swap
  ├─vg-tmp    254:3    0   1.9G  0 lvm  /tmp          #   etc
  ├─vg-home   254:4    0   151G  0 lvm  /home
  └─vg-srv    254:5    0    25G  0 lvm  /srv

Changing partitions

LVM

If you're not sure what size to make your partitions, using LVM is a good idea as it makes it easier to resize partitions. This is supported by the DebianInstaller. In LVM, each logical volume is treated as if it were a separate disk in which you make partitions.

The LVM page has examples of how to grow or shrink a logical volume.

Updating configuration files after changing partitions

Another advantage of LVM is that you can refer to logical volumes by name, which means you can make changes without needing to update configuration files.

If you change the underlying disk partitions in a way that changes the partition numbers then you may need to update a number of configuration files in /etc:

  1. The fstab file may need to be updated to refer to the new names (it is recommended to refer to filesystems by their UUID, which is less likely to change)

  2. If the partition number for a swap partition changed, the /etc/initramfs-tools/config.d/resume needs to be edited. This file indicates the partition, usually swap, used for hibernation. update-initramfs -u needs to be ran afterwards to update the initramfs.

  3. If you change the /boot or root partition you should run update-grub so that Grub2 knows how to boot the system

Note that even unaltered partitions may change. For example, a partition that used to be identified as /dev/sda7 may change to /dev/sda6 if an earlier partition is deleted.

See Also


CategorySystemAdministration CategoryStorage