How to delete / home partition and expand root partition in Centos 7

A series of articles on working with a hard drive

  • Mount a new disk in CentOS
  • How to grow LVM partition on CentOS 7
  • Add new disk to Centos 7
  • How to delete / home partition and expand root partition in Centos 7
  • Mount LVM partition on Ubuntu 18.04 / 18.10
  • Extend LVM partition for GPT disk tables on Centos 7

We look at the sections:

[[email protected] ~]# df -h
Файловая система        Размер Использовано  Дост Использовано% Cмонтировано в
/dev/mapper/centos-root    36G         899M   35G            3% /
devtmpfs                  486M            0  486M            0% /dev
tmpfs                     497M            0  497M            0% /dev/shm
tmpfs                     497M         6,6M  490M            2% /run
tmpfs                     497M            0  497M            0% /sys/fs/cgroup
/dev/sda1                1014M         125M  890M           13% /boot
/dev/mapper/centos-home    18G          33M   18G            1% /home
tmpfs                     100M            0  100M            0% /run/user/0

Unmount the / home partition, otherwise further actions will not be performed

[[email protected] ~]# umount /home

Remove the / home partition:

[[email protected] ~]# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume centos/home? [y/n]: y
  Logical volume "home" successfully removed

Extending the root section:

[[email protected] ~]# lvextend -l +100%FREE -r /dev/mapper/centos-root

Do not forget to comment out or remove the mount line from the / etc / fstab file, otherwise the OS will not boot after a reboot:

[[email protected] ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Jun 14 10:36:47 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=57c0960d-c69c-42e7-80bc-84c7fc57ba41 /boot                   xfs     defaults        0 0
#/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0

We look at the result:

[[email protected] ~]# df -h
Файловая система        Размер Использовано  Дост Использовано% Cмонтировано в
/dev/mapper/centos-root    53G         899M   52G            2% /
devtmpfs                  486M            0  486M            0% /dev
tmpfs                     497M            0  497M            0% /dev/shm
tmpfs                     497M         6,6M  490M            2% /run
tmpfs                     497M            0  497M            0% /sys/fs/cgroup
/dev/sda1                1014M         125M  890M           13% /boot
tmpfs                     100M            0  100M            0% /run/user/0
Sidebar