Vulnerability of Boot Loader

Asked by John Cobb

Ok so I did something stupid: I had this other disk and I wanted to install 8.10 on it (to be compatible with my work machine). All was going fine, I partitioned the right disk and (I think) I got stuff installed on the right disk without messing up my normal home system (and therefore upsetting my wife) except for one small thing: I didn't, until too late, remember that the boot loader would likely get altered. Unfortunately the new system wasn't bootable (for some reason to be investigated but probably something to do with the cruddy disc I was using) and I had lost the grub menu altogether OK I fixed the problem but
a) couldn't the installation have noticed and warned me (after all it knew about the other system because it offered to import from it). From what I have read if I had selected the advanced tab I would probably have seen something about writing grub parameters so it is not as though someone hadn't thought about it.
b) having messed up it was quite hard to work out what to do: i'm not that familiar with the grub loader (though at least I knew that was probably what was the problem: the startup disc could I think be more helpful about repairing a system). Having grovelled around in various manuals, none of which gave an adequate description of grub, I searched the web (why didn't I do that first - stupid again) and found a really simple description of what to do at
http://microdotsagamedev.wordpress.com/2007/06/08/repair-your-grub-loader

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub Edit question
Assignee:
No assignee Edit question
Solved by:
John Cobb
Solved:
Last query:
Last reply:
Revision history for this message
Tom (tom6) said :
#1

lol, is that black writing against a black background? I can only read the commands by selecting the whole 'empty' space. Err, is there still a problem? Please let us know what the current problem is. You can fix the mbr from within Windows if you can boot into it. This will overwrite the mbr and only give the Windows options on bootup or you can try installing Ubuntu properly on the main drive and use it's grub to fix the mbr which should give proper dual-boot options
https://help.ubuntu.com/community/WindowsDualBoot

If the Windows on your main drive is Vista thenit could get tricky but we could give that a go. If the spare space on your main-drive is tiny then we may have to suggest installing a tiny distro such as Wolvix (needs a lot less than 1GB) rather than Ubuntu which needs 8Gb
http://distrowatch.com/table.php?distribution=wolvix
Actually doing the dual-boot with Wolvix rather than Ubuntu may well help explain and fix quite a few issues.

Good luck and regards from
Tom :)
Tom

Revision history for this message
Sam_ (and-sam) said :
#2

Well,
the good news, with every failure we learn a lot, sort of implemented philosophy of *nix systems.
Hence I'll bet on community docs

https://help.ubuntu.com/community/GrubHowto#Backup,%20Repairing%20and%20Reinstalling%20GRUB

https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

##my favourite GRUB page
http://users.bigpond.net.au/hermanzone/p15.htm#Re-install_Grub_with_Live_CD

Nobody can know everything, but one out there knows something.

Enjoy Ubuntu

Revision history for this message
Sam_ (and-sam) said :
#3

Tom,
maybe it helps when you edit text & backround colour in your browser or try system colours.
Could be that I'm able to read because having less opacity and brightness settings through Compiz, reading depends on workspace background.

Revision history for this message
John Cobb (jccobb) said :
#4

Perhaps I didn't really make the point clear. What I was trying to report was a possible deficiency in the ubuntu installation 'program' not that I was in trouble, possibly I've not really got the right forum for reporting things like that. I just felt that the installer let me get into trouble a little too easily and that having got into trouble finding out what to do to regenerate my mbr was more difficult than it ought to be, given how easily it can happen. In this respect it seems to me that the installation CD could usefully have a menu item that says "repair existing installation" (and then of course stuff to support the process of repair which would of course be much more difficult to write). In fact the advice on the website which I quote below worked a treat.

The links given by Sam would have answered my problem though in fact the link I found is probably easier and certainly more reassuring. One comment I would make is that finding these links by searching in the ubuntu help does not seem very easy: how would someone who didn't know what grub did or what grub was or what an mbr was find them? And if they did wouldn't they be rather daunted?

