You'll need to create a new partition and extend your lvm /dev/mapper/centos-root
.
Firstly, let's create /dev/sda3
:
$ echo "n\np\n\n\n\nw" | fdisk /dev/sda
(you can manually give the values if you prefer with fdisk /dev/sda
- the above just uses defaults - i.e. all the space on the next partition number available)
Now, we need to create it as a physical volume:
$ pvcreate /dev/sda3
Once, that's done, we have to extend the volume group first, then the LVM.
To find the volume group:
$ vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz--n- 19.51g 0
So the volume group’s name in this example is “VolGroup” Let’s extend it:
$ vgextend VolGroup /dev/sda3
Running vgs
should now show the new size.
Now for the LVM extension. find the true path with lvdisplay
:
$ lvdisplay | grep Path
LV Path /dev/VolGroup/lv_root
Then extend it:
$ lvextend /dev/VolGroup/lv_root /dev/sda3
Now, lvdisplay
or lvs
will show the new size. But the filesystem still isn't extended if you check in df -h
- we need to resize that.
There are a few ways of doing this live (whilst the server is running and not in recovery), the one you use will depend on the file system type.
You can easily find the fs type with mount | grep mapper
.
For ext3/4
, use resize2fs
:
$ resize2fs /dev/mapper/VolGroup-lv_root
Note that I'm using /dev/mapper/VolGroup-lv_root
- as in the filepath in the output of df -h
.
for xfs
use xfs_growfs
:
$ xfs_growfs /dev/mapper/VolGroup-lv_root
Then df -h
should show the new size.
tmpfs
lines have nothing to do with your question. (3) Please do a web search for “tmpfs”. You will find lots of information. If you have problems understanding what you find, then ask a question here. (4) Thelsblk
output shows that your virtual disk is 25 GB, and the root filesystem is 8 GB. I don’t see 20 GB anywhere. – G-Man Says 'Reinstate Monica' Sep 19 '18 at 03:25