I have CentOS installed in my VirtualBox and there was small HDD for the system itself(about 8-9GB). After some time of using this, this virtual disc got full and I couldn't install updates so I extended the HDD with VBoxManage and GParted to 25GB. But now, even if it has greater capacity, I can't install these updates because of not enought space left. Here is what fdisk -l tells me

Disk /dev/sda: 26,2 GB, 26 214 400 000 bajtů
hlav: 255, sektorů na stopu: 63, cylindrů: 3 187
Jednotky = cylindry po 16065 * 512 = 8 225 280 bajtech
Velikost sektoru (logického/fyzického): 512 bajtů / 512 bajtů
Velikost I/O (minimální/optimální): 512 bajtů / 512 bajtů
Identifikátor disku: 0x000242e1

Zařízení Zavádět   Začátek       Konec    Bloky    Id  Systém
/dev/sda1   *           1          64      512000   83  Linux
Diskový oddíl 1 nekončí na hranici cylindru.
/dev/sda2              64        3188    25086976   8e  Linux LVM

(sorry for the language).

df -h

Filesystem            Size  Used Avail Use% Mounted on
                      6,5G  6,2G     0 100% /
tmpfs                 1,9G  324K  1,9G   1% /dev/shm
/dev/sda1             485M  114M  346M  25% /boot

I've also tried the resize2fs /dev/sda2 but it gives me an error about bad superblock. So I've tried the fsck -t ext4 /dev/sda command but no success again(first error was about that the /dev/sda is currently used and when I booted into the CentOS rescue mode, the error changed to couldn't open /etc/fstab: No such file or directory and info about that the superblock is invalid.

How can I use the newly added space?


Notice that your slash directory /, is coming from an LV (Logical Voume) from LVM, /dev/mapper/VolGroup-lv_root. So to get the newly added space into / you need to extend it in LVM first, then extend it into the EXT4 partition.

The first thing you'll notice is that the underlying physical drive that is providing the storage for LVM is /dev/sda2. NOTE: I'm assuming that's the device providing the storage a better way to determine this would be to inquire through LVM first.


Physical disks aka. PV's (Physical Volumes) assigned to a VG (Volume Group).

$ sudo pvs
  PV         VG               Fmt  Attr PSize   PFree
  /dev/sda2  fedora_greeneggs lvm2 a--  465.27g    0 

Makeup of VG's. Notice it has 1 physical volume (that's the above), and it contains 3 LV's (see below).

$ sudo vgs
  VG               #PV #LV #SN Attr   VSize   VFree
  fedora_greeneggs   1   3   0 wz--n- 465.27g    0 

The VG contains 3 LV's. You can see them below, as well as what VG they're part of.

$ sudo lvs
  LV   VG               Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
  home fedora_greeneggs -wi-ao--- 407.63g                                           
  root fedora_greeneggs -wi-ao---  50.00g                                           
  swap fedora_greeneggs -wi-ao---   7.64g              


So here's what you need to do:

  1. Extend the extra space from /dev/sda2 into the LVM Group

    $ pvresize /dev/sda2
  2. Extend the newly added free space into the Logical Volume

    $ lvextend -L 100% /dev/mapper/VolGroup-lv_root
  3. Extend the newly added free space into the ext4 partition

    $ resize2fs /dev/VolGroup/lv_root



You are using lvm so you need to extend the logical volume and resize the filesystem:

lvextend -L 100% VolGroup/lv_root
resize2fs /dev/VolGroup/lv_root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.