I'm looking to resize a number of partitions, but I'm unsure how to go about doing this.

I want to increase the partition size of the /var partition, that is in the middle of all the other partitions... I know that in order to keep data intact, the partition needs to start on the same block number as it was originally.

So my question is, even if there are partitions after /var, can I resize it without disrupting the other partitions? Will it take more space from a different place? Or would it be best to create a new partition altogether, something like /var/log down at the bottom? And if so, how do I do that?

Here's the current partition layout (I'm hoping I can just increase the size of /var/lib/mysql easily enough since it's down at the bottom).

$ df -h

Filesystem              Size  Used Avail Use% Mounted on

/dev/dm-0                19G  1.6G   16G   9% /

udev                     10M     0   10M   0% /dev

tmpfs                   7.9G  807M  7.1G  11% /run

tmpfs                    20G     0   20G   0% /dev/shm

tmpfs                   5.0M     0  5.0M   0% /run/lock

tmpfs                    20G     0   20G   0% /sys/fs/cgroup

/dev/md0                291M   33M  243M  12% /boot

/dev/mapper/base-var     19G   11G  7.5G  59% /var

/dev/mapper/base-tmp    1.8G  3.0M  1.7G   1% /tmp

/dev/mapper/base-home    86G   35G   47G  43% /home

/dev/mapper/base-cyrus   75G   60G   12G  85% /var/spool/cyrus

/dev/mapper/base-www     20G   13G  5.6G  71% /var/www

/dev/mapper/base-mysql   60G   55G  2.3G  97% /var/lib/mysql

Since you are using LVM instead of conventional partitions, you don't need to worry much about where they are on disk. As long as you have free space in the volume group, you can grow a logical volume with lvresize. You can then grow the filesystem in that logical volume with resize2fs, assuming it is ext4.

Use pvs to see how much space is used/free on the physical volumes in your volume group.


Partitioning tools

To resize partitions that are in-use on an already installed operating system, it is recommended to use a tool such as GParted (GNOME Partition Editor) by creating a USB disk or other bootable medium with the appropriate live ISO image.

The GParted live ISO allows for mouse and keyboard interaction with mounted volumes, and has a very extensive manual available here.

Creating space for /var

Can I resize it (/var) without disrupting the other partitions?

To resize /var, you'll need to create free (unallocated) space first by shrinking another one of your partitions (assuming that you have all possible space currently allocated to a partition).

You can create unallocated space from any partition that is not full by shrinking it; however, you'll want to ensure that the free space is taken from the end of the partition being shrunken in order to ensure no data loss.

The unallocated space should then be moved to post-fix the /var partition. Once the unallocated space has been moved, /var can be resized to take up as much as the free space as needed.

Will it take more space from a different place?

GParted cannot dynamically move unallocated space or take allocated space from another partition to the fit user's desires, thus the previous step of shrinking a partition and moving the unallocated space is necessary.

Or would it be best to create a new partition altogether, something like /var/log down at the bottom? And if so, how do I do that?

To answer your first question, it's up to your needs and what suits you best. It's hard to judge what your use-cases are and thus what suits your situation.

To answer your second question, you'd need to create unallocated space by shrinking a volume within GParted. You can then move the unallocated space to the end of the volume, and right-click on the free space to create a new partition, with the filesystem format that you need.

Ensuring order of partitions remains constant

The identifiers for each partition (for example: /dev/sdb1 or /dev/sdb3) are determined by the order of the partitions on the volume. To ensure continuity of the order of partitions after performing operations, you'll simply need to reorder the partitions as needed through move operations until the desired order is achieved.

  • This would be a good answer if the OP weren't using LVM
    – psusi
    Feb 8 '18 at 2:51
  • Oops, I totally totally missed that... This answer is pretty useless now! Feb 8 '18 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.