2

I'm trying to increase the size of the root / mount.

[root@coxdev-vn08 ~]# df -h
Filesystem                              Size  Used Avail Use% Mounted on
/dev/mapper/vg_system-lv_os             4.5G  2.4G  2.1G  54% /
devtmpfs                                2.9G     0  2.9G   0% /dev
tmpfs                                   2.9G  4.0K  2.9G   1% /dev/shm
tmpfs                                   2.9G  560K  2.9G   1% /run
tmpfs                                   2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/sda1                               509M  135M  375M  27% /boot
/dev/mapper/vg_system-lv_home          1014M   33M  982M   4% /home
/dev/mapper/vg_system-lv_tmp           1014M   35M  980M   4% /tmp
/dev/mapper/vg_system-lv_var            2.0G  1.4G  622M  70% /var
/dev/sda3                                10G   33M   10G   1% /var/www/miq_tmp
/dev/mapper/vg_system-lv_var_log         11G   83M   11G   1% /var/log
/dev/mapper/vg_system-lv_var_log_audit  509M   27M  483M   6% /var/log/audit
/dev/mapper/vg_data-lv_pg                14G  142M   14G   2% /var/opt/rh/rh-postgresql95/lib/pgsql
tmpfs                                   581M     0  581M   0% /run/user/0

/ is now 4.5GB in size and 2.1GB available. But to install GNOME Desktop I need ~350MB more.

We have increased the virtual disk size to 107GB and now there's 53.7GB of free space.

(parted) print free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  538MB   537MB   primary   xfs          boot
 2      538MB   28.5GB  27.9GB  primary                lvm
 3      28.5GB  39.2GB  10.7GB  primary   xfs
 4      39.2GB  53.7GB  14.5GB  extended
        39.2GB  39.2GB  802kB             Free Space
 5      39.2GB  53.7GB  14.5GB  logical                lvm
        53.7GB  107GB   53.7GB            Free Space

But I can't figure out how to use that free space to increase the / size.

lvextend -L +30G /dev/mapper/vg_system-lv_os

Results in:

Insufficient free space: 7680 extents needed, but only 35 available

1 Answer 1

3

You have to grow the partition first, then the PV, then the LV, finally the filesystem.

Grow the partition should be something along these lines in your case:

parted /dev/sda resizepart 4 100% # extended
parted /dev/sda resizepart 5 100% # logical

You might have to reboot afterwards, if the disk is in use, to make the kernel see the new partition layout.

Grow the PV:

pvresize /dev/sda5

Grow the LV:

lvextend -L+30G vg_system/lv_os

Finally, grow the filesystem:

resize2fs /  # if ext4
xfs_growfs / # if xfs
8
  • I'm on centOS and I've installed parted. But that's version 3.1 so there's no resizepart function. Apr 11, 2017 at 14:37
  • Without resizepart, you'll have to unit s, print free to get the start sector of partition 5 and the end sector of free space, rm 5, rm 4, mkpart primary <start>s <end>s (or do a two step mkpart extended, mkpart logical, if you wish to keep a single logical partition instead of making it primary). Have a care, if the start sector does not match, the data is gone. Creating logical partitions in the wrong place is destructive. Apr 11, 2017 at 14:49
  • Why do I have to remove partition 5 & 4? Apr 11, 2017 at 14:55
  • 1
    If you can't resize, it's remove and re-create with same start sector. Apr 11, 2017 at 15:01
  • Okay. Let me ask you a question though. I want to increase the volume size of /dev/mapper/vg_system-lv_os. That's located on a partition right? How do you know what partition to grow so I can allocate more space to the /dev/mapper/vg_system-lv_os volume? Apr 11, 2017 at 15:03

You must log in to answer this question.

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