4

I am running Virtualbox. I increased the size of my hard disk (.vdi) from 10G to 15G. Now when I start my Mint vm, the hard disk reports as 7.5g (df) even though i extended it (fdisk -l). I am not sure what is the problem. Can anyone point me the problem?

$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 >>7.5G<< 7.1G 61M 100% / udev 1.5G 4.0K 1.5G 1% /dev tmpfs 581M 888K 581M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1.5G 88K 1.5G 1% /run/shm $ sudo fdisk -l Disk /dev/sda: >>16.1 GB<<, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c55a4 Device Boot Start End Blocks Id System /dev/sda1 * 2048 15728639 7863296 83 Linux /dev/sda2 15730686 16775167 522241 5 Extended /dev/sda5 15730688 16775167 522240 82 Linux swap / Solaris $ vboxmanage showhdinfo mint.vdi UUID: a94931b9-673c-440a-ab6b-2c3eedd0cf93 Accessible: yes Logical size: 15360 MBytes Current size on disk: 7806 MBytes Type: normal (base) Storage format: VDI Format variant: dynamic default Location: /opt/virtualization/vm/mint.vdi 
1
  • What filesystem do you have on /? That'll need to be resized too probably. Commented Sep 16, 2012 at 13:02

2 Answers 2

2

You've resized the disk, but not the partition nor the filesystem on that partition. There is now unpartitioned space at the end of the disk.

A partition needs to be contiguous, so you'll need to move the swap partition to the end of the disk. The easiest way of doing that is to turn off swap (swapoff -a), delete the swap partition /dev/sda5 (and, since it's a logical partition, also delete the extended partition /dev/sda2), recreate it and turn the swap back on.

After that, extend the system partition /dev/sda1: change its end location to use all the space except the part used by the swap partition.

While this can be done manually with fdisk, I recommend using GParted. Boot from a GParted bootable image in the VM.

After you've moved and resized the partitions, expand the root filesystem to use all the space in the partition. You can do that in GParted, or manually with resize2fs /dev/sda1 (this can be done from the running system).

1
  • true, i almost did the same except i deleted and recreated all the partitions using fdisk. Can you recommend me some good study material on filesystems and partitions? Commented Sep 17, 2012 at 8:04
2

Even thought you've resized the underlying device in your VM, nobody has told the actual filesystem that the available space has changed. Your partion table on disk probably hasn't changed either. So, ext3 sees your root partition as starting at sector X and ending at sector Y. What you did in extending the size of the VDI was add sectors to the end of the VDI. So your ext3 partition beginning at sector X still only extends to sector Y.

What you need now is to do two more things. Update the partition table so that /dev/sda starts at sector X and now extends to the newly available sector Z, then you need to tell ext3 (ext2 really) that it can expand into the new space. In some operating systems this is done with a simple growfs -M /device command. In Linux it seems that this is more complicated, and involves converting your ext3 fs to ext2 (by removing the journal), then expanding your partition.

http://www.howtoforge.com/linux_resizing_ext3_partitions

That site has all the steps you'll need.

2
  • hi, thanks for pointing out. i did not follow the tutorial. i resized the partition using fdisk and used resize2fs to make the file system manager use the entire newly extended partition. it worked. Commented Sep 16, 2012 at 22:06
  • 1
    Growing an ext2/ext3/ext4 filesystem in Linux is straightforward, there's no need to remove the journal or anything like that, and extending (but not shrinking) can be done while the filesystem is mounted, with resize2fs. Commented Sep 16, 2012 at 22:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.