Skip to main content

How to merge home and root partitions on Centos 7


Sometimes while provisioning server from an image causes home partition gets assigned with  some partition which you don't want & yoiu want to merge root & home altogether.

Here is how you can do it:

[root@navicosoft-854 ~]# lsblk

NAME                                             MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

sda                                                8:0    0 465.8G  0 disk

├─sda1                                             8:1    0     1G  0 part /boot

└─sda2                                             8:2    0 464.8G  0 part

  ├─centos_navicosoft--user-root                        253:0    0    50G  0 lvm  /

  ├─centos_navicosoft--user-swap                        253:1    0  31.4G  0 lvm  [SWAP]

  └─centos_navicosoft--user-home                        253:2    0 383.3G  0 lvm  /home

sdb                                                8:16   0 931.5G  0 disk

sdc                                                8:32   0 465.8G  0 disk

├─vg2-vsv1003--d7ukx3rejw5mmq8i--q6ltarafzvxfk8nh

                                                 253:3    0    12G  0 lvm

└─vg2-vsv1004--dgxoydbojwnmbwro--wimqwmuu3ne3t9qw

                                                 253:4    0   100G  0 lvm

sdd                                                8:48   0 931.5G  0 disk

Firstly umount your home partition.

# umount /dev/mapper/centos_navicosoft--user-home

Then you need to remove this volume using lvremove

# lvremove /dev/mapper/centos_navicosoft--user-home

Do you really want to remove active logical volume centos_navicosoft-user/home? [y/n]: y

  Logical volume "home" successfully removed

Now you should extend volume using lvextend

# lvextend -l +100%FREE -r /dev/mapper/centos_navicosoft--user-root

  Size of logical volume centos_navicosoft-user/root changed from 50.00 GiB (12800 extents) to 433.32 GiB (110930 extents).

  Logical volume centos_navicosoft-user/root successfully resized.

meta-data=/dev/mapper/centos_navicosoft--user-root isize=512    agcount=4, agsize=3276800 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0 spinodes=0

data     =                       bsize=4096   blocks=13107200, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal               bsize=4096   blocks=6400, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 13107200 to 113592320

[root@navicosoft-user ~]# df -h

Filesystem                         Size  Used Avail Use% Mounted on

/dev/mapper/centos_navicosoft--user-root  434G   16G  419G   4% /

devtmpfs                            32G     0   32G   0% /dev

tmpfs                               32G     0   32G   0% /dev/shm

tmpfs                               32G   50M   32G   1% /run

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

/dev/sda1                         1014M  173M  842M  18% /boot

tmpfs                              6.3G     0  6.3G   0% /run/user/0