Home » How To Increase root partition by reducing /home

How To Increase root partition by reducing /home

  • by

By default, most Linux Installers create separate /home partition, occupying most of the drive space, this article will describe How To increase root partition by reducing /home.

When server is used mostly for system services, you may transfer free space from /home partition to root partition.
Before adjustment we have root 12G partition and 43G free space on /home, which we would like to use:

Filesystem                    Type      Size  Used Avail Use% Mounted on
udev                          devtmpfs  1.1G     0  1.1G   0% /dev
tmpfs                         tmpfs     208M  508k  208M   1% /run
/dev/mapper/devninja--vg-root ext4       12G  1.9G  9.5G  17% /
tmpfs                         tmpfs     1.1G     0  1.1G   0% /dev/shm
tmpfs                         tmpfs     5.3M     0  5.3M   0% /run/lock
/dev/vda1                     ext2      493M   89M  379M  19% /boot
/dev/mapper/devninja--vg-home ext4       45G  689k   43G   1% /home
/dev/mapper/devninja--vg-tmp  ext4      791M   46k  734M   1% /tmp
/dev/mapper/devninja--vg-var  ext4      4.3G  544M  3.5G  14% /var
tmpfs                         tmpfs     208M     0  208M   0% /run/user/1000

Umount home partition

First step is to unmount /home partition with command

umount /home

Shrink old /home

Shrink old /home partition to 20GB, (system will force you to check filesystem for errors by running e2fsck)

e2fsck -f /dev/mapper/devninja--vg-home # or using fsck -f /dev/mapper/devninja--vg-home
resize2fs /dev/mapper/devninja--vg-home 33G

Reduce the LVM

lvreduce -L -33G /dev/mapper/devninja--vg-home

Extend /root LVM to new size

Extend /root LVM to new size, utilizing 100% of free space on disk

lvextend -l +100%FREE /dev/mapper/devninja--vg-root

Increase root partition

Grow /root (ext3/4) partition to new LVM size

lvextend -l +100%FREE /dev/mapper/devninja--vg-root

Mount /home

mount /home

Result

Filesystem                    Type      Size  Used Avail Use% Mounted on
udev                          devtmpfs  1.1G     0  1.1G   0% /dev
tmpfs                         tmpfs     208M  508k  208M   1% /run
/dev/mapper/devninja--vg-root ext4       47G  2.0G   43G   5% /
tmpfs                         tmpfs     1.1G     0  1.1G   0% /dev/shm
tmpfs                         tmpfs     5.3M     0  5.3M   0% /run/lock
/dev/vda1                     ext2      493M   89M  379M  19% /boot
/dev/mapper/devninja--vg-tmp  ext4      791M   46k  734M   1% /tmp
/dev/mapper/devninja--vg-var  ext4      4.3G  544M  3.5G  14% /var
tmpfs                         tmpfs     208M     0  208M   0% /run/user/0
/dev/mapper/devninja--vg-home ext4      9.6G   39M  9.1G   1% /home

After these simple steps we have 95% of free disk space of root partition.

Tags:

Leave a Reply

Your email address will not be published.

twelve + two =