...making Linux just a little more fun!
[ In reference to "Introduction to Shell Scripting, part 6" in LG#116 ]
Mr Dash Four [mr.dash.four at googlemail.com]
Hi Gang,
_* *_Found this list thanks to the excellent article of Ben Okopnik here <http://linuxgazette.net/116/okopnik1.html> - I was trying to create a floppy disk to help me boot-up an old PC (PII, 256MB RAM, 2xUSB + FDD), by transferring the control over to the USB drive (which can't be booted-up directly as the PC is too old). The USB contains slimmed-down version of FC8 containing propriety tools and programs. I wasn't successful, though this is not why I am writing this email (help with the floppy-usb boot-up is also appreciated though that may be a subject to a different email as Ben's article points out that I would need Knoppix Linux, but I have FC8 on the USB drive). Anyway...
After unsuccessfully trying to make the boot-up floppy, allowing me to boot-up the USB drive I tried to make a bare-bone boot-up floppy, containing just stage1 & stage 2 files to get me to the GRUB prompt (see 'What happened' below) with the intention of trying my luck from there and this is where I encountered my problem.
_*The problem:*_ I can't boot from my HDD - when I try I see the word "GRUB " on the screen and then nothing (this is not the GRUB prompt - it is just a message on the screen saying "GRUB " and then the system halts)!
I can access all my partitions - no problem (none of them appear damaged, same is valid for my partition table, thank god) using Boot/Rescue CD, which I made following the instructions shown in section 3.4 here <http://orgs.man.ac.uk/documentation/grub/grub_3.html>.
_*My system:*_
Fedora Core 8 with the latest updates, P4-M, 1GB RAM, 80GB HDD, split into the following partitions: hda1 - primary, WinXP, NTFS hda2 - extended hda5 - logical, data disk, NTFS hda6 - logical, RedHat 9, ext2 hda7 - logical, Fedora Core 8 /boot, ext2 hda8 - logical, Fedora Core 8 LVM volumes (5 of them mapped to /, /usr, /var, /home and /var/cache), lvm hda9 - logical, data backups, NTFS hda3 - primary, Service/Rescue DOS, FAT
GRUB used to be in my MBR as through its menu I used to boot all partitions successfully (up until now that is). One other thing I need to point out - as soon as the partitions were made I have created a copies of the boot sectors of all my partitions, plus the main MBR sector using these commands:
%dd if=/dev/hda of=hda-mbr-full bs=512 count=1 # mbr including partitions %dd if=/dev/hda of=hda-mbr-nopart bs=446 count=1 # no partition information, just the MBR %dd if=/dev/hdaX of=hdaX-bootsect bs=512 count=1 # boot record of a particular partition
where 'X' is the number of the partition. The files were saved on a separate usb device (memory stick) for safekeeping.
I should also point out that within FC8 Linux my HDD is mapped as /dev/sda (not /dev/hda).
_*W**hat happened*_ - From my PC while I was running my FC8 Linux I tried to create a bare-bone Linux floppy, which includes nothing but stage1 & 2 files. I thought I could do it with 'grub-install /dev/sdb' (sdb is how FC8 maps the floppy drive when I connect the usb floppy to the PC). I got an error, which said something like 'my drive is not listed/recognised by BIOS'. I didn't pay attention to it at the time as I had a plan B, i.e. to copy stage1 & 2 using 'dd' as described in section 3.1 here <http://orgs.man.ac.uk/documentation/grub/grub_3.html>. This was successful, although I could not unmount the floppy (device busy) and then I decided to reboot.
Here is where the nightmare began!!!
When shutting down I had a dozen error messages that my /, /usr and /home directories could NOT be unmounted (very strange - never had that before). When I rebooted the machine, expecting the GRUB menu to pop-up with all the usual options, but no - BANG! - the dreaded "GRUB " message! I was absolutely shocked!
The first thing for me to do was to check my MBR, the partition table and all boot sectors on all partitions as I suspected that something might have gone there. I booted up FC8 Live CD (from which the whole FC8 was installed on the PC in the first place) and then took a separate copy of these again using the 'dd' commands as above so that I could compare them to the previous copies I have got on my memory stick.
Here comes the weird bit - the new and the old files were *exactly the same* when I compared them with 'cmp -l <old_file> <new_file>' - there was no difference whatsoever!
Also, when I booted up FC8 Live CD - it automatically mapped all those partitions and I could see nothing wrong there (I specifically looked at my boot partition and all the usual files were there - the /grub/grub.conf, the initrd and vmlinuz files were all there!!!), which, in my view, it narrows it down to the MBR, which, if I have taken a copy of it correctly, is exactly the same as my old copy!
_*It gets worse*_ - to save time typing when I made my Boot/Rescue CD I copied the relevant sections from menu.lst & grub.conf files (see file contents below) from my /boot HDD partition into the /boot/grub directory on the Boot/Rescue CD before it was made. This, I thought would save me the time to type all this 'root (hd...)' and 'kernel' commands from the grub command-line...so I thought.
When I booted up from the newly made Boot/Rescue CD, the GRUB menu showed up with all the correct options (as id does when I normally boot from the hard disk) I selected one of the partitions to boot up to and pressed enter. To my surprise (yet again) I've got "Error 25 - Disk Read Error"!!! The contents of my grub.conf & menu.lst files is shown at the end of this email for reference.
Now, the bizarre thing is - when I press 'c' to go to the GRUB command-line and enter *exactly the same* command as it appears on the menu option listed and then type 'boot' and press return - all is well, no problem!
For example: my WinXP option in the GRUB menu.lst file shows:
rootnoverify (hd0,0) chainloader +1
When I select this option from GRUB menu and then press enter I get Error 25! When I press 'c' and type:
rootnoverify (hd0,0) chainloader +1 boot
from the GRUB command-line menu - no problem. I boot into my WinXP partion and all is well.
So, I ran out of options and don't know what may be wrong and what I have done wrong. I am tempted to run 'grub-install /dev/hda' while I boot to my FC8 partition, but don't know if this is going to mess things up even more - after the day I just had i am not at all inclined to go that route...
Help is desperately needed!!!
Regards,
George
===========grub.conf & menu.lst files content============== # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,6) # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 # initrd /initrd-version.img #boot=/dev/sda default=2 timeout=5 splashimage=(hd0,6)/grub/splash.xpm.gz hiddenmenu title Fedora (2.6.25.6-27.fc8) root (hd0,6) kernel /vmlinuz-2.6.25.6-27.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /initrd-2.6.25.6-27.fc8.img title Fedora (2.6.25.4-10.fc8) root (hd0,6) kernel /vmlinuz-2.6.25.4-10.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /initrd-2.6.25.4-10.fc8.img title Windows XP Professional rootnoverify (hd0,0) chainloader +1 title Rescue Service rootnoverify (hd0,3) chainloader +1 ===============================================
Ben Okopnik [ben at linuxgazette.net]
On Mon, Jun 30, 2008 at 01:06:25PM +0100, Mr Dash Four wrote:
> Hi Gang, > > _* > *_Found this list thanks to the excellent article of Ben Okopnik here > <http://linuxgazette.net/116/okopnik1.html> - I was trying to create a > floppy disk to help me boot-up an old PC (PII, 256MB RAM, 2xUSB + FDD), by > transferring the control over to the USB drive (which can't be booted-up > directly as the PC is too old). The USB contains slimmed-down version of > FC8 containing propriety tools and programs. I wasn't successful, though > this is not why I am writing this email (help with the floppy-usb boot-up > is also appreciated though that may be a subject to a different email as > Ben's article points out that I would need Knoppix Linux, but I have FC8 on > the USB drive).
This is pretty funny actually (not anything about your request, just the synchronicity of events) - we just had someone write in with a question about an article in issue 116 that was addressed in issue 132... and your question is about an article in issue 116, with the follow-up that answers your present question in issue 132. In fact, the two Talkbacks in 132 are right next to each other.
(I don't know that I want to dig into this any further; it would probably turn out that these guys have the same birthday, both married a girl named Philomena Maryann Carstairs-Smith, and both own a Pekingese-Schnauzer-Akita puppy that was born exactly three days, two hours, and seventeen minutes ago. The only difference will be that one of these people is composed of anti-matter... we just won't go there, and thus save the world from destruction.)
Anyway. The problem, as I mentioned in that Talkback (http://linuxgazette.net/132/lg_talkback.html#talkback.03), is that the Linux kernel is now too big to fit on a floppy - so the approach that I described in 116 is, sadly, dead. On the other hand, there are new and different ways of doing the same thing; several of them are mentioned at the link I've cited.
Good luck, let us know how it goes - and stay away from any anti-matter twins (ant-twins?) you may happen to meet!
-- * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
Ben Okopnik [ben at linuxgazette.net]
On Mon, Jun 30, 2008 at 01:06:25PM +0100, Mr Dash Four wrote:
> > Now, the bizarre thing is - when I press 'c' to go to the GRUB command-line > and enter *exactly the same* command as it appears on the menu option > listed and then type 'boot' and press return - all is well, no problem! > > For example: my WinXP option in the GRUB menu.lst file shows: > > rootnoverify (hd0,0) > chainloader +1 > > When I select this option from GRUB menu and then press enter I get Error > 25! When I press 'c' and type: > > rootnoverify (hd0,0) > chainloader +1 > boot > > from the GRUB command-line menu - no problem. I boot into my WinXP partion > and all is well.
That does sound pretty bizarre. The question is, do you want to find out what happened/why it's happening, or do you want to fix it? The former may take unspecified amounts of time, but you'll learn a bit about how GRUB and booting work. The latter will give you a working system.
> So, I ran out of options and don't know what may be wrong and what I have > done wrong. I am tempted to run 'grub-install /dev/hda' while I boot to my > FC8 partition, but don't know if this is going to mess things up even more > - after the day I just had i am not at all inclined to go that route...
Running it may well be the best option if you just want it fixed. I would back up the current '/boot/grub/menu.lst', and carefully check out the resulting one.
> ===========grub.conf & menu.lst files content============== > # grub.conf generated by anaconda > # > # Note that you do not have to rerun grub after making changes to this file > # NOTICE: You have a /boot partition. This means that > # all kernel and initrd paths are relative to /boot/, eg. > # root (hd0,6) > # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 > # initrd /initrd-version.img > #boot=/dev/sda > default=2 > timeout=5 > splashimage=(hd0,6)/grub/splash.xpm.gz > hiddenmenu > title Fedora (2.6.25.6-27.fc8) > root (hd0,6) > kernel /vmlinuz-2.6.25.6-27.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb > quiet
This is the problem with citing stuff instead of attaching it - no way for us to know whether that text is actually wrapped (which would be an error) or if it just shows that way in the email.
> initrd /initrd-2.6.25.6-27.fc8.img
Does this image actually exist?
> title Fedora (2.6.25.4-10.fc8) > root (hd0,6) > kernel /vmlinuz-2.6.25.4-10.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb
Does this kernel actually exist? How about the device? Does the latter exist before your auto-dev-creation daemons come on line?
In any case, try rebuilding your GRUB setup from scratch. Can't do any harm, as long as you have backups (and maybe a bootable CD on hand.)
-- * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
Ben Okopnik [ben at linuxgazette.net]
Hi -
Please don't drop TAG from the CC list; we all get "paid" for our time by contributing our technical expertise to the Linux community, and that can't happen in a private email exchange.
You can have one of those if you prefer - several of us are Linux consultants - but it wouldn't be free.
On Sat, Jul 05, 2008 at 05:09:37PM +0100, Mr Dash Four wrote:
> Ben wrote: > > > That does sound pretty bizarre. The question is, do you want to find out > > what happened/why it's happening, or do you want to fix it? The former > > may take unspecified amounts of time, but you'll learn a bit about how > > GRUB and booting work. The latter will give you a working system. > > Both! I am that kinda person.
[laugh] Frankly, so am I - "and" is the operative conjunction in my life.
> Here is my plan (funny enough I was about to start doing this in about 2 > hours and possibly spend the whole of tomorrow - Sunday - depending in > what kind of a mess I may end up in): > > 1. Backup my entire current /boot partition (it is about 52MiB). > 2. Restore a month-old backup of this /boot partition to a safe' location > (USB drive). As this backup is old apart from the new kernel version it > won't contain anything wrong with the partition and my first task will be > to compare the files, which may cause my partition not to boot (menu.lst > etc) as well as the boot sector. I would expect to see changes and will > ignore the ones caused by the kernel updates (like new versions of the > vmlinuz- file). > 3. If I find such changes between the 'old' backup and the new one, which > prevent me from booting up the new partition then I will reverse them and > see if I can boot up. > 4. If there are NO changes I could find (the least favourable option for > me as I will enter uncharted waters here!) then I would have no option, > but to run grub-install /dev/sda while within FC8 Live CD to restore GRUB > in the hope of getting GRUB to load. If I could then boot normally from > the hard disk then I would compare what has been done (both in terms of > files and the boot sector - bot on the /boot partition as well as the > absolute on /dev/sda) and see if I can find any differences. If not, well > ... it will remain a great mystery what really went wrong, sadly!
Sounds like a reasonable approach - and it shouldn't take too long, either. The only problem may be the stuff that gets compiled (at least I assume it does; that's the way LILO used to work, and I'm not an expert on GRUB) into the boot sector. Part of that was stuff like partition locations.
> In the worse-case scenario nothing will happen and I will be at square one > and will restore the /boot partition backup I have made in step 1.
In the worst-case scenario, you could always go with the "guaranteed to work" route: back up your data - at least all the user-generated bits - and restore it to a freshly-installed system. Rick Moen documented a good approach to doing that here in TAG in the recent past.
http://linuxgazette.net/151/misc/lg/talkback_108_okopnik.html
> > > title Fedora (2.6.25.4-10.fc8) > > > root (hd0,6) > > > kernel /vmlinuz-2.6.25.4-10.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb > > > > Does this kernel actually exist? How about the device? Does the latter > > exist before your auto-dev-creation daemons come on line? > > Don't know what you mean here, but (hd0) is my hard disk and as such > should be visible.
I meant the device specified as 'root' in your GRUB stanza - '/dev/VolGroup00/LogVol00'.
> Anyway, when I type this (at the grub> prompt) it > works, so I presume there is nothing wrong with it. Still don't understand > why grub is treating what I type (and which subsequently works!) > differently compared to when I press return after the option which > contains the same statements is selected?
That's precisely why I asked that question. This is somewhat unlikely, but - what would happen if that device 1) didn't normally exist and 2) was created by GRUB loading some device-creation module/daemon? It seems to me that you'd see exactly the kind of behavior that you're describing.
> P.S. I just noticed a few interesting things when looked at my boot sector > files with a BinHex viewer (Windows) - the boot sector of the /boot > partition is all zeroed (both in the old - working - and new/current - > non-working versions).
By "boot sector", I assume you mean /boot/grub/stage1, right? That is pretty odd.
> Also, in the boot CD the file I thought I copied as > /BOOT/GRUB/GRUB.CONF is saved as /BOOT/GRUB/GRUB.CON ('F' is missing).
I suspect that it has to do with the DOS 8+3 file naming scheme. Yep - we're still stuck with that, given that the whole mess with booting CDs still has those roots... In any case, there's usually some sort of a map file that keeps track of the actual file names.
> Both /BOOT/GRUB/GRUB.CON and /BOOT/GRUB/MENU.LST have the same content > (attached to this email). The only other files on that CD are > /BOOT/GRUB/STAGE2_E and /BOOT.CAT, nothing else.
I don't have anything like that close to hand at the moment, but that seems right for a bootable CD. I'm sure that someone will let me know if I'm wrong.
-- * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *