Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I initially created a dynamically expanding VirtualBox image, and have tried to increase its hard drive space:

VBoxManage modifyhd "VirtualBox VMs/JHBuild/JHBuild.vdi" --resize 16384

After that, I saw from the UI that it has increased to 16GB logical size:

enter image description here

Sadly, when I boot the image, I still get the initial size (e.g. when I use df).

share|improve this question

3 Answers 3

You should realize that when you boot a virtual machine, it sees the virtual disk as if it was a physical device and, as I understand from your description, the system you boot resides on the disk. So look from the point of view of your normal system: You've got a bigger disk but have the old-sized partition on it. Certainly, you must resize it. But not after booting into that very system (that is, not from the disk) - just as you should never resize your partition, from which your system booted.

So the solution is to download a bootable CD iso image like SystemRescueCD or Gparted live. Add it to your virtual machine (just in the menu you showed in your picture - select the "SATA Controller", click "Add CD/DVD Device" icon and then, on the right, browse for your iso file) and set to boot from that instead of the disk image (but do not remove the image of course). Once you've booted, run gparted and resize the partition. Shutdown the machine, remove the iso from it and boot back to your virtual disk :)

share|improve this answer
    
I don't see why it makes a difference if you booted from this disk or not. In both cases, you should have a backup. If you then remove and re-establish the needed partition, reboot and do a online resize2fs, all should be ok. –  glglgl Aug 17 '11 at 14:51
    
Absolutely not. Can you cut and enlarge a boat while floating on it? Or change the suspension while driving a car? This is shooting at your own knees. The system is running from the partition you are trying to change! –  rozcietrzewiacz Aug 17 '11 at 14:58
    
BTDT. Several times. You as well? A changed (removed and re-established) partition won't be recognized by the running OS - it behaves as if the partition table was the old one. This is safe until the next reboot, where the new size is recognized - but not yet by the file system. And the, now pending, online resizing of FS has been existing for years with no problems. –  glglgl Aug 18 '11 at 9:18

After increasing the size of the underlying device, you must as well increase the size of the file system and, if so, everything in-between (partitions, LVM stuff etc.).

If you don't have any if them, and your file system is ext[23], you can just use

resize2fs /dev/...

in order to increase up to the auto-determined size.

share|improve this answer
1  
Running sudo resize2fs /dev/sda1 gives me The filesystem is already 2096640 blocks long. Nothing to do!. –  Tshepang Aug 15 '11 at 18:29
1  
Running sudo resize2fs /dev/sda1 16G gives me The containing partition (or device) is only 2096640 (4k) blocks\nYou requested a new size of 4194304 blocks.. –  Tshepang Aug 15 '11 at 18:30
1  
Seems like the partition is too small, as only the size of the underlying blockdevice (/dev/sda) has changed. So you have to change the size of the partition first. Use cfdisk, fdisk or sfdisk and note the parameters of your partition, remove it and add it again at the same position but with a higher size. Then you should be able to resize2fs the file system. –  glglgl Aug 15 '11 at 18:47

WARNING: e2fsck will likely harm a mounted partition

You've just modified your disk (partition) size; You'll need to do the following to modify you fs size (providing that you are using ext* fs:

e2fsck -f /dev/<partition>
resize2fs /dev/<partition> <size>

HTH

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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