Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:

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?

share|improve this question
    
Assuming 512-bytes sectors, you are writing to both the first and the second sector. I have never seen the need to use dd on anything else than the first sector (the MBR). A partition could start at the second sector, so you may damage it. –  Francesco Turco Sep 13 '12 at 10:24
add comment

1 Answer

You're directly overwriting the boot sector / partition table with the stage1 and stage2 files, when you use dd like that. Instead, you should use grub-install (or the lower-level grub-mkimage and grub-setup commands, as mentioned in that link).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.