#487755 grub2 does not install on boot sector of the current (or a mounted) partition

Package:
grub2
Source:
grub2
Description:
GRand Unified Bootloader, version 2 (dummy package)
Submitter:
Holger Fischer
Date:
2023-05-04 16:27:04 UTC
Severity:
normal
#487755#5
Date:
2008-06-23 21:48:30 UTC
From:
To:
In my mbr I installed gag. It boots from my bootable partitions.
Therfore I install grub in the boot block of a partition I want to boot
from, I find this more "sorted". This worked fine for years.

I tried it with some prior version of grub2 (I think 1.96-200805xx) on
my root (like above sda6) as follows:

grub-install /dev/sda6

This does not work. After a lot of tries and some dangerous
grub-install /dev/sda6
grub-install /dev/sda7
dd if=/dev/sda7 of=/dev/sda6 bs=512 count=1
actions I got it to work, but this does not always work. I think that
work's because sda7 is not mounted at this moment. (There's a longer
story behind it with checking the difference of the first 512 bytes of
sda6 and sda7 with vbindiff and finding the right jumppoint to
core.img...., if you are interested let me know)

Now I try it always with sda7 by doing
mkdir /1
mount /dev/sda7 /1
grub-install --root-directory=/1 /dev/sda7
umount /1
rmdir /1

when I then do
kvm /dev/sda
(I know this is dangerous because sda6 is mounted as root and kvm does
not check it, but for only trying the bootloader on sda7 I won't destroy
anything on sda6)
the bootloader works flawless
when I reboot and try this from real hardware grub2 stops somewhere in
the beginning  with a short message.
When I do kvm /dev/sda after this reboot I get the same message like
from real hardware.
My thoughts:
I think the message I get after reboot is the message from my last
successfull grub2 dd if=.. installation, because the changes that should
have been written to the 1st 512 bytes of sda7 are not written back by
grub-install, they were only cached. This only occurs when the boot
block I want grub2 boot.img install on is actually mounted (I think some
tests I did proved this, the boot sector of the partition stayed the
same after a reboot like before grub-install). Maybe this information
helps you.

There's another thing related to this:
One advantage of grub1 (or grub-legacy) was that you could install it
somewhere and then create or change the grub.conf or menu.lst without
the need of reinstalling grub or a update-grub or grub-setup

With grub2 this does not work. When I change something in the grub.cfg I
must do a grub-setup or update-grub to "apply" changes. This means, the
grub.cfg is not really used when booting?
Did I do something wrong? Will this always be the behaviour of grub2?
(If yes, then grub2 is a big step back in the evolution of bootloader
software, it behaves like old lilo did and I don't need full size splash
images, I need easy-to-maintain software)

Best regards

Holger Fischer

Don't make Linux too much like Windows, because I don't like Windows but
I like Linux and other ?NIX

#487755#10
Date:
2008-06-24 06:32:05 UTC
From:
To:
With Version 1.96+20080617-1 grub-install ran through and worked in a
virtual machine directly after install, but not after a reboot anymore.

with version 1.96+20080621-1 I get this
:~$ mount /dev/sda7 /1
:~$ grub-install /dev/sda6
grub-setup: error: Cannot read `/boot/grub/core.img' correctly
:~$ grub-install --root-directory=/1 /dev/sda7
grub-setup: error: Cannot read `/boot/grub/core.img' correctly

:~# grub-setup -d /1/boot/grub -r '(hd0,7)' '(hd0,7)'
grub-setup: error: Cannot read `/boot/grub/core.img' correctly
:~# grub-setup  '(hd0,6)'
grub-setup: error: Cannot read `/boot/grub/core.img' correctly

Oh and (maybe again) some hardware info:
MB: Asus m2a-vm (sb600/amd690g)
RAM: 8gb ddr800
sata disk samsung 2,5" connected to sata port 4 on mainboard
filesytems mounted with uuid in fstab and grub.cfg

#487755#13
Date:
2008-06-25 20:56:14 UTC
From:
To:
Possibly caused by GRUB 2 core.img being bigger.  Anyway, mixing bootloader
code with your filesystem is dangerous and not recommended.

#487755#16
Date:
2008-06-25 20:57:22 UTC
From:
To:
This sounds a lot like filesystem corruption.  If you don't have backups,
I suggest you don't unmount this filesystem.  You might be unable to mount
it again.

#487755#23
Date:
2008-07-05 08:21:40 UTC
From:
To:
Hallo Robert,
thanks for your reply, sorry for answering so late, but there's
a lot to do at the moment.

The good news:

I did not screw up my filesystem (I must say, I never expected
problems, cause changing the 1st 512 Bytes - the boot sector of
a partition - does normally not cause any problems)

grub2 2 still works in sda6 - that means there should be no
problem installing grub2 in the boot sector of a partition
rather than in a mbr. (I got this by doing this "dangerous"
dd thing described above)

With grub(1) or grub_legacy installing grub to the boot sector
of a partition was never a problem.

Now back to the problems:

An apt-cache show grub2 gives me for
Version:  1.96+20080626-1

With this version I could not install grub2 to a partition boot
sector anymore.

So I downgraded (thanks to my /var/cache/apt) to 20080617 which
I reported to work.

Then the behaviour is as I described already:

$ sudo mount /dev/sda7 /1
$ sudo grub-install --root-directory=/1 /dev/sda7
Installation finished. No error reported.
This is the contents of the device map /1/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0)   /dev/sda
$

Then I can do a

$ sudo kvm /dev/sda.

I get a gag screen (see gag.png).

Pressing 2 for sda7 and pressing <down> <up> for stopping grub
timeout

I get the grub2 screen (see sda7.png)

Then I close kvm. (hard disk not touched, nothing destroyed,
nothing screwed up)

When rebooting and trying item 2 in gag menu I get a black
screen with "GRUB" in top left corner.

ctrl-alt-del + booting working item 1 (my sda6 with grub2)
in gag menu and starting after logging in

$ sudo kvm /dev/sda

choosing item 2 in gag screen, gives me the same screen like
real booting item2
(see sda7_after_reboot_same_as_real_boot.png)

One can say:
Oh yeah, starting kvm after grub-install screwed it up,
but I can do:

$ sudo mount /dev/sda7 /1
$ sudo grub-install --root-directory=/1 /dev/sda7
Installation finished. No error reported.
This is the contents of the device map /1/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0)   /dev/sda
$

and reboot immediately. Nothing changes.

That's why I wrote I think this is a kind of a caching problem.
In the running system all works fine, but changes are never
written back (as I wrote I checked this by comparing the boot
sectors of the partitions)

Now with Version from date 20080621 on I could not install
grub2 to the boot sector of a partition.
I get this error message which leads you to the assumption that
my filesystem is screwed up.

I think:
- Maybe this is a step forward, cause grub2 now checks, that
  it's not installed correctly (cause itnow  makes an ioctl() call)
  Now and we and grub2 install routine can check out
  that there's never something written back to the 1st 512
  Bytes of sda7.
- The only thing the grub2 developer or possibly you must do
  is checking why this is not written back correctly.

Best regards

Holger Fischer

#487755#28
Date:
2008-09-01 19:37:54 UTC
From:
To:
Hello Holger,

you're report just came by the way up on IRC.
How is is now with the current lenny version 1.96+20080724-9 and maybe
you could try the current experimental one 1.96+20080831-1 ?

In the report you only said grub-install /dev/sda6 and grub-setup "(hd0,6)"
but you can even use grub-install "(hd0,6)"

#487755#33
Date:
2008-10-15 06:37:00 UTC
From:
To:
Hi,

I tried grub-install "(hd0,6)" or better said  "(hd0,8)" because my hardware changed. It does exactly the same as described above. Isn't it only a mapping internally?

new hardware: asus m3a-h/hdmi (sb700/amd780g) with phenom 9350e
boot partition: sata disk connected with sata - ide adapter as primary master drive
root partition: md0 as raid0 from 8 sandisk ultra iv  with 8 cf-sata adapters (4 connected to  HighPoint Technologies, Inc. RocketRAID 230x 4 Port SATA-II Controller pcie)

