On 2012-04-01 10:46, Yarny wrote:
> I just tried that and it works nice. I used an empty internal disk
> instead of an usb stick, but it shouldn’t make a difference.
> I guess your usb stick is /dev/sdb and the /boot partition on it is
> /dev/sdb1, and is mounted in /media/something.
>
> Code:
> --------------------
>
> # Remove old device.map
> $ rm /media/something/boot/grub/device.map
> # Write new device.map
> $ grub --device-map=/media/something/boot/grub/device.map <<< quit
>
> --------------------
>
> Look into /media/something/boot/grub/device.map. It should point (hd1)
> to your usb-stick /dev/sdb.
Done.
That’s the starting trick, the device map.
> Put some test file on your usb-stick’s
> /boot, like “touch /media/something/boot/my_mark_file”.
Ah, good trick! Let me see…
> Call grub
> again, with “grub --device-map=/media/something/boot/grub/device.map”,
> try again “root (hd1,0)” and verify that you’re on the correct partition
> with “find /boot/my_mark_file”. It should respond “(hd1,0)”.
Right, it does work:
grub> root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
grub> find /boot/mark
Error 15: File not found
grub> find /boot/grub/mark
(hd1,0)
grub>
Good.
If it
doesn’t, you somehow ended up on a wrong device, maybe your machine’s
/boot. If it does, you’re on your way.
Code:
setup --stage2=/boot/grub/stage2 --force-lba (hd1,0)
setup --stage2=/boot/grub/stage2 --force-lba (hd1)
grub> setup --stage2=/boot/grub/stage2 --force-lba (hd1,0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1,0)"... failed (this is not fatal)
Running "embed /boot/grub/e2fs_stage1_5 (hd1,0)"... failed (this is not fatal)
Running "install --force-lba --stage2=/boot/grub/stage2 /boot/grub/stage1
(hd1,0) /boot/grub/stage2 p /boot/
grub/menu.lst "... succeeded
Done.
grub> setup --stage2=/boot/grub/stage2 --force-lba (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded.
succeeded
Running "install --force-lba --stage2=/boot/grub/stage2 /boot/grub/stage1
(hd1) (hd1)1+17 p (hd1,0)/boot/gru
b/stage2 /boot/grub/menu.lst"... succeeded
Done.
grub>
Looks good.
>
> From here on, I didn’t test any further.
Lets see if it boots.
…]
No… I press F9 to change the boot order, I choose the USB stick, the
screen blanks for a moment, and then I get the bios boot screen again. If I
try a second time, I get a grub crash, dunno if from the stick or the HD.
In fact, I powered off, booted and failed, the HD boot is broken now
…]
Booting from a rescue CD I see that /etc/grub.conf was modified, probably
by yast on a previous attempt.
Mmm… I used the same procedure as above to rebuild the laptop device.map,
and hd0 is fd0, which does not exist! It doesn’t see sda!
Broken grub
Well, I have a full backup of the /boot partition. I’ll make a backup of
the current files, dd the image backup, and then replace the files. Should
be enough.
…]
Failed! I don’t understand… Maybe mc doesn’t work right in a chroot. Copy
failed?
Ok, backup image restored. Now grub stops at a different point. I only see
“GRUB” on the top left.
Trying to restore files… No good.
Trying again. Perhaps the MBR was also modified - no.
It appears my grub is totally destroyed
…]
Ah!
I know why I can’t restore from backup. I’m restoring the boot partition,
sda6, but I also need to restore sda4, the extended partition, which is
where grub resides - and I don’t have a backup of this one. Oh, yes, I do!
But it might not work, it is only 512 bytes… will it have stage 1.5?
Bingo! It boots! Pffff!
Reinstalling grub properly… {setup --stage2=/boot/grub/stage2 --force-lba
(hd0,3) (hd0,5)}
booting… no, it crashes loading stage2. I wonder why… restoring grub as
previously, from rescue system. sda4… not enough, it stops at loading
stage2. I have to restore sda6 from image backup.
Fails again… WHY!!! It worked before!
Reinstalling for the Nth time from backup, rebooting… now I get the boot
prompt, no menu!
Doing it again, same error! :-/
Typing the entries manually… booting!
I HATE GRUB!
I’ll have to tell Yast to reinstall grub. I hope it will do it right…
No… it did not. I’m back to the"GRUB loading stage 2" prompt and nothing
more.
WHYY!
–
Cheers / Saludos,
Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)