mrdebug
Posts: 70
Joined: Sun Apr 07, 2013 6:08 pm

QEmu and raspbian, how to increase image size.

Tue Apr 30, 2013 9:11 am

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?
www. ???
www. ???
GMT+1
Skype: mrdebug

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5706
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Apr 30, 2013 11:02 am

Are you running qemu under windows or linux?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5706
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Apr 30, 2013 11:09 am

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.

mrdebug
Posts: 70
Joined: Sun Apr 07, 2013 6:08 pm

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

Tue Apr 30, 2013 12:42 pm

Perfect!
www. ???
www. ???
GMT+1
Skype: mrdebug

aramis
Posts: 2
Joined: Fri Aug 23, 2013 1:59 pm

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

Fri Aug 23, 2013 2:06 pm

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

mrdebug
Posts: 70
Joined: Sun Apr 07, 2013 6:08 pm

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

Fri Aug 23, 2013 5:06 pm

After that have you run "sudo raspi-config"?
www. ???
www. ???
GMT+1
Skype: mrdebug

aramis
Posts: 2
Joined: Fri Aug 23, 2013 1:59 pm

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

Mon Aug 26, 2013 8:01 am

mrdebug wrote:After that have you run "sudo raspi-config"?
Yes after sudo raspi-config.

mrdebug
Posts: 70
Joined: Sun Apr 07, 2013 6:08 pm

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

Mon Aug 26, 2013 9:56 am

And have you run "increase file system" or something like this?
www. ???
www. ???
GMT+1
Skype: mrdebug

User avatar
jojopi
Posts: 3074
Joined: Tue Oct 11, 2011 8:38 pm

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

Mon Aug 26, 2013 10:06 am

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

d3fman
Posts: 8
Joined: Sun Feb 16, 2014 7:06 pm

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

Sun Mar 16, 2014 2:57 pm

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

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5706
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Sun Mar 16, 2014 3:45 pm

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"

ejolson
Posts: 3019
Joined: Tue Mar 18, 2014 11:47 am

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

Tue Mar 18, 2014 11:57 am

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.

guy_BXL
Posts: 1
Joined: Sat Jan 30, 2016 9:09 pm

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

Sat Jan 30, 2016 10:06 pm

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

tofutim
Posts: 1
Joined: Tue Feb 20, 2018 7:27 pm

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

Tue Feb 20, 2018 7:33 pm

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.

alenteria
Posts: 1
Joined: Fri Jul 27, 2018 4:15 pm

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

Fri Jul 27, 2018 4:35 pm

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

Return to “General discussion”