We recommend a very good Linux rescue system with great learning value. Here I will mainly explain the application of the Linux rescue system, including the background knowledge of the Linux rescue package. This article describes how to log on to the system during system repair. For example, when we forget the root password or encounter difficulties when the system is started normally, we can use the single-user mode, in the repair mode, Linux rescue and cross-Console Logon are used to load and log on to the file system;
How can we access the system when the system is damaged or difficult to log on? For example, when we forget the root password or the system cannot start normally, we first think of how to log on to the system or back up important data in the file system; the following methods are provided for your reference:
1. single-user mode;
In single-user mode, you must enter the password of the root user. Otherwise, you cannot log on to single-user mode. If you lose the password of the root user, you cannot reset your root password in single-user mode. In addition, in single-user mode, grub or lilo works properly;
In addition, you know where your system problems occur. When you log on in single-user mode, you can open the file system write operation and then fix the system you want; some may say, "I really don't know which system is wrong, it does not explain how to fix the system;
1. Use the grub System Boot manager for single-user logon;
After grub is started, move the keyboard to the Linux Startup item; press the e key; then move the keyboard to a line similar to the following, that is, the line of the kernel: kernel/boot/vmlinuz-2.6.11-1.1369_FC4 ro root = LABEL =/1 rhgb quiet move the cursor over this line, then press the e key to edit this line;
Enter a space at the end of the line, and then enter Linux single, which is similar to the following: kernel/boot/vmlinuz-2.6.11-1.1369_FC4 ro root = LABEL =/1 rhgb quiet Linux single end edit, press enter to return; next we need to start the system and press the B key to start it;
After running in single-user mode, the system prompts us to enter the root password. after entering the correct password, the system will enter. You can use df-h to view the Mount location of the file system, you can also use fdisk-l to view partitions and so on. But write operations on the file system may need to be viewed below. After a single user enters the system, the system may be read-only; run the following command; # mount-o remount, rw/
2. lilo Boot manager single-user mode;
In boot: Enter Linux single. When running in single-user mode, the system prompts us to enter the root password. If entered correctly, the system will enter; you can use df-h to view the Mount location of the file system, or use fdisk-l to view partitions. However, the write operations on the file system may be as follows; after a single user enters the system, the system may be read-only. Run the following command: # mount-o remount, rw/
Ii. Linux rescue repair mode;
In Linux, the repair mode is Linux rescue. In the repair mode, the system does not need the system password. When the repair mode is enabled, the system will prompt the file system on the partition to be mounted, we can choose based on our own system conditions. After you log on to the system, the system will prompt the directory to which the file system of the partition will be mounted. If you do not know where the file system is mounted, check it through df-h;
The repair mode requires the first or independent Repair Disk of the disk to be installed. For example, Fedora has a dedicated Repair Disk. In fact, the Repair Disk is similar to livecd in a sense and can run the system without being installed on the hard disk; then mount the file system. In fact, when we execute Linux rescue, there will be some prompts for systems such as Fedora, such as the partitions that he wants to mount, let's just select it;
When performing the repair mode, you need to perform the following steps: In BIOS, set the first boot drive to CDROM; second, find the first disk to be installed; put it into CDROM; when the CD is running, the installation interface is displayed. Enter Linux rescue after boot, and press Enter. boot: Linux rescue
What can we do when we enter the repair mode ?? Everything can be done, such as mounting USB disks for data backup; modifying the configuration file in the system ...... reset the root password and mount the file system ...... as long as you can think of it, most of it can be done;
3. log on to the Apsara stack console;
You do not need to enter the root password for a real cross-Console Logon. If you lose the root password, you need to log on across the console. the Linux rescue mentioned above is essentially, it means that you can log on to the system without password verification. logon across the console mainly includes: Using grub and lilo to log on across the console; Linux rescue mode; third-party livecd system and third-party Linux system;
1. log on to the console through grub and lilo boot;
1) if grub is used for system guidance;
After grub is started, move the keyboard to the Linux Startup item; press the e key; then move the keyboard to a line similar to the following, that is, the line of the kernel: kernel/boot/vmlinuz-2.6.11-1.1369_FC4 ro root = LABEL =/1 rhgb quiet move the cursor over this line, then press the e key to edit this line; a space at the end of the line, enter Linux single, which is similar to the following:
Kernel/boot/vmlinuz-2.6.11-1.1369_FC4 ro root = LABEL =/1 rhgb quiet Linux init =/bin/bash end edit, press enter to return; then we want to start the system, press B to start; the system may be read-only. Run the following command;
# Mount-o remount, rw/then we can use df-h to check the loading of the file system. Since all the file systems are mounted, What can't we do? Reset the root password and backup the file... for example, reset the root password; # passwd
2) if you use lilo for system boot;
In boot: Enter boot: Linux init =/bin/bash. after entering the system, you can use df-h to view the Mount location of the file system, you can also use fdisk-l to view partitions and so on. But the write operation on the file system may also look at the following; the system may be read-only; run the following command; # mount-o remount, rw/
2. Linux rescue;
Refer to the repair mode mentioned in the second point above;
3. Use Linux livecd CD or a third-party Linux system;
Linux livecd is a Linux system that runs on a CD without installation. livecd is mostly used for restoration. livecd integrates common system operating tools; A third-party Linux system refers to the installation of more than one Linux system on your machine. If one of them has a problem, we can use the other to fix it;
Livecd and a third-party Linux system are used to fix damaged Linux systems. Common tools include mount and chroot. If you simply change the problematic system file, mount is enough. The chroot tool can change/and then enter another system. This tool is indeed useful.
We will give an example to illustrate how to use mount and chroot. As for the simple use of third-party Linux and Livecd in the machine, we will not mention it here; livecd is the Linux running on the CD, you can find a release version of livecd to burn it, which is easy to use;
: Http://www.frozentech.com/content/livecd.php common SLAX, Knoppix, Damn Small Linux, Ubuntu... basically, you can download a small backup file. It depends on how you use it. Use livecd Linux or other Linux to fix the damaged Linux as follows:
1) mount the file system;
Note: run the mount and chroot commands with the root permission. For example, the problematic system is located in/dev/hda5. If you do not know which partition is Linux, you can view it through fdsik-l;
- [Root @ localhost ~] # Fdisk-l note: view the partition information;
- [Root @ localhost ~] # Pwd Note: determine the current working directory;
- /Root note: the current working directory is/root
- [Root @ localhost ~] # Mkdir upload MP Note: create a temporary directory under the current working directory;
- [Root @ localhost ~] # Mount/dev/hda5 into MP/Note: mount hda5 to the tmpsys directory;
- [Root @ localhost ~] # Df-h Note: Check whether the disk has been mounted;
- Filesystem capacity in use available % mount point
- /Dev/hda8 11 GB 9.8G 581 M 95%/
- /Dev/shm 236 M 0 236 M 0%/dev/shm
- /Dev/hda5 7.9G 5.9G 2.0G 76%/root/batch MP Note: after reading this, it is mounted to the/root/batch MP directory;
Since the file system in the/dev/hda5 partition has been mounted, we can write the mounted file system. For simple backup and file modification, yes, it works. Note: During the write operation, you need to be overwhelmed. during the operation of a file, you need to back up the file first. When the file cannot be mounted, it may be that your current kernel does not support the corresponding file system. If the system requires a file system, see the following example;
Mount-t file system type disk partition mount destination directory for Linux File System types mainly include: reiserfs, ext3, ext2; what file system type is used, you understand the most; if you still don't know, try one by one. For example, if my hda5 is reiserfs, you can use the following command to mount it. [root @ localhost ~] # Mount-t reiserfs/dev/hda5 restart MP/
2) chroot to the mounted file system;
The chroot tool is very useful. Many Linux systems support switching chroot to another file system and installing a series of system packages and system configurations. This does not mean that chroot can be used in any file system, first, the file system has certain tools and environments for running the system, such as/bin and/sbin directories ....
I cannot express it clearly in Chinese. I 'd like to explain it as an example. For example, I have two Linux systems on my machine, one running normally, and the other having some problems, for example, I forgot the root password ), I want to fix another problem through a normal system. First, we perform mount, that is, what we mentioned above, and then the next step is chroot. Switch to the file system to be repaired through chroot; for example, the problematic system is located at/dev/hda5.
- [Root @ localhost ~] # Fdisk-l
- [Root @ localhost ~] # Pwd
- /Root
- [Root @ localhost ~] # Mkdir upload MP
- [Root @ localhost ~] # Mount/dev/hda5 initialize MP/
- [Root @ localhost ~] # Df-h
- Filesystem capacity in use available % mount point
- /Dev/hda8 11 GB 9.8G 581 M 95%/
- /Dev/shm 236 M 0 236 M 0%/dev/shm
- /Dev/hda5 7.9G 5.9G 2.0G 76%/root/batch MP
- [Root @ localhost ~] # Chroot slave MP Note: chroot is in the hda5 partition system;
- Bash-3.00 # Note: You have logged on;
- Bash-3.00 # df-lh Note: view the mounting status of the file system;
- Filesystem capacity in use available % mount point
- /Dev/hda5 7.9G 5.9G 2.0G 76%/
- Proc 7.9G 5.9G 2.0G 76%/proc
- Sysfs 7.9G 5.9G 2.0G 76%/sys
The preceding command uses the chroot command to complete cross-console logon from one system to another. Livecd also completes this task. Now that we have logged on to the problematic system, we can perform corresponding repair work, such as restoring the root password, installing the software package, and modifying the corresponding file ...... I think you should know how to do it, right ???
Some release versions of the installation disk are similar to livecd, such as the first slackware installation disk. When it is started and asked you to enter the user name and password for installation, we do not have to enter anything, or directly enter the root, now we can access the cdrom virtual environment. In this case, we will use the mount file system mentioned above, and then the file system mounted by chroot;
4. postscript; Writing File System Management may take several days; efforts;
We can see that the Forum's brother is still calling for how to restore the root password. Although there are many documents in the Forum, most of them have not formed a system. To solve the problem, we will rewrite this article, some may need such a document; since there is a "market", I will write it. It is no big deal; some may think that it is a small masterpiece, so when I exercise well; there is no difficulty in writing such documents;
- A Brief Introduction to Linux rescue
- Linux-guided installation in GRUB Command Line Mode
- The support of common Linux file systems and storage devices is determined by the kernel.
- The System File rpm package required for Linux compilation and installation is used by me.
- Linux operating system Redhat series and Debian Series