Skip to contentSkip to conversation

Creating a filesystem for QEMU

Buildroot Bogdan Cristea 4 participants 14 messages Nov 12, 2009 – Nov 13, 2009 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

I am trying to use QEMU for development of embedded systems using Real
Time Linux. Buildroot seems to be the tool I need, but I still don't know how to build a disk image recognized by QEMU. Right now I am trying to use only x86 and x86_64 architectures.
Does anyone know how to build a file system usable in QEMU ?

#1 lore raw

Hi Bogdan,

You have a lot of option :

- You can generate a cloop root filesystem using buildroot, and then convert it to the format you want using qemu-img
- Create an initramfs, and boot it using qemu
- Create an ext2 filesystem and write it on a qemu disk through an install cdrom
- and so on....

Regards,

--
Lionel

Quoted 11 lines · Bogdan Cristea

I am trying to use QEMU for development of embedded systems using Real
Time Linux. Buildroot seems to be the tool I need, but I still don't know how
to build a disk image recognized by QEMU. Right now I am trying to use only x86 and x86_64 architectures.
Does anyone know how to build a file system usable in QEMU ?
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20091112/bbb95787/attachment.htm>

#2 lore raw
Quoted 7 lines · On Thursday 12 November 2009 16:58:15 you wrote:

- You can generate a cloop root filesystem using buildroot, and then convert it to the format you want using qemu-img
- Create an initramfs, and boot it using qemu
- Create an ext2 filesystem and write it on a qemu disk through an install cdrom
- and so on....

Thank you for your feedback, I'll try to explore these options in the next
days. IMHO it could be extremely useful to have these indications into the help page of buildroot.
Could you expand a little more the last option (Create an ext2 filesystem
and write it on a qemu disk through an install cdrom). I don't understand that part.

thanks
Bogdan

#3 lore raw

Once your have created an ext2 filesystem you can boot a debian cdrom image (for example), edit partitions from the debian rescue console and write the ext2 filesystem using dd.
Then mount the filesystem and run some grub-install to get the bootloader installed.
Or just boot with a vmlinux using the -kernel qemu option (if I remember correctly).

Regards,

Quoted 17 lines · Bogdan Cristea
Quoted 7 lines · On Thursday 12 November 2009 16:58:15 you wrote:

- You can generate a cloop root filesystem using buildroot, and then convert it to the format you want using qemu-img
- Create an initramfs, and boot it using qemu
- Create an ext2 filesystem and write it on a qemu disk through an install cdrom
- and so on....

Thank you for your feedback, I'll try to explore these options in the
next
days. IMHO it could be extremely useful to have these indications into the help page of buildroot.
Could you expand a little more the last option (Create an ext2 filesystem
and write it on a qemu disk through an install cdrom). I don't understand that
part.

Quoted 3 lines

thanks
Bogdan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20091112/0123f1c1/attachment.htm>

#4 lore raw
In reply to Bogdan Cristea
Quoted 6 lines · Bogdan Cristea

Thank you for your feedback, I'll try to explore these options in the next
days. IMHO it could be extremely useful to have these indications into the help page of buildroot.
Could you expand a little more the last option (Create an ext2 filesystem
and write it on a qemu disk through an install cdrom). I don't understand that part.

It's also possible to loop mount a qemu image if you do not use -f qcow...

Quoted 2 lines

qemu-img create qemu.img 4G
mount -o loop,offset=32256 qemu.img /mnt

then, for instance, if you created a tarball from Buildroot then you should be able to extract the tarball to a temp directory and rsync -av /temp/ /mnt

I haven't tried this but it might work.

--markc

#5 lore raw
In reply to Bogdan Cristea
Quoted 10 lines · Bogdan Cristea

? ?I am trying to use QEMU for development of embedded systems using Real Time Linux. Buildroot seems to be the tool I need, but I still don't know how to build a disk image recognized by QEMU. Right now I am trying to use only x86 and x86_64 architectures.
? ?Does anyone know how to build a file system usable in QEMU ?
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

I've just started doing the same thing myself. After a bit of googling the trick I found was to ask buildroot to generate a cpio target file system. Start with the i386_defconfig or i686_defconfig and set BR2_TARGET_ROOTFS_CPIO=y (or use "make menuconfig" an find the cpio option under the "Target file system" menu)

Making use of qemus ability to replace the bootloader you can invoke qemu with

   qemu -kernel output/images/bzImage \
        -initrd output/images/rootfs.i686.cpio

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 11 lines · On Thursday 12 November 2009 16:46:32 you wrote:

I've just started doing the same thing myself. After a bit of googling the trick I found was to ask buildroot to generate a cpio target file system. Start with the i386_defconfig or i686_defconfig and set BR2_TARGET_ROOTFS_CPIO=y (or use "make menuconfig" an find the cpio option under the "Target file system" menu)

Making use of qemus ability to replace the bootloader you can invoke qemu with

    qemu -kernel output/images/bzImage \
         -initrd output/images/rootfs.i686.cpio

I have tried this approach, but it does not seem to work. First
inconvenient is that rootfs.i686.cpio file is very large (600 MB) and when using the above command I only get a black screen from QEMU while the entire computer seems to be slower.
Lionel, suggested other approaches but till now I have no luck. Trying to
obtain first a cloop root filesystem and then convert that to a QEMU format seem to work and the file size is small (3 MB), but still when using that disk image, QEMU is not able to recognize any root partition.
If you have any other suggestion it would be helpful.

#8 lore raw
Quoted 7 lines · Bogdan Cristea
Quoted 6 lines · On Thursday 12 November 2009 16:46:32 you wrote:

I've just started doing the same thing myself. After a bit of googling the trick I found was to ask buildroot to generate a cpio target file system. Start with the i386_defconfig or i686_defconfig and set BR2_TARGET_ROOTFS_CPIO=y (or use "make menuconfig" an find the cpio option under the "Target file system" menu)

Quoted 5 lines
Quoted 4 lines

Making use of qemus ability to replace the bootloader you can invoke qemu with

    qemu -kernel output/images/bzImage \
         -initrd output/images/rootfs.i686.cpio

Shouldn't be the cpio image gunzipped ? :

$ file /boot/initrd.img-2.6.30-2-686
/boot/initrd.img-2.6.30-2-686: gzip compressed data, from Unix, last
modified: Fri Nov 13 09:08:02 2009
$ gunzip -c /boot/initrd.img-2.6.30-2-686 > test
$ file test
test: ASCII cpio archive (SVR4 with no CRC)
Quoted 18 lines
Quoted 1 line

I have tried this approach, but it does not seem to work. First
inconvenient is that rootfs.i686.cpio file is very large (600 MB) and when using the above command I only get a black screen from QEMU while the entire
computer seems to be slower.
Lionel, suggested other approaches but till now I have no luck. Trying
to
obtain first a cloop root filesystem and then convert that to a QEMU format seem to work and the file size is small (3 MB), but still when using that disk
image, QEMU is not able to recognize any root partition.
If you have any other suggestion it would be helpful.
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20091113/44a0bbd1/attachment.htm>

#9 lore raw
Quoted 11 lines · Lionel Landwerlin
Quoted 7 lines · Bogdan Cristea
Quoted 6 lines · On Thursday 12 November 2009 16:46:32 you wrote:

I've just started doing the same thing myself. After a bit of googling the trick I found was to ask buildroot to generate a cpio target file system. Start with the i386_defconfig or i686_defconfig and set BR2_TARGET_ROOTFS_CPIO=y (or use "make menuconfig" an find the cpio option under the "Target file system" menu)

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

Making use of qemus ability to replace the bootloader you can invoke qemu with

    qemu -kernel output/images/bzImage \
         -initrd output/images/rootfs.i686.cpio

Shouldn't be the cpio image gunzipped ? :

I mean gzipped of course...

Quoted 31 lines
$ file /boot/initrd.img-2.6.30-2-686
/boot/initrd.img-2.6.30-2-686: gzip compressed data, from Unix, last
modified: Fri Nov 13 09:08:02 2009
$ gunzip -c /boot/initrd.img-2.6.30-2-686 > test
$ file test
test: ASCII cpio archive (SVR4 with no CRC)
Quoted 19 lines
Quoted 1 line

I have tried this approach, but it does not seem to work. First
inconvenient is that rootfs.i686.cpio file is very large (600 MB) and when using the above command I only get a black screen from QEMU while the entire
computer seems to be slower.
Lionel, suggested other approaches but till now I have no luck. Trying
to
obtain first a cloop root filesystem and then convert that to a QEMU format
seem to work and the file size is small (3 MB), but still when using that disk
image, QEMU is not able to recognize any root partition.
If you have any other suggestion it would be helpful.
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20091113/600e9bb1/attachment.htm>

#10 lore raw
Quoted 8 lines · Lionel Landwerlin
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Making use of qemus ability to replace the bootloader you can invoke qemu with
? ? qemu -kernel output/images/bzImage \
? ? ? ? ?-initrd output/images/rootfs.i686.cpio