Maybe I said it before: Can't this be a problem of a shared library grub2 uses to write  it's changes (so not a problem of grub2 itself)? - Only an idea.

Best regards

#487755#38
Date:
2008-10-17 15:23:32 UTC
From:
To:
Am Mittwoch, den 15.10.2008, 08:37 +0200 schrieb Holger Fischer:

Hello,

This is very weird, I can't reproduce this at all though I only tested
this with glibc 2.8 currently in experimental and with current debian
sid kernel and vanilla 2.6.27-git2.

grub-setup uses the low level API open()/write() with O_SYNC flag.

I looked over the manual of your mainboard to check if it has some sort
of bootsector proction which it seems it doestn't.

So I'm pretty clueless.
Maybe you could try with a livecd chrooted to your system if it happens
with it too?

#487755#43
Date:
2010-11-13 10:59:37 UTC
From:
To:
I’m a newbee
I use linux so now an then.
My system:
/dev/sda1 xp -1- primary
/dev/sda2 xp -2- primay
/dev/sda3 extended
there is no /dev/sda4
/dev/sda5 ntsf data
/dev/sda6 ntsf data
/dev/sda7 fat 32 data
/dev/sda8 swap
/dev/sda9 ext3 ment for squeze

For years I use osl2000 bootmanager. Just perfect for me.
OSL2000 hides the not active primary partitions. So xp -1- can’t see or
access xp -2- and the other way round. Just what I want.
On /dev/sda9 -/dev/hdc9- I installed lenny and grub. Worked great. Grub
was just for linux and came after osl2000.

Now I wanted to put squeeze on it. Problems began.
It is a pitty that the bootmanager is installed in the last steps. Just
after that you find out that the installation can’t be accessed an you
can start over again.
Missing operating system is the message.

My trials:
Over a rescue cd, I thought the command was:
sudo grub-install --force /dev/sda9
just warnings but no result.

A not clean install or clean install, grub legacy or grub2, no
difference: Missing operating system (4 times installing, costs a lot of
time)
Then installing lenny again. /dev/hdc9. Grub2 same problems: Missing
operating system. Grub legacy works immediately fine.
Even after upgrading
(http://www.go2linux.org/how-to-upgrade-from-debian-lenny-to-squeeze)
grub was changed in grub2. Grub2 and squeeze work both. But now there is
no network access anymore. Work to do.

So I think the installing of grub2 is not bug free. Installing Grub
under squeeze is also not bug free.
There are warnings if grub is not installed in mbr. I have not enough
knowledge, but if it works after upgrading, why it is not recommended?
If I remember good,there was also a warning it would make the system slower.
When? During booting or overall? In the first case, no problem. In the
second case. I didn’t notice. (After the upgrading)

My Question:
Is there a way to install squeeze and grub or grub2 correctly on hda9
without upgrading from lenny?

#487755#48
Date:
2012-12-29 16:30:13 UTC
From:
To:
Hello

Is there problem solved in the latest grub software? 1.99-24

#487755#53
Date:
2023-05-04 16:24:34 UTC
From:
To:
Hello there,

Is this still an on-going issue?  Given that the last entry was 2012,
I'm leaning towards no, and propose the ticket should be closed.

Best wishes

Emyr


On Sat, 29 Dec 2012 16:30:13 +0000 Martin Naughton  <blades2000@gmail.com> wrote:

 > Hello
 >
 > Is there problem solved in the latest grub software? 1.99-24
 >
 > --
 > Regards
 > Martin Naughton

#487755#56
Date:
2023-05-04 16:24:34 UTC
From:
To:
Hello there,

Is this still an on-going issue?  Given that the last entry was 2012,
I'm leaning towards no, and propose the ticket should be closed.

Best wishes

Emyr


On Sat, 29 Dec 2012 16:30:13 +0000 Martin Naughton  <blades2000@gmail.com> wrote:

 > Hello
 >
 > Is there problem solved in the latest grub software? 1.99-24
 >
 > --
 > Regards
 > Martin Naughton