Page 1 of 1

CentOS 6 not growing disk space

Posted: 23. Aug 2012, 19:21
by rnutter
I am trying to install Splunk on a CentOS 6 install. I created the drive as an 8 gb dynamic growth drive. The system thinks it has maxed out at 3.6gb and wont see the additional disk space. Virtualbox itself thinks that 3.7 to 8 is still available for expansion.

Any ideas ? Has anyone else run into this ?

Ron

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 19:31
by Perryg
Sure. Which partition is maxed out?

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 19:49
by rnutter
The one labeled / of course.

Ron

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 19:56
by Perryg
Well there you are. The drive is not max'ed out. The partition is. Give it more room.

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 20:10
by rnutter
That is my question. Virtualbox thinks there is still 4gig available on the drive. CentOS only see the initial 3.6 that it got when it was installed. I am in the process of learning linux so I dont know what the next step is for CentOS to see the additional drive space. It was my understanding that it was supposed to happen automatically.

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 20:12
by michaln
rnutter wrote:It was my understanding that it was supposed to happen automatically.
Out of curiosity, what was your understanding based on?

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 20:17
by rnutter
My understanding was based on what Virtualbox said when I created the drive about it growning dynamically. Obviously it doesnt play nice with CentOS and probably other linux distros. Just need to know how to get it to see the additional file space that is there but it doesnt know about yet.

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 20:23
by Perryg
It's not that VirtualBox does not know or see the partition information. It does not care. Once VirtualBox has provided the HDD the OS (with your guidance) is responsible to partition and format the drive.

You need to first figure out how you partitioned the drive. Probably LVM and then you need to learn how to increase the partition to a more usable size. For that you are better off seeking help from the distro you are using in particular their forum.

Re: CentOS 6 not growing disk space

Posted: 23. Aug 2012, 22:30
by michaln
rnutter wrote:My understanding was based on what Virtualbox said when I created the drive about it growning dynamically.
Didn't you choose a maximum size when creating the virtual disk?

Re: CentOS 6 not growing disk space

Posted: 24. Aug 2012, 10:57
by mpack
@rnutter, to cut this sport short: all of us here had had this discussion several times. We know that there is nothing in the manual or in the user interface which expresses or even implies that virtual disks have, or ever could have, a variable capacity. Such a thing would be impossible for most currently existing guest OSs to handle. Your confusion is based on invalid assumptions combined with failure to RTFM. Dynamic Allocation <> Variable capacity. Dynamic Allocation <> Infinite capacity.

Re: CentOS 6 not growing disk space

Posted: 26. Aug 2012, 22:49
by cybervzhn
Considering you came here because of a problem, rather than get bogged semantics about misconceptions and what other people know, I'll just share what you need.

Perryg gave the right advice, it's always distribution-specific because you are talking about what the Guest VM sees.

As always the standard caveat is that you should backup everything before you start changing things, at the very least, the virtual disk files you will be changing.

The part you are missing is allowing the Guest VM to use the additional space. If you allowed CentOS defaults to use LVM, you are in luck. Every Virtualization platform allows expanding a dynamic or thin disk on the VM Host with a simple command, for example with VirtualBox to make the disk 100GB in size(note: this happens on the VM host, or where VM guests run):

VBoxManage modifyhd "D:\VirtualBox VMs\CentOS_6\CentOS_6.vdi" --resize 102400

or with Linux

VBoxManage modifyhd "VirtualBox VMs/CentOS6/CentOS6.vdi" --resize 102400

You can also do this in the GUI interface, but I find giving advice works better with specific commands, the general assumption that always comes with examples is that you have to verify the commands to your specific situation before using them.

After that, you will be working inside the Guest VM to get it to recognize this new space.

In general terms, with LVM you will need to:

-Run fsck on that volume within the VM Guest, remount or reboot, then make a backup copy of the virtual disk image file on the VM Host before you start. This is important because you will resizing a live filesystem, you do not want bad blocks or disk inconsistencies to cause the resize to fail. Just having the system lose power or power off without successfully shutting down gracefully can leave behind disk inconsistencies that could cause problems in the future. Just reboot with "shutdown -Fr now" to reboot forcing a disk check before the volumes are mounted. CentOS6 live CD or Rescue more is another option (example at end).

-Increase the virtual disk size in VirtualBox or add a new virtual disk if the existing one already has 4 primary partitions
-Add a new primary type 8e (Linux LVM) partition the size you want to add to the virtual disk from inside the CentOS(VM guest) with "fdisk" or "cfdisk", reboot so partition is properly recognized.(max 4 primary partitions per virtual disk)
-"pvcreate" a new Physical Volume(PV) using this new partition you just created
-"vgextend" the correct LVM Volume Group(VG) with the PV you just created
-"lvextend" the correct LVM Logical Volume(LV) that needs more space
-"resizse2fs" this larger Logical Volume to utilize the new space
-boot into single user mode, umount, and "fsck" the Logical Volume to make sure everything is updated and clean
Once again, never run fsck on a mounted volume or disk.

BEFORE YOU START: You made a backup of the virtual disk file right? (don't skip this part, do it now if you haven't) You need to know which drive needs more space and how it is mounted to determine the Volume Group and Logical Volume names.

