How to Create a Filesystem on Dynamic-sized Virtual Drive - VirtualBox on Windows 7 Host, Ubuntu Guest

2

Moved here from StackOverflow

I made my VirtualBox (4.3.0) Ubuntu VM (on Win 7 host) too small. I have the choice of enlarging the virtual disk (all I read makes that sound dangerous and complicated) or to add a second "drive" (which sounds easier). I chose the second drive.

I shut down and cloned my VM. On the clone VM I went to the storage setting and added another, much larger, SATA drive (350 GiB). I set it to dynamically allocate space.

I booted up the VM and used ffdisk to make a partition table (primary partition using the whole drive). Seemed to work and fdisk /dev/sdb, p command says:

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1       734003199   734003199        0+  83  Linux

Now to put a filesystem on the disk. I issue the command:

sudo mkfs.ext4 -L /data /dev/sdb1

and get the message

mke2fs 1.42 (29-Nov-2011)
mkfs.ext4: Device size reported to be zero.  Invalid partition specified, or
    partition table wasn't reread after running fdisk, due to
    a modified partition being busy and in use.  You may need to reboot
    to re-read your partition table.

Rebooting did not fix the problem.

The description of the second drive from the VBox Manager reads:

Type:             normal (VDI)
Virtual Size:     350.00 GB
Actual Size:      3.00 MB
Details:          Dynamically allocated st...

Can someone advise me on how to approach this problem? Google nor StackOverflow have yielded any useful answers.

Wes Miller

Posted 2013-11-11T13:20:37.517

Reputation: 233

2Looks like you're going hardcore with the low-level commands. In the Ubuntu VM, why not use 'gparted' to create and initialize your new HD – rickhg12hs – 2013-11-11T13:33:08.487

3

The partition you created is 0 blocks long. Remove it and create a proper new partition. https://help.ubuntu.com/community/InstallingANewHardDrive

– Der Hochstapler – 2013-11-11T14:03:37.260

Thanks to both of you. It was 0 bytes long and gparted was a big help. Problem fixed. – Wes Miller – 2013-11-11T20:10:37.123

No answers