Shouldn't be the cpio image gunzipped ? :

I mean gzipped of course...

Unzipped works for me. The cpio target makes 2 files. rootfs.ARCH.cpio and rootfs.ARCH.cpio.gz.
I just tried the .gz file and that works too.

#11 lore raw
Quoted 7 lines · Chris Packham
Quoted 5 lines · Lionel Landwerlin
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

Making use of qemus ability to replace the bootloader you can invoke qemu with

    qemu -kernel output/images/bzImage \
         -initrd output/images/rootfs.i686.cpio
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Shouldn't be the cpio image gunzipped ? :

I mean gzipped of course...

Unzipped works for me. The cpio target makes 2 files. rootfs.ARCH.cpio and rootfs.ARCH.cpio.gz.
I just tried the .gz file and that works too.

In fact the 600Mb cpio archive is probably the problem ;) Maybe the Qemu hardware configuation hasn't enough ram.

Bogdan: You should probably avoid building things like WebKit at least in
initrd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20091113/3cd96b81/attachment-0001.htm>

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw
Quoted 29 lines · On Friday 13 November 2009 15:59:46 you wrote:
Quoted 12 lines · Bogdan Cristea
Quoted 10 lines · On Thursday 12 November 2009 16:46:32 you wrote:

I've just started doing the same thing myself. After a bit of googling the trick I found was to ask buildroot to generate a cpio target file system. Start with the i386_defconfig or i686_defconfig and set BR2_TARGET_ROOTFS_CPIO=y (or use "make menuconfig" an find the cpio option under the "Target file system" menu)

Making use of qemus ability to replace the bootloader you can invoke qemu with

    qemu -kernel output/images/bzImage \
         -initrd output/images/rootfs.i686.cpio
Quoted 9 lines

I have tried this approach, but it does not seem to work. First
inconvenient is that rootfs.i686.cpio file is very large (600 MB) and when using the above command I only get a black screen from QEMU while the entire computer seems to be slower.
Lionel, suggested other approaches but till now I have no luck. Trying
to obtain first a cloop root filesystem and then convert that to a QEMU format seem to work and the file size is small (3 MB), but still when using that disk image, QEMU is not able to recognize any root partition.
If you have any other suggestion it would be helpful.

I'd double check your configuration. I must admit I started hacking away without looking at the i686_defconfig. But I've got a rootfs thats only 3M and a kernel thats just under 4M. I've attached my buildroot config (.config) and kernel config (i386_defconfig) for your reference.

Quoted 5 lines

Also when you are hacking away re-configuring buildroot doesn't know to remove something up if you've de-selected it so you may need to manually clean out output/target/ manually (or start from fresh each time).

when using your .config file my compilation fails due to a missing patch file mpfr-2.4.1.patch. What is the role of that patch ?

#14 lore raw
Quoted 4 lines · Bogdan Cristea

when using your .config file my compilation fails due to a missing patch file mpfr-2.4.1.patch. What is the role of that patch ?

mpfr is used when generating gcc with floating point support. Its not something I've added locally.

My buildroot repository is based off the commit id 5e5f3209f which has got numerous changes since the 2009.08 release (including some in mpfr). If you do want to persue using my config you may want to get fresh git clone and seek to the same point as me. i.e.

git clone http://git.buildroot.net/buildroot
cd buildroot
git checkout -b test 5e5f3209f

Failing that maybe you just want to compare your config to mine and see if you have a bunch of extra packages that are causing your target file system to be so big.

#15 lore raw
Quoted 12 lines · On Friday 13 November 2009 17:14:59 you wrote:
Quoted 2 lines · Bogdan Cristea

when using your .config file my compilation fails due to a missing patch file mpfr-2.4.1.patch. What is the role of that patch ?

mpfr is used when generating gcc with floating point support. Its not something I've added locally.

My buildroot repository is based off the commit id 5e5f3209f which has got numerous changes since the 2009.08 release (including some in mpfr). If you do want to persue using my config you may want to get fresh git clone and seek to the same point as me. i.e.

Quoted 8 lines

git clone http://git.buildroot.net/buildroot
cd buildroot
git checkout -b test 5e5f3209f

Failing that maybe you just want to compare your config to mine and see if you have a bunch of extra packages that are causing your target file system to be so big.

Thank you Chris, finally I have managed to boot a linux image in QEMU. The problem seems to be the version of buidroot I have used: 2009.08