"df -h" shows disk space usage.

After you determine which needs space, you need to look at mounting to determine where the space needs to go.

By default, CentOS will mount /boot directly from a disk partition and mount the rest with drive mappings under LVM.

"mount" shows disk and LVM names by how they are mounted

[cybervzhn@dev ~]$ mount
/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw,grpquota,usrquota)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext4 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

LVM commands that help understanding are pvscan, pvdisplay, vgscan, vgdisplay, lvscan, lvdispay

After you determine the LVM info and know which drive is associated with the bigger virtual disk, take a look at your existing partitions in CentOS.

In this example I had a 5GB dynamic virtual disk that I increased to 10GB and it was mapped to VolumeGroup00 on LogicalVolume00

(after increasing virtual disk image size)
fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 195 1518142 8e Linux LVM

The next partition on this drive would be /dev/sda3, so that's what should be created.

(note: if there are already 4 partitions, it's not a problem with LVM, you just have to add a completely new Virtual Disk to add in LVM to "expand" the "Volume Group" and resize the "Logical Volume" or disk)

add /dev/sda3 primary partition type 8e in cfdisk or fdisk.

fdisk /dev/sda
'n', to create a new partition
"p" to make it primary partition
"3" for new partition number
"t" to specify type
"3" to choose which partition to change type
"8e" to specify type of Linux LVM
"w" to write changes to drive and reboot (you made a backup 1st before changing right?)

"fdisk -l" will show your bigger drive
pvscan
pvcreate /dev/sda3
pvscan
vgdisplay
vgextend VolGroup00 /dev/sda3
vgdisplay
lvdisplay
lvextend /dev/VolGroup00/LogVol00 /dev/sda3
lvdisplay
resize2fs /dev/VolGroup00/LogVol00

Note: you should always umount volumes before running fsck, CentOS6 will do this for you before they are mounted after reboot with "shutdown -Fr now".

If that fails for some reason, the second option is to "fsck" or check the volume for errors from boot from CentOS6 CD/DVD with "boot: linux rescue"
The Volumes have to be recognized by LVM, so...
lvm pvscan
lvm vgscan
lvm lvchange -ay VolGroup00
lvm lvscan
umount /dev/VolGroup00/LogVol00
fsck -y /dev/VolGroup00/LogVol00


Reboot and you should be set.

I hope that helps...
--

Re: CentOS 6 not growing disk space

Posted: 4. Dec 2012, 00:11
by MaxDrown
I know this post was a little while in the past, but thank you cybervzhn!! Your information was a huge help.

Resized volume group not growing disk space!

Posted: 11. Oct 2013, 02:38
by usysinc
I have tried resizing a volume group of a Linux guest OS on a Windows host machine, from an original 10G to 14G. Problem is that df -h does not appear to acknowledge that the volume group has indeed been grown. Also performing resize2fs on the /dev/VolGroup/LogicalVol which corresponds to /dev/sda2 gives a "bad magic number error". I gather that this is so because this volume group does not contain boot sector?

Question: Where are my additional +900 extents (3.5G)? Why are they not showing up?

I did the following:

1. Cloned the .vmdk VM disk image into an .iso format with the VBoxManage “clonehd” command.

“C:\Program Files\Oracle\VirtualBox\VBoxManage.exe” clonehd –format VDI “C:\SPB_Data\VirtualBox VMs\Oracle Virtual Sysadmin Days\OracleLinux64-disk1.vmdk” “C:\SPB_Data\VirtualBox VMs\Oracle Virtual Sysadmin Days\OracleLinux64-disk1.vdi”

2. Re-sized the .vdi image with the VBoxManage “modifyhd” command.

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "C:\SPB_Data\VirtualBox VMs\Oracle Virtual Sysadmin Days\OracleLinux64-disk1.vdi" --resize 14000

3. Use Gparted to increase the volume group vg_oraclelinux6 partition size to its full capacity.

4. Booted into Oracle-linux6 and extended the vg_oraclelinux6 volume group with the Linux “lvextend” command.

$ sudo lvextend -v -l +900 -r vg_oraclelinux6/lv_root

vgdisplay
vgextend vg_oraclelinux6 /dev/sda2
vgdisplay
lvdisplay
lvextend /dev/vg_oraclelinux6/lv_root /dev/sda2
lvdisplay

resize2fs /dev/vg_oraclelinux6/lv_root
Bad magic number in super-block … Coundn't find valid filesystem superblock.

lvm pvscan
lvm vgscan
lvm lvchange -ay vg_oraclelinux6
lvm lvscan
umount /dev/vg_oraclelinux6/lv_root
fsck -y /dev/vg_oraclelinux6/lv_root

shutdown -Fr now

Re: Resized volume group not growing disk space!

Posted: 11. Oct 2013, 10:27
by mpack
usysinc wrote: I did the following:

1. Cloned the .vmdk VM disk image into an .iso format with the VBoxManage “clonehd” command.
Hmm. I'm afraid not. There is no ISO conversion provided by VBoxManage, and anyway the command you give is converting VMDK to VDI. Also these LVM tutorials are off topic in these forums.

We seem to be diverging somewhat from the OPs post, so time to lock this one perhaps.