View the existing file structure and capacities with the df -h command.
[root@utlxd1304 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 1.3M 3.9G 1% /dev/shm tmpfs 3.9G 409M 3.5G 11% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/vg_root-rootvol 10G 2.8G 7.2G 28% / /dev/sda1 1014M 235M 780M 24% /boot /dev/mapper/appvg0-appvol0 50G 33M 50G 1% /app /dev/mapper/postgresvg-dbpostgres 350G 84G 267G 24% /db/postgres /dev/mapper/postgresvg-dbpostgres--backup 300G 246G 55G 82% /db/postgres/backup /dev/mapper/vg_root-optvol 6.0G 595M 5.5G 10% /opt /dev/mapper/postgresvg-optpostgres 50G 384M 50G 1% /opt/postgres /dev/mapper/vg_root-varvol 10G 4.7G 5.4G 47% /var /dev/mapper/vg_root-tmpvol 6.0G 35M 6.0G 1% /tmp /dev/mapper/vg_root-homevol 6.0G 34M 6.0G 1% /home
Use the command lsblk to display volume information prior to any changes.
[root@utlxd1304 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 60G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 59G 0 part ├─vg_root-swapvol 253:0 0 6G 0 lvm [SWAP] ├─vg_root-rootvol 253:1 0 10G 0 lvm / ├─vg_root-varvol 253:6 0 10G 0 lvm /var ├─vg_root-tmpvol 253:7 0 6G 0 lvm /tmp ├─vg_root-optvol 253:8 0 6G 0 lvm /opt └─vg_root-homevol 253:9 0 6G 0 lvm /home sdb 8:16 0 50G 0 disk └─sdb1 8:17 0 50G 0 part └─appvg0-appvol0 253:2 0 50G 0 lvm /app sdc 8:32 0 250G 0 disk └─sdc1 8:33 0 250G 0 part ├─postgresvg-optpostgres 253:3 0 50G 0 lvm /opt/postgres ├─postgresvg-dbpostgres 253:4 0 350G 0 lvm /db/postgres └─postgresvg-dbpostgres--backup 253:5 0 300G 0 lvm /db/postgres/backup sdd 8:48 0 250G 0 disk └─sdd1 8:49 0 250G 0 part ├─postgresvg-dbpostgres 253:4 0 350G 0 lvm /db/postgres └─postgresvg-dbpostgres--backup 253:5 0 300G 0 lvm /db/postgres/backup sde 8:64 0 200G 0 disk └─sde1 8:65 0 200G 0 part └─postgresvg-dbpostgres 253:4 0 350G 0 lvm /db/postgres sr0 11:0 1 1024M 0 rom
Find out the file system being used. This is important to know when formatting.
[root@utlxd1304 ~]# df -kh -T /db/postgres/backup Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/postgresvg-dbpostgres--backup xfs 300G 246G 55G 82% /db/postgres/backup
Add a new disk of the desired size within VMWare. Once the new disk has been added, you will want to run lsblk again on the system you want to add disk space. You should see the additional volume listed now. In our case, you can see the new volume named sdf.
[root@utlxd1304 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 60G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 59G 0 part ├─vg_root-swapvol 253:0 0 6G 0 lvm [SWAP] ├─vg_root-rootvol 253:1 0 10G 0 lvm / ├─vg_root-varvol 253:6 0 10G 0 lvm /var ├─vg_root-tmpvol 253:7 0 6G 0 lvm /tmp ├─vg_root-optvol 253:8 0 6G 0 lvm /opt └─vg_root-homevol 253:9 0 6G 0 lvm /home sdb 8:16 0 50G 0 disk └─sdb1 8:17 0 50G 0 part └─appvg0-appvol0 253:2 0 50G 0 lvm /app sdc 8:32 0 250G 0 disk └─sdc1 8:33 0 250G 0 part ├─postgresvg-optpostgres 253:3 0 50G 0 lvm /opt/postgres ├─postgresvg-dbpostgres 253:4 0 350G 0 lvm /db/postgres └─postgresvg-dbpostgres--backup 253:5 0 300G 0 lvm /db/postgres/backup sdd 8:48 0 250G 0 disk └─sdd1 8:49 0 250G 0 part ├─postgresvg-dbpostgres 253:4 0 350G 0 lvm /db/postgres └─postgresvg-dbpostgres--backup 253:5 0 300G 0 lvm /db/postgres/backup sde 8:64 0 200G 0 disk └─sde1 8:65 0 200G 0 part └─postgresvg-dbpostgres 253:4 0 350G 0 lvm /db/postgres sdf 8:80 0 100G 0 disk sr0 11:0 1 1024M 0 rom
Use parted to partition the new volume.
[root@utlxd1304 ~]# parted /dev/sdf -- mklabel gpt Information: You may need to update /etc/fstab.
Make the partition a primary partition using all the available space.
[root@utlxd1304 ~]# parted /dev/sdf -- mkpart primary 0% 100% Information: You may need to update /etc/fstab.
Use pvcreate to initialize the new disk.
[root@utlxd1304 ~]# pvcreate /dev/sdf1 Physical volume "/dev/sdf1" successfully created.
Add the newly partitioned volume to the LVM.
[root@utlxd1304 ~]# vgextend postgresvg /dev/sdf1 Volume group "postgresvg" successfully extended
We are going to extend the LVM by 99G.
[root@utlxd1304 ~]# lvextend -L +99G /dev/mapper/postgresvg-dbpostgres--backup Size of logical volume postgresvg/dbpostgres-backup changed from 300.00 GiB (76800 extents) to 399.00 GiB (102144 extents). Logical volume postgresvg/dbpostgres-backup successfully resized.
We will use xfs_growfs to expand the file system as our example uses the xfs format. Different commands are required if the LVM is formatted with ext4.
[root@utlxd1304 ~]# xfs_growfs /dev/mapper/postgresvg-dbpostgres--backup meta-data=/dev/mapper/postgresvg-dbpostgres--backup isize=512 agcount=13, agsize=6553344 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=78643200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=12799, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 78643200 to 104595456
If the file system uses ext4, we will use resize2fs to expand the file system using a different system for our example.
[root@utlxd368 ~]# resize2fs /dev/mapper/postgresvg-dbpostgres--backup resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mapper/postgresvg-dbpostgres--backup is mounted on /backup; on-line resizing required old_desc_blocks = 3, new_desc_blocks = 6 The filesystem on /dev/mapper/postgresvg-dbpostgres--backup is now 24379392 blocks long.
Now you can check your work. Notice the increased size of /db/postgres/backup.
[root@utlxd1304 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 292K 3.9G 1% /dev/shm tmpfs 3.9G 409M 3.5G 11% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/vg_root-rootvol 10G 2.8G 7.2G 28% / /dev/sda1 1014M 235M 780M 24% /boot /dev/mapper/appvg0-appvol0 50G 33M 50G 1% /app /dev/mapper/postgresvg-dbpostgres 350G 84G 267G 24% /db/postgres /dev/mapper/postgresvg-dbpostgres--backup 399G 246G 154G 62% /db/postgres/backup /dev/mapper/vg_root-optvol 6.0G 597M 5.5G 10% /opt /dev/mapper/postgresvg-optpostgres 50G 384M 50G 1% /opt/postgres /dev/mapper/vg_root-varvol 10G 4.7G 5.4G 47% /var /dev/mapper/vg_root-tmpvol 6.0G 35M 6.0G 1% /tmp /dev/mapper/vg_root-homevol 6.0G 34M 6.0G 1% /home