0

I first installed the centos on the virtual box and only assigned 8GB to it. Now I've extended the VIRTUAL BOX file system and it has around 25gb.

As you can see below it's showing as tmpfs when I do "df -h" command and when I do "lsblk" it's showing root file system has 20gb. How can I extend the centos-root file system?

And, what is tmpfs?

information of file systems

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Hybrid
  • 103
  • (1) Please post text (e.g., command-line commands and output) as text and not as images (screenshots). (2) The 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) The lsblk 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
  • See https://unix.stackexchange.com/questions/468252/extend-lvm-size/468255#468255 – Emmanuel Rosa Sep 19 '18 at 05:23
  • partition sda2 is 9G, you should create a sda3 with the rest, and add it as physical disk (in LVM way). – Archemar Sep 19 '18 at 07:52

1 Answers1

0

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.

RobotJohnny
  • 1,039
  • 8
  • 18