People who use windows and ubuntu dual systems are very likely to reinstall a certain system, or add another partition, which will cause the system to restart:
- GRUB loading
- error:unknow filesystem
- grub rescue>
1. Concept
BIOS: "Basic Input Output System", the Chinese name is "Basic Input Output System". In fact, it is a set of programs that are solidified on a ROM chip on the motherboard of the computer. It saves the most important basic input and output programs of the computer, system setting information, self-checking programs after booting, and system self-starting programs. Its main function is to provide the lowest-level and most direct hardware setup and control for the computer.
MBR: "Master Boot Record" The physical sector of the hard disk, also called the master boot record! Because the BIOS is too small to carry the running program, after the BIOS detects a hard disk, it simply judges the contents of cylinder 0, head 0, and sector 1 of the hard disk to the specified location in the memory, and then jumps To this position, start running from this position, the size is 512 bytes, which mainly store the boot program and the partition table of the hard disk.
GRUB: "GRand Unified Bootloade" multi-operating system boot manager, that is, after running this GRUB, it can be used to boot into other systems, including window and linux
The above three concepts should be able to understand their process literally, generally:
The PC first boots to the BIOS, then detects the MBR of the hard disk, loads the content of the MBR sector (that is, the GRUB written on it) into the memory and runs, and then realizes a new jump start through the result obtained by running GRUB!
2. Ubuntu's grub2 fix
When the PC is installed with windows first and then ubuntu or there is only one ubuntu system, and the grub2 boot program that comes with the ubuntu system is written on the MBR, then the main boot program for booting is grub2! (ubuntu has been used since 9.10. grub2)
And grub2 is divided into two parts, one of which is written to MBR, and one of which exists in the /boot/grub directory of ubuntu.
The appearance of grub rescue> means that the grub program cannot function properly in the MBR part, and the grub rescue mode is started because the /boot/grub part cannot be found.
Available commands under grub rescue:
set, ls, insmod, root, prefix (set the startup path)
First view all partitions through ls, which will list:
(hd0),(hd0,msdos8),(hd0,msdos7),(hd0,msdos6),(hd0,msdos5),(hd0,msdos3),(hd0,msdos1)
Need to find the installation partition of ubuntu, through ls (hd0, msdos*)/boot until it does not appear: error: unknown filesystem
If you know which partition to start installing ubuntu in, such as sda7, then this is msdos7. If you add a partition before the ubuntu hard disk space, then move the ubuntu partition serial number back! become msdos8
After finding it, set the one-time startup parameters with the following command:
- grub rescue>set root=(hd0,msdos8)
- grub rescue>set prefix=(hd0,msdos8)/boot/grub
- grub rescue>insmod /boot/grub/normal.mod
grub rescue>normal The boot interface in boot/grub will appear!
If /boot/grub is not damaged, you can enter the ubuntu system. If the part of grub to start ubuntu is damaged, you need to manually boot:
Enter the grub command line:
- grub > root (hd0,8) ## Specify the partition containing vmlinuz-2.6.18-274.7.1.el5 and initrd-2.6.18-274.7.1.el5.img
- grub > kernel /boot/vmlinuz-2.6.18-274.7.1.el5 ro root=/dev/sda8 ## root= is the partition that specifies /sbin/init, that is, the partition that mounts / (from a Linux perspective)
- grub > initrd /boot/initrd-2.6.18-274.7.1.el5.img ## It is said that this can be omitted
- grub> boot
After entering ubuntu correctly, the grub part of the MBR needs to be updated to accommodate the new partition situation:
Terminal input:
- sudo update-grub2
- sudo grub-install/dev/sda
Update to /boot/grub/grub.cfg! Then install grub to the MBR of the main hard drive
I have encountered such an unsuccessful installation. There is another method for reinstalling grub2 to MBR in the GRUB2 manual, record it:
- This scenario installation uses the chroot command to access files on the compromised system.
- Once the chroot command is executed, the LiveCD will treat the / (root directory) of the corrupted system as if it were currently in use.
- Commands executed in a chroot environment affect the filesystem of the compromised system, not the LiveCD's.
- 1. Boot into the LiveCD desktop (Ubuntu 9.10 or later). Note that this LiveCD must be the same version you are trying to repair now - either 32-bit or 64-bit (otherwise chroot will fail).
- 2. Open Terminal - Apps, Affiliate Apps, Terminal.
- 3. Confirm your standard system partition - (options are lowercase "L")
- sudo fdisk -l
- If you are not sure, do
- df -Th
- Find the correct disk size and ext3 or ext4 format.
- 4. Mount your standard system partition
- Replace with the correct partition: sda1, sdb5, etc.
- sudo mount /dev/sdXX /mnt #範例:sudo mount /dev/sda1 /mnt
- 5. If you have a separate /boot partition:
- sdYY is the location of the /boot partition (eg sdb3)
- sudo mount /dev/sdYY /mnt/boot
- 6. Mount important virtual file systems:
- sudo mount --bind /dev /mnt/dev
- sudo mount --bind /dev/pts /mnt/dev/pts
- sudo mount --bind /proc /mnt/proc
- sudo mount --bind /sys /mnt/sys
- 7. Chroot to your standard system device:
- sudo chroot /mnt
- 8. If there is no /boot/grub/grub.cfg in the system or its content is incorrect, use the following command to rebuild
- update-grub
- 9. Reinstall GRUB 2:
- Replace with the correct device - sda, sdb, etc. Do not specify a partition number.
- grub-install /dev/sdX
- 10. Verify the installation (use the correct device, eg sda. Do not specify a partition):
- sudo grub-install --recheck /dev/sdX
- 11. Exit chroot: press CTRL-D on the keyboard
- 12. Unmount the virtual file system:
- sudo umount /mnt/dev/pts
- sudo umount /mnt/dev
- sudo umount /mnt/proc
- sudo umount /mnt/sys
- If you have a separate /boot partition mounted:
- sudo umount /mnt/boot
- 13. Unmount the /usr directory of the LiveCD:
- sudo umount /mnt/usr
- 14. Uninstall the last device:
- sudo umount /mnt
- 15. Reboot. sudo reboot
Another common thing is that you cannot boot to the grub interface. At this time, you need another boot. Many methods on the Internet are to use the ubuntu installation CD, that is, livecd.
I usually use the U disk, use Lao Mao Tao to load an ubuntu iso to make a ubuntu boot U disk, and then select the U disk to boot from the bios,
Select try running ubuntu, do not select the install option
This will run the ubuntu system we made on the U disk. You can use this as a medium to modify other system files on the machine, like the above-mentioned first mount those partitions:
sudo mount /dev/sdxx /mnt
You can use the sudo fdisk -l command to view the partition status and select the corresponding
If you want to modify the corresponding content, use chroot to switch and exit after ctrl+d
My side is 13.04, the grub version is:
- jscese@jscese-H61M-S2P:~$ grub-install -v
- grub-install (GRUB) 2.00-13ubuntu3
In this case the correct grub can be installed to the MBR with the following command:
- grub-install --root-directory=/mnt /dev/sda
My sda is the first hard drive
Symptom:
Boot display: GRUB loading
error: unknow filesystem
grub rescue>
Reason:
Since the operator does not know that grub2 is divided into two parts, one part (generally) is written on mbr, and the other part is written in the /boot/grub directory of a certain partition (if /boot is a separate partition, it is directly written in the corresponding partition /grub directory). Due to the above operations, the part in the mbr of grub2 cannot find the part in the /grub directory (or that part has been deleted).
Ideas:
Method 1, completely delete grub2, so that this prompt does not appear again:
suitable for people who no longer want to use ubuntu and want to switch back to windows.
This is very simple, as long as you have a Windows startup disk (not Ghost), use it to start, select the installation location, do not need to actually install, just exit and restart.
Or use it to boot to the troubleshooting desk, either run fixboot or fixmbr.
Under the win7 command line, execute: BootRec.exe /fixmbr
(/fixmbr repairs mbr, /FixBoot repairs the boot sector, /ScanOs detects the installed win7, /RebuildBcd rebuilds bcd.)
Method 2, reinstall and repair grub2
1 . First use the ls command to find out which partition Ubuntu is installed in:
Enter the following command under grub rescue>:
Code:
Will list all disk partition information, for example:
2. Then call the following commands in sequence: X represents the number of each partition
If /boot does not have a separate partition, use the following command:
Code:
If /boot is a separate partition, use the following command:
Normally, there are several hundred files listed, many with the extensions .mod and .lst and .img, and one with grub.cfg. Assuming that when (hd0,5) is found, the files in the folder are displayed, which means that Linux is installed in this partition.
4. If the correct grub directory is found, try to temporarily associate the two parts of grub as follows:
The following is the command without a separate partition for /boot:
Quote:
grub rescue>set prefix=(hd0,5)/boot/grub
grub rescue>insmod /boot/grub/normal.mod
The following are the commands for the /boot separate partition: (These sentences are to be verified)
grub rescue>set prefix=(hd0,5)/grub
grub rescue>insmod /grub/normal.mod
Then call the following command to display the missing grub menu.
grub rescue>normal
but don't be happy, if restart at this time, the problem still exists, we need to enter Linux to repair grub.
Start up, after entering ubuntu, execute in the terminal:
Code:
sudo grub-install /dev/sda
(sda is your hard disk number, never specify a partition number, for example, sda1, sda5, etc. are not correct)
Has the restart test restored the grub boot menu? Congratulations on your successful recovery!
5. If the correct /grub directory cannot be found, such as the 3rd and 4th misoperations, try to find out whether there are linux core files, and then call the following commands in turn: X indicates the number of each partition:
Under grub rescue>, enter:
if /boot does not have a separate partition:
Code:
If /boot is partitioned separately, then:
Look for a file with a name similar to vmlinuz-3.0.0-12-generic, which is the linux core file. If found, write down the X value in (hd0,X). Suppose that when (hd0,5) is found, the files in the folder are displayed.
Then use live cd or live usb to start, and enter the following commands in the ubuntu terminal of the live cd (the "5" in sda5 must be changed to the value recorded above) (these two sentences need to be verified):
If /boot does not have a separate partition :
Code:
sudo grub-install --boot-directory=/mnt/boot /dev/sda
If /boot is partitioned separately, then:
sudo grub-install --boot-directory=/mnt /dev/sda
Then restart it.
(The above two commands can also solve the problem that the grub installation location is wrong when ubuntu is installed, and grub is not installed to /dev/sda, resulting in the problem that the ubuntu startup item does not appear directly into windows when starting , but you need to determine the "5" in sda5 by yourself "Change to what number.)
6. If there is no linux core file, then reinstall it completely