For the record what I actually did.
I had this spare hard disc that was connected using a USB device. Now my PC has the ability to boot from USB device (and the ability to turn of devices such as the internal SATA disc - but I forgot to do that). It will quite happily boot from a USB dvd/CD for instance. SO I installed the 8.10 on the disc. This rewrites the menu.lst (but on the SATA disc). I try to boot, well this would (I think) have been OK had the disc worked in the way I was assuming because there was in the grub menu file a list of all the various kernels; both 8.04 and 8.11 except that my PC didn't quite support booting with the USB disc. It seems that if I have the USB disc turned on at boot time it just gets confused (to the extent I don't get the chance to even get into the bios configuration). OK so I curse and turn of the device; unfortunately I don't get to see the grub menu and obviously it can't boot the default system because that is on the disc that isn't turned on (or i can't see the menu I note something above about black writing on a black background). Anyway I didn't investigate further just panicked a bit until I found this:

The answer: (some explanatory notes of my own follow after this)

" GRUB is the bootloader of choice for Ubuntu, it is flexible and can be edited to load windows partitions if needed. Every once in a while windows may have the inclination to overwrite your bootloader with its own. This will make accessing your Ubuntu box a mission - fear not, I have a quick solution ;) Follow these steps to repair your GRUB loader:

Boot your PC with an Ubuntu Live CD in the drive

Open a shell (Terminal)

Type the following to re-configure GRUB

sudo grub

Type the following followed by the TAB key

root (hd

This will provide you with a list of possible physical drives eg:

hd0 or hd1

Type the number of the drive you installed ubuntu on, not to worry if you unsure, the next step with tell you if you on the right path. Add a ‘,‘ after the number and press the TAB key again:

root (hd0,

You will see something similar to the following:

grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0×7
Partition num: 2, Filesystem type is ext2fs, partition type 0×83
Partition num: 4, Filesystem type unknown, partition type 0×7
Partition num: 5, Filesystem type is fat, partition type 0xb
Partition num: 6, Filesystem type is fat, partition type 0xb
Partition num: 7, Filesystem type unknown, partition type 0×82

Notice the ext2fs partition, this is the one Ubuntu is installed for the above example. I would therefore type:

root (hd0,2)

Now type the following, replacing hd0 with the physical drive Ubuntu is installed

setup (hd0)

Close the terminal, reboot and enjoy your restored GRUB loader. Let me know how it goes for ya ;)"

Some grossly simplified explanatory notes in case someone else comes across all this.
1) a boot loader is a program responsible for getting your system started. As such it typically lives in a special area on the disc call the MBR (Master Boot Record). A bootloader is designed to run in the very special environment that exists at machine start up: it will not run as a normal program. Discs are not the only devices that can support a bootloader some network cards also have facilities for providing a bootloader stored on some central service.
2) Grub (Grand Unified Bootloader) is probably the most flexilble of the bootloaders and is the one used by the ubuntu Linux distribution, it is not, however used by windows, though grub can be used to boot windows indirectly.
3) When a system is installed it is likely that changes will occur to the MBR since that system will very likely 'think' that it is the only thing in the universe. You are likely therefore to find that now and then you need to repair your installation.
4) In linux grub stores its parameters in /boot/menu.lst (along with a lot of other stuff). look at this, back it up but don't fiddle with it without reading more about it.
5) slightly confusingly the grub configuration program is also called grub. There are therefore two distinct things call grub the bootloader and the configuration program. The grub configuration program can be run in a linux terminal as a normal program. To do anything useful it has to run with full permission so it should be run under the root user or using the SUDO command viz sudo grub.
6) grub and linux use different conventions for referring to connected devices (and anyway Linux is not all that consistent with itself). Grub uses the format: command (devicedevicenumber,partionnumber) where numbering is from zero so for example root (hd0,1) means the second partition on the first disc. Yes there is a space between command and the open bracket.
7) when typing commands to grub it tries to help you by providing a list of possible answers when you type the tab character.
8) if you want to create a mulitboot system grub can do it: but read one of the comprehensive how to's first and backup your /boot configuration.

Revision history for this message
John Cobb (jccobb) said :
#5

supplementatry note due to typo I got one of the paths wrong in notes
I should of said grub parameters reside in /.boot/grub/menu.lst (together with the rest of the grub stuff).