### Repairing GRUB in Linux
Recently, the 2003 system has been having a lot of problems.
Mainly, the firewall causes many chat software to not work @|@
Hey, sometimes even the MBR file is lost
Is there no way to reinstall GRUB???
Hehe, no need to waste precious time. Let's look at the recent gains: >
.................Feeling of repairing Linux 9 GRUB boot...................
1. Put the first installation disc into the CD-ROM, then restart the machine, and set the system to boot from the CD-ROM in the BIOS.
2. When the installation interface appears, press F5
Then type after boot
linux rescue
Then press Enter
3. A series of keyboard operations and a few simple configurations, then [Continue]... I won't go into details about this process, it's relatively simple.
4. Then such characters will appear
sh#
5. We can operate GRUB... Hehe... As long as such a thing appears, the rest is easy. I just won't say it, everyone can understand, everyone in the world knows it...
sh#grub
Such characters will appear
grub>
We can operate behind such characters. Note that after the root space is a (hdx,y)
grub>root (hdX,Y)
grub>setup (hd0)
If successful, there will be a successful......
Here, X, if it is one disk, it is 0. If the root partition of your installed Linux is on the second hard disk, then X is 1; Y is the root partition where the Linux system is installed. setup (hd0) is to write GRUB to the MBR of the hard disk.
Let me give an example. Take my hard disk as an example. I installed XP on the first hard disk and RH73 on hda9 of the first hard disk. I have a total of two hard disks. If I lose GRUB, I can use this method to get it back. If you don't know which partition your Linux is installed on, that is, you don't know what Y is, it doesn't matter. First, enter root (hdX, then use [TAB] to check, and you will understand...
The operation is as follows: [There are instructions above when starting the machine]
sh# grub
The following words will appear
grub>
Then operate like this. If I know that my Linux is installed on the first hard disk but I don't know which partition it is installed on, I can first enter root (hd0, then use the [TAB] key to complete, then you will understand. You can also type
find /boot/grub/grub.conf
find /grub/grub.conf
to query the location
grub>root (hd0,8)
grub>setup (hd0)
Of course, there are accidents. For example, this time MagicLinux still can't boot the system. The solution is as follows:
After installing the XP system, GRUB system boot is gone
Use the installation disc of Red Flag 4.1
F5
linux rescue
grub
find /grub/grub.conf
Get hd0,6
root (hd0,6)
setup (hd0)
Then exit, GRUB is built, but I can only stay at grub>...
Under grub>, cat (hd0,6)/grub/grub.conf, press Enter
Check the command line, copy the long command for the first Linux system login, press Enter
boot, press Enter to enter the system
Then create a menu.lst file in /boot/grub, directly copy the content in grub.conf to menu.lst, restart, and the GRUB graphical interface will come back~~
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Repairing the GRUB boot menu
I saw some friends post such posts asking about the method to solve reinstalling Win breaking GRUB and forgetting the root password. I wrote the solution and pinned it, so everyone can just look at it later.
1. fdisk /mbr writes the DOS boot record into the MBR
If GRUB has problems.
1. Boot with a made floppy. If the floppy is not made, use the installation CD to select upgrade, and finally make a bootable disk. After booting with the made floppy, enter grub-install /dev/hda in the shell to install GRUB to the MBR.
2. Boot from the CD. When boot appears, type linux rescue
A series of keyboard operations and a few simple configurations, then [Continue]... I won't go into details about this process, it's relatively simple.
Then such characters will appear
sh#grub
Such characters will appear
grub>
We can type behind such characters
grub>root (hdX,Y)
grub>setup (hd0)
If successful, there will be a successful......
Here, X, if it is one disk, it is 0. If the root partition of your installed Linux is on the second hard disk, then X is 1; Y is the root partition where the Linux system is installed. If you don't know where the root partition is, you can use df, and it will display it. setup (hd0) is to write GRUB to the MBR of the hard disk.
2. If the super user forgets the password, he can't enter the system, and can't manage and use the system. Originally, this kind of thing is not very likely to happen, but among some Linux single-machine users, especially beginners, it is relatively easy to happen. The general solution is to format the hard disk and reinstall the system, but this is a bit overkill. How to repair it, there are the following methods
What to do if you forget the password?
1. lilo
1. When the lilo: prompt appears, type linux single
The screen shows lilo: linux single
2. Press Enter to directly enter the Linux command line
3. #vi /etc/passwd
Delete the content after root: and before the next : in the first line, which starts with root.
The first line will be similar to
root::......
Or directly passwd
Save
4. #reboot restart, the root password is empty
2. grub
1. When the grub screen appears, use the up and down keys to select the item you usually start Linux with (don't select dos), then press e key
2. Again use the up and down keys to select the item you usually start Linux with (similar to kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/), then press e key
3. Modify the command line you see now, add single, the result is as follows:
kernel /boot/vmlinuz-2.4.18-14 single ro root=LABEL=/ or you can add single at the end.
4. Press Enter to return, then press b key to start, and you can directly enter the Linux command line
5. #vi /etc/passwd
Delete the content after root: and before the next : in the first line, which starts with root.
The first line will be similar to
root::......
Or directly passwd
Save
6. #reboot restart, the root password is empty
If it is not a dual boot, boot with a made floppy, linux single, linux 1, linux -s can all enter single-user mode, then go in and passwd. If there is no made floppy, you start with the installation CD, select upgrade to make one. However, you can also passwd with the installation CD.
Type linux rescue at the beginning, enter repair mode, then select read-only or skip. Read-only mounts the already mounted hard disk, and skip you have to mount the hard disk yourself.
Then chroot ./
Enter the real single-user mode, then passwd.
If there is no floppy drive or CD-ROM in the system, you can remove the hard disk, hang it on another computer with Linux, Unix, then mount, then find the /etc/passwd that mounts your hard disk, and clear the root password. But I haven't tried this method.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Guide to repairing GRUB (using tools)
1. Download the tool
If you installed Grub to the MBR, reinstalling Windows XP/2K, etc. will clear the MBR. Then how to repair the Grub boot record in the MBR? The method introduced here is to use Grub4DOS, a tool under DOS. The latest version of Grub4DOS can be downloaded here. After downloading, you can use WinRAR, WinZIP under win or the tar zxvf command under Linux to unzip it, and put grub.exe in one of your fat/fat32 partitions (such as D:\grub4dos).
2. Restart to DOS, you can use a DOS boot floppy or CD-ROM (I think everyone generally has a win98 or winme CD-ROM). Then type:
Code:
d:\grub4dos\grub.exe
This enters the Grub environment, and you can see a gurb> prompt. What needs to be done next is to restore your Grub boot record
3. Type under the Grub> prompt
Code:
root (hdx,y)
kernel (hdx,y)/boot/yourkernelname ro root=/dev/hdxx
setup (hd0)
The first command is to specify the location of your /boot partition. If your /boot is not a separate partition, then it is your / partition.
The second command specifies the location of the kernel, which is determined according to your actual situation.
The third command is to write the Grub boot record to the MBR.
If you are not very clear about the location of your Linux partition, you can use the TAB key completion function to check and determine.
After executing the setup command, if successful, you will see the succeed! word.
Now you can restart and enter Grub.
4. If you just want to start Linux instead of repairing Grub, then you can type the following command after entering DOS to start your Linux system.
Code:
d:\grub4dos\grub.exe --config-file=(hdx,y)/boot/grub/grub.conf
The parameters are the same as above.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Repairing the GRUB boot of Linux (vfloppy)
Recently, my machine's hard disk is not enough, so I removed the floppy drive (taking up space), installed a second hard disk, then installed Windows XP on the first hard disk, and RedHat Fedora Core 1 (Red Hat Linux personal edition) on the second hard disk, using Grub under Linux to boot. Considering that the Windows system often needs to be reinstalled, I want to make a Linux emergency boot disk to repair the Grub boot. But without a floppy drive, how to do it? After checking the help, the following method is found to be feasible, for your reference:
1. Make a Linux boot disk. Under Linux, mkbootdisk can be used to make an emergency boot disk. But without a floppy drive, how to do it? It doesn't matter, mkbootdisk can make the boot disk into an image file. On my machine, it is done like this: mkbootdisk --device /root/fedora.img 2.4.22-1.2115.nptl. The last parameter is the version number of your Linux kernel. If you don't know, you can check it with uname -r. Then copy the floppy image file to the Windows partition.
2. Find a software called virtual boot floppy vfloppy. Run it and load fedora.img into it. Actually, add the boot of the floppy to boot.ini in Windows XP. Then when Windows XP starts, if you select floppy boot, you will enter Linux. If Grub is damaged or the Windows system reinstalls and rewrites the MBR (master boot record), you can use this method to boot into Linux, then use grub-install /dev/hda to reinstall Grub.
Note: You can also use some software to manage the MBR, such as SRCTools.
Recently, the 2003 system has been having a lot of problems.
Mainly, the firewall causes many chat software to not work @|@
Hey, sometimes even the MBR file is lost
Is there no way to reinstall GRUB???
Hehe, no need to waste precious time. Let's look at the recent gains: >
.................Feeling of repairing Linux 9 GRUB boot...................
1. Put the first installation disc into the CD-ROM, then restart the machine, and set the system to boot from the CD-ROM in the BIOS.
2. When the installation interface appears, press F5
Then type after boot
linux rescue
Then press Enter
3. A series of keyboard operations and a few simple configurations, then [Continue]... I won't go into details about this process, it's relatively simple.
4. Then such characters will appear
sh#
5. We can operate GRUB... Hehe... As long as such a thing appears, the rest is easy. I just won't say it, everyone can understand, everyone in the world knows it...
sh#grub
Such characters will appear
grub>
We can operate behind such characters. Note that after the root space is a (hdx,y)
grub>root (hdX,Y)
grub>setup (hd0)
If successful, there will be a successful......
Here, X, if it is one disk, it is 0. If the root partition of your installed Linux is on the second hard disk, then X is 1; Y is the root partition where the Linux system is installed. setup (hd0) is to write GRUB to the MBR of the hard disk.
Let me give an example. Take my hard disk as an example. I installed XP on the first hard disk and RH73 on hda9 of the first hard disk. I have a total of two hard disks. If I lose GRUB, I can use this method to get it back. If you don't know which partition your Linux is installed on, that is, you don't know what Y is, it doesn't matter. First, enter root (hdX, then use [TAB] to check, and you will understand...
The operation is as follows: [There are instructions above when starting the machine]
sh# grub
The following words will appear
grub>
Then operate like this. If I know that my Linux is installed on the first hard disk but I don't know which partition it is installed on, I can first enter root (hd0, then use the [TAB] key to complete, then you will understand. You can also type
find /boot/grub/grub.conf
find /grub/grub.conf
to query the location
grub>root (hd0,8)
grub>setup (hd0)
Of course, there are accidents. For example, this time MagicLinux still can't boot the system. The solution is as follows:
After installing the XP system, GRUB system boot is gone
Use the installation disc of Red Flag 4.1
F5
linux rescue
grub
find /grub/grub.conf
Get hd0,6
root (hd0,6)
setup (hd0)
Then exit, GRUB is built, but I can only stay at grub>...
Under grub>, cat (hd0,6)/grub/grub.conf, press Enter
Check the command line, copy the long command for the first Linux system login, press Enter
boot, press Enter to enter the system
Then create a menu.lst file in /boot/grub, directly copy the content in grub.conf to menu.lst, restart, and the GRUB graphical interface will come back~~
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Repairing the GRUB boot menu
I saw some friends post such posts asking about the method to solve reinstalling Win breaking GRUB and forgetting the root password. I wrote the solution and pinned it, so everyone can just look at it later.
1. fdisk /mbr writes the DOS boot record into the MBR
If GRUB has problems.
1. Boot with a made floppy. If the floppy is not made, use the installation CD to select upgrade, and finally make a bootable disk. After booting with the made floppy, enter grub-install /dev/hda in the shell to install GRUB to the MBR.
2. Boot from the CD. When boot appears, type linux rescue
A series of keyboard operations and a few simple configurations, then [Continue]... I won't go into details about this process, it's relatively simple.
Then such characters will appear
sh#grub
Such characters will appear
grub>
We can type behind such characters
grub>root (hdX,Y)
grub>setup (hd0)
If successful, there will be a successful......
Here, X, if it is one disk, it is 0. If the root partition of your installed Linux is on the second hard disk, then X is 1; Y is the root partition where the Linux system is installed. If you don't know where the root partition is, you can use df, and it will display it. setup (hd0) is to write GRUB to the MBR of the hard disk.
2. If the super user forgets the password, he can't enter the system, and can't manage and use the system. Originally, this kind of thing is not very likely to happen, but among some Linux single-machine users, especially beginners, it is relatively easy to happen. The general solution is to format the hard disk and reinstall the system, but this is a bit overkill. How to repair it, there are the following methods
What to do if you forget the password?
1. lilo
1. When the lilo: prompt appears, type linux single
The screen shows lilo: linux single
2. Press Enter to directly enter the Linux command line
3. #vi /etc/passwd
Delete the content after root: and before the next : in the first line, which starts with root.
The first line will be similar to
root::......
Or directly passwd
Save
4. #reboot restart, the root password is empty
2. grub
1. When the grub screen appears, use the up and down keys to select the item you usually start Linux with (don't select dos), then press e key
2. Again use the up and down keys to select the item you usually start Linux with (similar to kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/), then press e key
3. Modify the command line you see now, add single, the result is as follows:
kernel /boot/vmlinuz-2.4.18-14 single ro root=LABEL=/ or you can add single at the end.
4. Press Enter to return, then press b key to start, and you can directly enter the Linux command line
5. #vi /etc/passwd
Delete the content after root: and before the next : in the first line, which starts with root.
The first line will be similar to
root::......
Or directly passwd
Save
6. #reboot restart, the root password is empty
If it is not a dual boot, boot with a made floppy, linux single, linux 1, linux -s can all enter single-user mode, then go in and passwd. If there is no made floppy, you start with the installation CD, select upgrade to make one. However, you can also passwd with the installation CD.
Type linux rescue at the beginning, enter repair mode, then select read-only or skip. Read-only mounts the already mounted hard disk, and skip you have to mount the hard disk yourself.
Then chroot ./
Enter the real single-user mode, then passwd.
If there is no floppy drive or CD-ROM in the system, you can remove the hard disk, hang it on another computer with Linux, Unix, then mount, then find the /etc/passwd that mounts your hard disk, and clear the root password. But I haven't tried this method.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Guide to repairing GRUB (using tools)
1. Download the tool
If you installed Grub to the MBR, reinstalling Windows XP/2K, etc. will clear the MBR. Then how to repair the Grub boot record in the MBR? The method introduced here is to use Grub4DOS, a tool under DOS. The latest version of Grub4DOS can be downloaded here. After downloading, you can use WinRAR, WinZIP under win or the tar zxvf command under Linux to unzip it, and put grub.exe in one of your fat/fat32 partitions (such as D:\grub4dos).
2. Restart to DOS, you can use a DOS boot floppy or CD-ROM (I think everyone generally has a win98 or winme CD-ROM). Then type:
Code:
d:\grub4dos\grub.exe
This enters the Grub environment, and you can see a gurb> prompt. What needs to be done next is to restore your Grub boot record
3. Type under the Grub> prompt
Code:
root (hdx,y)
kernel (hdx,y)/boot/yourkernelname ro root=/dev/hdxx
setup (hd0)
The first command is to specify the location of your /boot partition. If your /boot is not a separate partition, then it is your / partition.
The second command specifies the location of the kernel, which is determined according to your actual situation.
The third command is to write the Grub boot record to the MBR.
If you are not very clear about the location of your Linux partition, you can use the TAB key completion function to check and determine.
After executing the setup command, if successful, you will see the succeed! word.
Now you can restart and enter Grub.
4. If you just want to start Linux instead of repairing Grub, then you can type the following command after entering DOS to start your Linux system.
Code:
d:\grub4dos\grub.exe --config-file=(hdx,y)/boot/grub/grub.conf
The parameters are the same as above.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Repairing the GRUB boot of Linux (vfloppy)
Recently, my machine's hard disk is not enough, so I removed the floppy drive (taking up space), installed a second hard disk, then installed Windows XP on the first hard disk, and RedHat Fedora Core 1 (Red Hat Linux personal edition) on the second hard disk, using Grub under Linux to boot. Considering that the Windows system often needs to be reinstalled, I want to make a Linux emergency boot disk to repair the Grub boot. But without a floppy drive, how to do it? After checking the help, the following method is found to be feasible, for your reference:
1. Make a Linux boot disk. Under Linux, mkbootdisk can be used to make an emergency boot disk. But without a floppy drive, how to do it? It doesn't matter, mkbootdisk can make the boot disk into an image file. On my machine, it is done like this: mkbootdisk --device /root/fedora.img 2.4.22-1.2115.nptl. The last parameter is the version number of your Linux kernel. If you don't know, you can check it with uname -r. Then copy the floppy image file to the Windows partition.
2. Find a software called virtual boot floppy vfloppy. Run it and load fedora.img into it. Actually, add the boot of the floppy to boot.ini in Windows XP. Then when Windows XP starts, if you select floppy boot, you will enter Linux. If Grub is damaged or the Windows system reinstalls and rewrites the MBR (master boot record), you can use this method to boot into Linux, then use grub-install /dev/hda to reinstall Grub.
Note: You can also use some software to manage the MBR, such as SRCTools.
