LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 09-07-2012, 03:22 AM   #1
soroush
LQ Newbie
 
Registered: Oct 2011
Posts: 13

Rep: Reputation: Disabled
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?
 
Old 09-07-2012, 09:00 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 09-07-2012, 11:27 AM   #3
soroush
LQ Newbie
 
Registered: Oct 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
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...
 
Old 09-07-2012, 02:47 PM   #4
jefro
Guru
 
Registered: Mar 2008
Posts: 11,013

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

Last edited by jefro; 09-07-2012 at 02:48 PM.
 
Old 09-07-2012, 03:21 PM   #5
soroush
LQ Newbie
 
Registered: Oct 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
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.
 
Old 09-07-2012, 04:37 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by soroush View Post
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.
 
Old 09-07-2012, 08:56 PM   #7
jefro
Guru
 
Registered: Mar 2008
Posts: 11,013

Rep: Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356
I think I'd be inclined to use Das U-Boot.
 
Old 09-08-2012, 02:18 AM   #8
soroush
LQ Newbie
 
Registered: Oct 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
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.
 
Old 09-08-2012, 07:29 AM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by soroush View Post
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.
 
  


Reply

Tags
embedded, grub, grubinstall


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't get 8-1 card reader to work {ID 058f:9360 Alcor Micro Corp. 8-in-1 Media Card } DBabo Linux - Software 28 12-06-2013 08:06 PM
[SOLVED] Will Grub legacy or Grub 1.9 find PCBSD? alfredo10 *BSD 2 08-01-2012 08:29 AM
How do I need to format grub entry to boot from grub2 into grub legacy? mitchell7man Linux - Software 6 04-03-2010 03:03 AM
GRUB (Legacy) Configuration uNiVerse555 Linux - Newbie 1 01-25-2007 10:19 AM
USB Micro memory salte Linux - Hardware 4 11-01-2006 03:35 AM


All times are GMT -5. The time now is 08:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration