Using buildroot images (iso/ext2) in real target device (flash drive)
Hi,
I have created my system images (iso and ext2) and I would put one of them in the flash drive of the target system.
So far I've used unetbootin to create a bootable system which loaded in RAM, now the image is too big for my RAM.
Now I've used dd to put my image in the flash drive:
sudo dd if=rootfs.ext2 of=/dev/sdc1
Then when the machine starts I got the error:
Missing operating system
DISK BOOT FAILURE, PLEASE INSERT...
I "think" I've installed grub on my buildroot image
( package BR2_TARGET_GRUB [=y] ).
How can I test if grub is properly installed and how can I setup it? Thanks,
Signature · 1 line
Willy
Le Thu, 01 Mar 2012 17:06:44 +0100,
Willy <[email protected]> a ?crit :
Quoted 6 lines
I have created my system images (iso and ext2) and I would put one of them in the flash drive of the target system.
So far I've used unetbootin to create a bootable system which loaded in RAM, now the image is too big for my RAM.
Quoted 7 lines
Now I've used dd to put my image in the flash drive:
sudo dd if=rootfs.ext2 of=/dev/sdc1Then when the machine starts I got the error:
Missing operating system
DISK BOOT FAILURE, PLEASE INSERT...
Yes, you need a bootloader.
Quoted 3 lines
I "think" I've installed grub on my buildroot image
( packageBR2_TARGET_GRUB[=y] ).
How can I test if grub is properly installed and how can I setup it?
You need to run grub so that it installs itself on your /dev/sdc device. Something like:
printf "device (hd0) /dev/sdc\nroot (hd0,0)\nsetup (hd0)\nquit\n" | output/staging/sbin/grub --device-map=/dev/null --no-floppy
Let us know if that works. We should certainly extend the documentation with more details about this.
Best regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Quoted 7 lines · On Thursday 01 March 2012 16:59:21 Thomas Petazzoni wrote:
You need to run grub so that it installs itself on your
/dev/sdcdevice. Something like:printf "device (hd0) /dev/sdc\nroot (hd0,0)\nsetup (hd0)\nquit\n" | output/staging/sbin/grub --device-map=/dev/null --no-floppy
Let us know if that works. We should certainly extend the documentation with more details about this.
It probably won't work if your target is uclibc-based (unless your host
happens to be uclibc-based as well :-). You'd need a host-grub to get that right. I tried to do that half a year ago, but it wasn't so easy - unfortunately I don't remember why not. Could be a problem with 32/64 bit. Or with ccache.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286540 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
Quoted 7 lines · Arnout Vandecappelle
Quoted 4 lines · On Thursday 01 March 2012 16:59:21 Thomas Petazzoni wrote:
You need to run grub so that it installs itself on your
/dev/sdcdevice. Something like:printf "device (hd0) /dev/sdc\nroot (hd0,0)\nsetup (hd0)\nquit\n" |
output/staging/sbin/grub --device-map=/dev/null --no-floppy
Quoted 1 line
Quoted 9 lines
Quoted 2 lines
Let us know if that works. We should certainly extend the documentation with more details about this.
It probably won't work if your target is uclibc-based (unless your host
happens to be uclibc-based as well :-). You'd need a host-grub to get that right. I tried to do that half a year ago, but it wasn't so easy - unfortunately I don't remember why not. Could be a problem with 32/64 bit. Or with ccache.
What you could do is use qemu to get your bootloader installed. I typically use lilo for uclibc images, so I don't know the exact commands, but basically get the grub source code or binary on your image, then copy the kernel and initrd (if you have one) onto you host system, then start qemu using your flash drive as qemu's hard drive and use the -kernel and -append options on qemu. Then once it boots and you log in, just install grub as you would if you were installing it on your hard drive, since qemu will make it look like your flash drive is a hard drive.
the command to star qemu would look something like this:
qemu-system-x86_64 -kernel ./vmlinux -append "root=/dev/sda1" -hda /dev/sdc
make sure /dev/sdc* is NOT mounted anywhere else when you do this or else it could get corrupted pretty bad.
--PHil
I'm sending it to the mailing list this time :-P
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120304/ef9a9bec/attachment.html>
Le Fri, 2 Mar 2012 23:00:01 +0000,
Arnout Vandecappelle <[email protected]> a ?crit :
Quoted 2 lines
It probably won't work if your target is uclibc-based (unless your host
happens to be uclibc-based as well :-).
Correct. This code was taken from a project that was glibc-based.
Quoted 3 lines
You'd need a host-grub to get that right. I tried to do that half a year ago, but it wasn't so easy - unfortunately I don't remember why not. Could be a problem with 32/64 bit.
Or with ccache.
Yeah, I remember you posted some patches about this. Don't remember what the outcome was, though. Definitely something that would be nice to improve.
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Il 01/03/2012 17:06, Willy ha scritto:
Quoted 4 lines
I "think" I've installed grub on my buildroot image
( packageBR2_TARGET_GRUB[=y] ).
How can I test if grub is properly installed and how can I setup it? Thanks,
I've still that problem :-(
Here what I do:
1. make buildroot with grub selected and iso/etx2/tar image
2. create an ext2 partition (with boot flag) in my usb key with gparted
3. use dd to put the ext2 fs in my key: dd if=rootfs.ext2 of=/dev/sdc1 this put the fs in my key, but It say that only 11MB are avaiable, so I use gparted again to resize the partition and magically the dimension is correct!
4. put bzImage in the buildroot fs folder /boot
5. using qemu with -hda option to load buildroot and install grub in /dev/sdc1
When in grub (image booted with qemu) give the command setup (hd0) I got a segmentation fault.
Somewhere I found that there is a problem with a patch for grub (sorry, I don't remember exactly the name ...inode...ext2...) but I can't find this patch.
So I've downloaded grub sources and put them into my filesystem. Then I've compiled grub into qemu virtualization (modifying arguments for the ar command in Makefiles from cru to cr) and then I've installed grub on the device hd0.
I've created a menu.lst file manually:
#########################################
default 0
timeout 10
color light-green/brown blink-red/blue
title BuildRoot ISO9660 image
kernel /boot/bzImage root=/dev/hda1
#########################################
Now when I try to boot with this key usb, briefly read "Grub loading..." then there is a reboot.
Signature · 1 line
Willy
Il 24/04/2012 15:04, Willy ha scritto:
Quoted 1 line
I've still that problem :-(
I made some little steps.
I've installed grub on my usb flash using qemu:
"qemu -kernel bzimage -hda=/dev/sdc"
where sdc is my usb flash.
It tries to boot, but it stops.
I figured out that it tries to boot the bzImage on RAM (and it's larger than my memory).
So I've deleted the output/ folder, made some modifications and rebuilt all obtaining a smaller kernel and a smaller fs.
Now it boot, but always using the bzImage (I've only /boot/grub/* and bzImage on my flash usb). Every modifications does not survive to reboot.
So I've built the vmlinux image and tar fs, but I got "Grub Error 13: Invalid or unsupported executable format"
There is a way to use a vmlinux image and the fs directly on the flash drive?
Thanks
Signature · 1 line
Willy
Quoted 4 lines · On Friday 27 April 2012 16:23:20 Willy wrote:
So I've deleted the output/ folder, made some modifications and rebuilt all obtaining a smaller kernel and a smaller fs.
Now it boot, but always using the bzImage (I've only/boot/grub/*and bzImage on my flash usb).
So where did the rest of your rootfs.ext2 go?
Quoted 1 line
Every modifications does not survive to reboot.
Maybe you changed the rootfs to an initramfs?
Quoted 2 lines
So I've built the vmlinux image and tar fs, but I got "Grub Error 13: Invalid or unsupported executable format"
vmlinux is not executable by grub, and a tar file is not readable
by the kernel.
The proper approach is the following:
- Create a /boot/grub/menu.lst in your rootfs skeleton.
- Make sure you have the grub boot loader configured.
- Build kernel and rootfs.ext2. Make sure BR2_LINUX_KERNEL_INSTALL_TARGET is selected, so the kernel is inside the rootfs.ext2. If you want extra space in your rootfs to write files to it, set the BR2_TARGET_ROOTFS_EXT2_BLOCKS variable to the size of the root partition. Note, though, that genext2fs creates that whole size in memory, so you need to have enough RAM.
- Write rootfs.ext2 to the root partition: 'cat rootfs.ext2 > /dev/hdc1'
- Run 'grub --device-map=/dev/null --no-floppy' and give the following commands interactively:
device (hd0) /dev/hdc
root (hd0,0)
setup (hd0)
quit
This installs grub on /dev/hdc and makes it bootable.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286540 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F