How to expand the file system for RPi emulation with QEMU?

Posted on

QUESTION :

I’ve recently grabbed a pre-compiled version of QEMU running Raspbian Wheezy for use on Windows as I would like to do some testing and a dev environment like this is far more kind than using the actual device.

The only problem I have come across is that after the initial boot the device doesn’t have much free space and I can’t use raspi-config to expand the device at all. I am assuming this is because I’m not running it on any particular virtual disk, or I am but it is of fixed size?

Below is the batch file which runs the virtual machine in question.

qemu-system-arm.exe -M versatilepb -cpu arm1176 -hda 2012-07-15-wheezy-raspbian.img -kernel kernel-qemu -m 192 -append "root=/dev/sda2"

Is there a way to alter this to either A) provide an expandable image so that I can provide more space for my RPi install or B) expand the current device size so that I can run raspi-config and expand the device that way.

ANSWER :

For linux, you can do it with gparted:

Create a loop device:

sudo losetup -f --show numar1.img

(numar1.img is your image file). It will return something like /dev/loop0.
Then run gparted with loop device:

sudo gparted /dev/loopX

(the X in loopX should be a number). Then resize the ext4 partition.

Leave a Reply

Your email address will not be published.