df and fdisk conflict and grub therefore won't boot or run setup
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
df and fdisk conflict and grub therefore won't boot or run setup
So, I rebooted my Gentoo server (a PIII with 2 IDE HDDs) a couple of days ago only to find that the computer wouldn't boot. Instead, grub would get go to mounting stage 1 and then initially threw an error of the like "Error 6: Mismatched or corrupt version of stage1/stage2". I've been playing around with it and now it simply hangs on mounting stage 1.
Googling around made me suspect that the problem was caused by the fact that my root/boot/swap drive is the slave drive. Consequently, I also tried switching the master/slave config on the HDDs (wasn't a problem before, but maybe an update in grub made it an issue (seems like a long shot, but that's the best I could come up with)).
Anyway, I put in the livecd with the intention of simply reinstalling my grub.conf to the MBR. I did the standard mount my drives, chroot into my installation, and run grub. I tried:
root (hd0,0)
setup (hd0)
[now that I had my boot drive as the master (ie /dev/hda)]
Anyway, the root command works fine, but the setup command gives the Error 6 command again.
I then also attempted (after exiting the grub shell):
grub-install /dev/hda
and it tells me something like: Device /dev/sdb3 does not exist
I then ran df, mount, fdisk -l, and ls /dev. Results are as follows:
df: screwed up: a collection of sdx's and hdx's
mount: same as df
fdisk -l: as it should be: ie hda1, hda2, hda3, hda4, hdb1 exist (boot, swap, root, data1, data2 respectively)
ls /dev: same as fdisk
Another point of interest is that my drives used to be recognized as sdx's and now they seem to be recognized as hdx's (or maybe I'm just going crazy).
Also, I checked fstab and it had the sdx's (from the old config), so I tried modding that file to make it what it should be as well.
So, in summary, there are two problems:
-screwy mapping of my drives
-grub won't boot or setup the MBR
I'm assuming these problems are related since I didn't have either of them before (and to my knowledge all I've done is run standard periodic updates and reboot, so configuration shouldn't have changed since it was working last). But, I suppose they don't have to be related.
Did you run the grub-install command while you were still chrooted in your Gentoo partition? Another way to use that grub-install command to accomplish the same thing is to mount your Gentoo partition on say /mnt, and then do:
Where "hda" should be the drive where you want to install Grub to the MBR, and Grub will then point to whichever partition that was mounted on /mnt for its boot files. Let me know how that goes.
I will check the grub-install with your parameters and the fdisk -lu when I get back to my room.
Although, I must say, I haven't had success in the past (ie the last 36 hours) in general with the --recheck since it generally gives me "grub not found on block device" or something similar...nonetheless I'll check again when I get back and post my results.
I forgot to mention that probably the reason why the grub-install failed while you were chrooted is if you didn't mount /dev to the partition you chrooted into (you may also need to mount /proc, it doesn't hurt for completeness). In other words, if you have Gentoo mounted on say /mnt, you would need to do:
Code:
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
Prior to chrooting into /mnt. That's why you could get the error you got, namely "Device /dev/sdb3 does not exist", because /dev was not mounted. But since the grub-install command has the --root-directory option, there shouldn't be any need to set up a chroot environment and run grub-install from there; it's of course up to you though.
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
before chrooting in each time
I can try the different options that you suggested if you think that will make a difference (I've been using the above simply because that's what the Gentoo Install Guide suggested)
Hmmm... I'm a little suprised then why grub-install failed if you had those mounted before chrooting. If you want to try using that method again, then for completeness I would first mount all system related directories and see if that makes any difference:
Code:
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /tmp /mnt/tmp
I should mention that it may seem like mounting /tmp is superfluous, but actually it is critical whenever you try to run a GUI app from a chroot environment, so it couldn't hurt to mount it even if grub-install may not need it.
Also, when you chroot, I would run fdisk -l again to make sure you are using the correct hda vs sda drive notation, since you mentioned that seemed to be ambiguous before.
I went to /dev/mtab and found that there were a bunch of incorrect mounts there (ie with the sdx's). I deleted those and was able to get:
grub-install to run
going into grub shell and then running root and setup still gives the below error 6 though, so I'm not sure what's up with that.
Anyway, I now get back to the point where I get grub to run properly. However, some sort of error happens during the booting process. Unfortunately, I cannot read what the problem is since there is something wrong with the video output during the first section of the boot process (this was a problem before too, but wasn't a problem since the video issue resolved itself halfway through the boot process (presumably when it loaded a driver for the vid card)).
Anyway, if you have any thoughts, let me know. Otherwise, I guess this thread is closed based on the topic of the thread and I'll open up a new one once I get a better idea of what's going on.
It may be related to the error 6 problem, but I will need to find a way to read the text on the screen to be sure.
Definitely getting the Grub error 6 is not a good sign, and could very well be related to your current booting problem like you mention. How about completely purging the grub package, reinstall it, run the grub-install command again (that should rewrite the stage1/stage2 files to the grub directory with the new package files), and then run the "root" and "setup" commands just to see if they can complete without error. I've seen strange Grub problems like yours that can sometimes be solved by following those steps, and I think it would be worth trying in case that has anything at all to do with your current boot problem.
The error I was getting was that it wasn't a valid root device (ie /dev/hda3) For the heck of it, I tried /dev/sda3 and ta-da (ie when booting). So it seems that the LiveCD requires hdx and the computer sees sdx. So, now that I'm unsure of what's going on or how to fix it, I at least know what the problem is.
btw, it failed when checking the root filesystem since it obviously cannot open the hdxs (as all my files reference)
(btw, I fixed the old error by adding /dev/hda3 to my mtab and no more error 6).
If you have any ideas, let me know; otherwise, I'll just start googling around with this.
It sounds like what you are looking for is how Grub maps its drives in the device.map file in the Grub directory. If you have any references to /dev/sdX or /dev/hdX in your grub.conf file, then on start up Grub will look inside the device.map file to figure out which (hdX) corresponds to /dev/hdX or /dev/sdX. So if the computer worked with sdX, I'm guessing if you look in your device.map file you will see that all the drives are sdX and not hdX.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.