A site for solving at least some of your technical problems...
A site for solving at least some of your technical problems...
Today I got an error 16 with GRUB on one of my machines. This had happened before so I did not worry too much. It is just quite annoying.
A Ubuntu boot CD has a cool feature one can use to rescue such a system (i.e. re-install GRUB properly.) More or less, boot the CD, select the rescue mode, let it do its things for a moment (after you select options like keyboard, etc.)
At the time it tells you to select your drive, choose your boot drive (/dev/sda1 maybe? In my case, it was /dev/hda5.) The system says something like Which disk do you want to select as root? (i.e. / in your file system.) Just for fixing GRUB you should not need anything more than that.
The drive you select should include the /boot folder from your Linux installation. If /boot is on a separate partition, then go to the root partition and use mount to get access to /boot.
Once the drive was selected, choose to enter a shell. After you hit enter it starts and the selected partition becomes / (with a chroot that is done automatically for you!)
Note that the chroot on / is important for the GRUB command to work. If you're not in that folder, the booting to your Linux partition won't work correctly.
Newer versions of Ubuntu do not really offer that capability anymore. I have a set of commands I use to do the chroot manually. The fact is that you have to prepare a few directories before you can do so and make sure the drive is mounted.
First we mount the root drive on /mnt and if necessary, the boot drive on /mnt/boot. With newer systems, we also have many virtual file systems that need to be mounted. After all of that, we can finally run the chroot command. Once playing as if you were booted on your failing boot system, you can start working on your fixes in grub, initramfs (necessary if you edit /etc/fstab), etc.
If you are looking for an LVM partition, you may need to run
sudo mdadm --assemble --scan
before trying to mount those drives. However, on my end, I now avoid RAID-1 for my root & boot partition. It makes since much more brittle (much more likely to require heavy maintenance).
# Mount root partition: sudo mount /dev/sdXY /mnt # /dev/sdXY is your root partition, e.g. /dev/sda1, /dev/mapper/ubuntu--vg-ubuntu--lv, etc. # If you have a separate boot partition you'll need to mount it also: sudo mount /dev/sdYY /mnt/boot # Mount your virtual filesystems: for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done # Chroot sudo chroot /mnt # Edit fstab vim /etc/fstab # Make sure initramfs is updated update-initramfs -u # Edit config file(s) as needed, for example: vim /boot/grub/grub.cfg # Apply changes update-grub
Note that you may also need to mount other partitions, depending on the complexity of your system. In my case, I only need the root (/) and boot (/boot) partitions. You may also need a var (/var) or some other partition for some of the commands you want to run.
See stackoverflow for additional details and links.
Now you are ready to run: grub-install /dev/hda
This will give you some warnings, ignore them and try to reboot (i.e. Ctrl-D and then select reboot system.)
What had happened? Frankly I have no idea, but in general what happens is that MS-Windows overwrites some boot sectors. This makes GRUB not know what to do next. Obviously.
I have also heard of some people who reformatted a Linux partition for Windows but kept GRUB as their boot system. This is fine until you overwrite the files that GRUB needs to startup your computer (stage1 and/or stage2.) At that time you will have to replace GRUB with the standard MS-Windows MBR (Master Boot Record.) The MS-Windows CD let you fix the MBR.
But for me, GRUB says error 17 or 18... These are different errors. You can attempt to fix things as described here, but error 18 is usually because the hard drive cannot be read. Also this is likely your hardware, it could also come from your BIOS that cannot load data at such large sector numbers. In this case, try to put your root partition on /dev/hda1 at the very beginning of the hard drive. If that still fails... get a new drive or a new computer altogether! Well... first try with LILO or some other boot loader! It could be cheaper.