24/7/365 Support

Partition resizing of Debian

Partition resizing may be required ifyou need more space. To get a quick overview of your disk space usage, use the df command. There is also a disk usage (du) command that summarizes file and directory space. Refer to the manual pages for details.

Ifyou must resize a disk partition, the procedures are fairly straightforward but there are some considerations.

There is always a risk in modifying your partition layout. Make sure you have current backups prior to modifying the layout.

If the partition is being expanded, there must be room to expand it. Ifyou are using Logical Volume Manager (LVM), this can be as simple as adding a physical volume to the volume group ifthere is not enough space left in it. If you are not using L VM, or ifyou have multiple partitions configured on the same logical volume, then there must be free space available on the physical disk or logical volume following the end of the partition to be expanded. Ifthere isn't, it must be created somehow. Ifthe partition is to be shrunk, space is not an issue, although you may want to move or expand other partitions to use the space freed up by shrinking. Also, it is sometimes necessary to move partitions around. This is not necessary ifyou use L VM and assign one partition per logical volume.

Moving or shrinking a partition may only be done with unmounted (offline) partitions, since itrequires moving files and risks corruption ifany files are in use. Some filesystems, EXT3 and EXT4 in particular, may be expanded while the partition is still mounted, however, since this doesn't require moving any files, just modifying the filesystem metadata.

While each filesystem architecture has appropriate tools for resizing and there are simple tools for managing the partition table, the primary tool for managing partitions is parted. There are other, mostly commercial tools, but parted does pretty much everything that is necessary, is available as an easy to use graphical utility (gparted), and it is free. There is even a live CD version you can boot to manage your partitions regardless of what operating system is installed. Many Windows administrators use it quite successfully. Ithandles both enlarging and shrinking partitions as well as moving them, and will handle many different filesystem architectures, and ensures that the partition table matches the filesystem sizes.

Unfortunately, neither parted nor gparted will not allow you to expand a mounted partition. Ifyou must expand a partition while it is in use, you must delete and recreate the partition with the same, identical beginning position, force a reread of the partition table, and then use the appropriate filesystem resizing commands. This is extremely dangerous and should never be used for resizing the root partition.

The procedures for modifying partition layout are straightforward. .ct Note that ifyou aren't booted from a gparted live CD or similar utility disk, you cannot unmount partitions required to run the necessary utilities and operating system services.

To manually modify your partition layout:

  1. Ensure there is adequate space for the expanded partition, or to hold the partition being moved. If necessary, shrink or move other partitions or expand the logical volume.
  2. You must ensure the partition table matches the resized or moved partition exactly. Failing to do this can result in corrupted or lost data. gparted will handle this for you automatically.
  3. To shrink a partition, it must be offline (unmounted). Resize the filesystem first, then modify the partition table to match the new size.
  4. To expand a partition, modify the partition table first, then expand the filesystem. Ifyou are doing this with a mounted partition, you must use the procedure outlined previously.
  5. To move a partition, you must first create a new partition of the same size as the original. Then you must unmount the current partition, copy the data to the new partition exactly, and delete the old partition.

In all cases, the partition must be clean prior to modifying or moving it, and should be checked afterwards prior to mounting it. The gparted utility or similar will handle the steps above automatically, including the necessary filesystem checks, data movement, and partition table modifications.

Note that either gparted or the manual procedures may be used on a Jive system, provided the partitions being modified can be unmounted, or if a mounted partition must be modified, itis only being expanded and gparted is not being used.

Unless you must expand a partition while it remains mounted and in use, the recommended procedure is to boot from a gparted live CD. lhis greatly simplifies the whole process, allows modification of all partitions, not just those that aren't required for operating system services and necessary utilities, and reduces the risk of corruption.

Help Category:

What Our Clients Say