LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Installing legacy GRUB on micro SD memory card (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/installing-legacy-grub-on-micro-sd-memory-card-4175426089/)

soroush 09-07-2012 03:22 AM

Installing legacy GRUB on micro SD memory card
 
I'm trying to build a linux-based embedded OS using buildroot framework. After compilation I extracted contents of root filesystem on micro SD card. Now I need to install GRUB. I have stage 1 and stage 2 files. trying to write them on first sectors of /dev/sdb (using a memory reader) destroys partition table:

Code:

dd if=stage1 of=/dev/sdb bs=512 count=1
dd if=stage2 of=/dev/sdb bs=512 seek=1

Also installation on a partition (/dev/sdb1) causes damage on it.

How do I install GRUB?

theNbomr 09-07-2012 09:00 AM

stage2 & stage2 are files, which grub tries to read from a filesystem. You need to copy (cp) those files to a mounted filesystem on the flash drive. Using dd to write them to a partition makes the partition into something that is not a filesystem any more.
A pretty good recipe to solve your problem is at How to put Grub into floppy, pen drive, hard disk or CD/DVD.
--- rod.

soroush 09-07-2012 11:27 AM

Thanks for reply. I read your link. Unfortunately I donn't have legacy GRUB installed on my system, and the GRUB of embedded system is 0.97...

jefro 09-07-2012 02:47 PM

I'm just wondering. Why are you using grub? Can you consider lilo or any other boot loader?

soroush 09-07-2012 03:21 PM

Quote:

Originally Posted by jefro (Post 4775219)
I'm just wondering. Why are you using grub? Can you consider lilo or any other boot loader?

I'm using buildroot which supports U-Boot, syslinux, barebox and grub.

theNbomr 09-07-2012 04:37 PM

Quote:

Originally Posted by soroush (Post 4775110)
Thanks for reply. I read your link. Unfortunately I donn't have legacy GRUB installed on my system, and the GRUB of embedded system is 0.97...

You can load any version of grub onto your build host. It doesn't mean it will install a bootloader on the boot disk, or anywhere else. We all recognize grub as the bootlaoder that runs when your system boots, however it is really also a tool much like any other tool on your system. grub, the tool, is what you use to install grub, the bootloader, onto some media (your SD flash card). This is a concept that seems under-explained.

--- rod.

jefro 09-07-2012 08:56 PM

I think I'd be inclined to use Das U-Boot.

soroush 09-08-2012 02:18 AM

Quote:

Originally Posted by theNbomr (Post 4775275)
You can load any version of grub onto your build host. It doesn't mean it will install a bootloader on the boot disk, or anywhere else. We all recognize grub as the bootlaoder that runs when your system boots, however it is really also a tool much like any other tool on your system. grub, the tool, is what you use to install grub, the bootloader, onto some media (your SD flash card). This is a concept that seems under-explained.

--- rod.

Trying to install legacy grub on my system by Arch packages, causes a disaster. The geub package will install a bootloader on host machine, which is not what I want. So I compiled legacy grub on my system, and not installed it. Using interactive shell do the trick:

Code:

grub > device (hd0) /dev/sdb # My microSD card on memory reader
grub > root (hd0,0)
grub > setup (hd0)

Above code failed to install grub on microSD card. The error said no space left on device. Searching around I found that there is no boot sector (MBR) in my device. (BTW can't see how do distros install themselves without problem!) Fortunately there is a small tool for managing MBR on devices. I installed the 'install-mbr' package from AUR and
Code:

sudo install-mbr /dev/sdb
Then installed grub and no errors occured.

theNbomr 09-08-2012 07:29 AM

Quote:

Originally Posted by soroush (Post 4775466)
Trying to install legacy grub on my system by Arch packages, causes a disaster. The geub package will install a bootloader on host machine, which is not what I want. So I compiled legacy grub on my system, and not installed it. Using interactive shell do the trick:

Yeah, I was worried that might happen. I consider that to be a broken installer. Still, I should have suggested
that possibility up front. Glad you were able to work through it.
--- rod.


All times are GMT -5. The time now is 11:27 PM.