0

I have an issue with the storage of my virtual machine which is running on CentOS 7. I'd like to enlarge the home directory which is currently completely used but there is clearly free space on the other partitions:

[root@localhost ~]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0               2:0    1    4K  0 disk 
sda               8:0    0  250G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   63G  0 part 
  ├─centos-root 253:0    0   38G  0 lvm  /
  ├─centos-swap 253:1    0  6.4G  0 lvm  [SWAP]
  └─centos-home 253:2    0 18.6G  0 lvm  /home
sr0              11:0    1  973M  0 rom  
[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 7.8G     0  7.8G   0% /dev
tmpfs                    7.8G  8.8M  7.8G   1% /run
tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/centos-root   39G  1.8G   37G   5% /
/dev/sda1               1014M  194M  821M  20% /boot
/dev/mapper/centos-home   19G   19G  8.8M 100% /home
tmpfs                    1.6G     0  1.6G   0% /run/user/0

Is there a solution to use the free spaces for my home directory? I'd be grateful for any help.

1 Answer 1

0

There is unpartitioned space on /dev/sda that can be added to the logical volume that is mounted on /home.

Required steps:

  1. Reboot into live-cd.
  2. Create new partition on /dev/sda (using gparted, or fdisk/gdisk/etc.)
  3. lsblk # Note the newly created partition number (/dev/sda3 in this example).
  4. pvcreate /dev/sda3 # Make the new partition into a physical volume in the LVM system.
  5. sudo lvs # Note the name of the "VG" that centos-home is using.
  6. vgextend /dev/sda3
  7. sudo vgs # Note the free space now available in the Volume Group (VG) we just extended.
  8. lvextend --resizefs --size +100G /centos-home

The last step will resize the Logical Volume that your /home filesystem sits on, as well as resizing the filesystem itself.

Now just reboot into your main OS.

3
  • He can do all that without rebooting using fdisk or parted, but I will suggest making a backup of important files first. Commented Apr 12, 2021 at 2:45
  • Oh really? I didn't know you could partition a disk with mounted partitions on it. Good to know.
    – superboot
    Commented Apr 12, 2021 at 2:46
  • Thanks a lot! It worked
    – Jaw. M.
    Commented Apr 13, 2021 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .