Page 1 of 1

QEmu and raspbian, how to increase image size.

Posted: Tue Apr 30, 2013 9:11 am
by mrdebug
Raspbian under QEmu has only 200 Mb free disk space.
In order to enlarge the image I run
qemu-img resize arm-softmmu/Raspberry/2013-02-09-wheezy-raspbian.img +2G
but the free space is still 200 Mb more less.
What have I do for enlarge the file system?

Re: QEmu and raspbian, how to increase image size.

Posted: Tue Apr 30, 2013 11:02 am
by ShiftPlusOne
Are you running qemu under windows or linux?

Re: QEmu and raspbian, how to increase image size.

Posted: Tue Apr 30, 2013 11:09 am
by ShiftPlusOne
Actually, doesn't matter too much.

After doing the resize, boot it up
Create this file (in raspbian): /etc/udev/rules.d/90-qemu.rules
Put this in the file:

Code: Select all

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",

Now reboot qemu, and you should be able to run 'sudo raspi-config' and select the expand fs option to fix everything up.

Re: QEmu and raspbian, how to increase image size.

Posted: Tue Apr 30, 2013 12:42 pm
by mrdebug
Perfect!

Re: QEmu and raspbian, how to increase image size.

Posted: Fri Aug 23, 2013 2:06 pm
by aramis
Hi at all,

I emulate raspbian under WIN XP.

In order to enlarge the image I run
qemu-img resize 2012-07-15-wheezy-raspbian.img +2G

but the free space is still 200 Mb more less.
What have I do for enlarge the file system?

I have done what ShiftPlusOne posted
(Create this file (in raspbian): /etc/udev/rules.d/90-qemu.rules
But this in:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",
reboot, sudo raspi-config, and select the expand fs option )

I'm getting always /dev/root/ is not an SD card. Don't know how to expand

Who can help me?

Sorry for my bad english

regards
aramis

Re: QEmu and raspbian, how to increase image size.

Posted: Fri Aug 23, 2013 5:06 pm
by mrdebug
After that have you run "sudo raspi-config"?

Re: QEmu and raspbian, how to increase image size.

Posted: Mon Aug 26, 2013 8:01 am
by aramis
mrdebug wrote:After that have you run "sudo raspi-config"?
Yes after sudo raspi-config.

Re: QEmu and raspbian, how to increase image size.

Posted: Mon Aug 26, 2013 9:56 am
by mrdebug
And have you run "increase file system" or something like this?

Re: QEmu and raspbian, how to increase image size.

Posted: Mon Aug 26, 2013 10:06 am
by jojopi
aramis wrote:I'm getting always /dev/root/ is not an SD card. Don't know how to expand
raspi-config checks that /dev/root is a symlink to mmcblk0p2.

The suggested udev rules make mmcblk0 point to sda, so that the correct device is resized, but I do not see how they affect /dev/root to get around the initial check.

You may also need:

Code: Select all

sudo ln -snf mmcblk0p2 /dev/root
sudo raspi-config

Re: QEmu and raspbian, how to increase image size.

Posted: Sun Mar 16, 2014 2:57 pm
by d3fman
mrdebug wrote:Raspbian under QEmu has only 200 Mb free disk space.
In order to enlarge the image I run
qemu-img resize arm-softmmu/Raspberry/2013-02-09-wheezy-raspbian.img +2G
but the free space is still 200 Mb more less.
What have I do for enlarge the file system?
Hi,
Can you tell me where do you put this command ?
Thanks

Re: QEmu and raspbian, how to increase image size.

Posted: Sun Mar 16, 2014 3:45 pm
by ShiftPlusOne
d3fman wrote:
mrdebug wrote:Raspbian under QEmu has only 200 Mb free disk space.
In order to enlarge the image I run
qemu-img resize arm-softmmu/Raspberry/2013-02-09-wheezy-raspbian.img +2G
but the free space is still 200 Mb more less.
What have I do for enlarge the file system?
Hi,
Can you tell me where do you put this command ?
Thanks
Command prompt of a terminal shell, depending on your OS. If it's windows, make sure qemu-img.exe is present.
aramis wrote:Hi at all,

I emulate raspbian under WIN XP.

In order to enlarge the image I run
qemu-img resize 2012-07-15-wheezy-raspbian.img +2G

but the free space is still 200 Mb more less.
What have I do for enlarge the file system?

I have done what ShiftPlusOne posted
(Create this file (in raspbian): /etc/udev/rules.d/90-qemu.rules
But this in:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",
reboot, sudo raspi-config, and select the expand fs option )

I'm getting always /dev/root/ is not an SD card. Don't know how to expand

Who can help me?

Sorry for my bad english

regards
aramis
Sorry, since I wrote my post raspi-config has changed and it doesn't work that way any more.

The udev rules should now be:

Code: Select all

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"

Re: QEmu and raspbian, how to increase image size.

Posted: Tue Mar 18, 2014 11:57 am
by ejolson
As raspi-config also reports for my setup "not a flash card" the following worked.

First add the file /etc/udev/rules.d/90-qemu.rules with the recommended contents
in the raspian image. Quit the qemu emulator.

On the host system:

$ qemu-img resize 2014-01-07-wheezy-raspbian.img +2G

Boot raspian in qemu and within raspian

$ fdisk /dev/sda

delete partition 2 remembering its start address 122880
add new partition 2 with start 122880 and maximum end allowed

$ resize2fs

Then reboot.

Re: QEmu and raspbian, how to increase image size.

Posted: Sat Jan 30, 2016 10:06 pm
by guy_BXL
Hi,
for me it works in the following steps
change size of img file
start qemu
delete partion 2
create partition 2
reboot
resize
===>> ok


in win7
1/ in a dos box in win7 in the dir containing both qemu-img.exe and the img file
qemu-img.exe resize 2012-07-15-wheezy-raspian.img +3G
2/ start the run.bat in the good directory in win7
in raspian
3/ sudo fdisk -l you have the list of normally 2 partitions, second beginning 122880
4/ sudo fdisk /dev/sda
in fdisk
5/ d to delete a partiton
6/ 2 the second
the 2nd partition is now deleted
7/ n create partition
8/ accept default primary, second partition but entry the good beginning address
122880
9/ if doing mistake quit without saving change with q
otherwize w will write the new table to disk
in raspian
10/ sudo reboot
11/ sudo resize2fs /dev/sda2
verify with df diskfree command

after you will have place to do
sudo apt-get update
sudo apt-get upgrade

Re: QEmu and raspbian, how to increase image size.

Posted: Tue Feb 20, 2018 7:33 pm
by tofutim
I just wanted to share on my end that I was facing the same issues. If I use raspi-config, I get sda2 is not an SD card. If I use resize2fs, I get open: no such file or directory while opening /dev/root.

It finally worked with the addition of /etc/udev/rules.d/90-qemu.rules

Code: Select all

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",
AND

Code: Select all

sudo ln -snf mmcblk0p2 /dev/root
What a royal pain. Thank you jojopi, you saved my day.

This is in QEMU (emulation) on OSX. Probably it would have all been fixed had I mounted /dev/mmcblk0 instead of /dev/sda.

Re: QEmu and raspbian, how to increase image size.

Posted: Fri Jul 27, 2018 4:35 pm
by alenteria
Here's what really works for me everytime, this is for linux:

qemu-img resize 2018-06-27-raspbian-stretch-lite.img 8G
fdisk 2018-06-27-raspbian-stretch-lite.img

In the fdisk console, input p to print the details, see ff:

Device Boot Start End Sectors Size Id Type
2018-06-27-raspbian-stretch-lite.img1 8192 96663 88472 43.2M c W95 FA
2018-06-27-raspbian-stretch-lite.img2 98304 3637247 3538944 1.7G 83 Linux

Input d to delete the existing partition, and select 2 for the partition number to delete.
Create new partition by inputting n
Select p for primary and 2 for the partition number to use
Input the start sector shown in the details from the first command p
Press enter to use default for end sector
Then input w to write the changes
Boot raspbian img and see the size change applied
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.9G 1.1G 6.5G 14% /
devtmpfs 124M 0 124M 0% /dev
tmpfs 124M 0 124M 0% /dev/shm
tmpfs 124M 1.9M 123M 2% /run