Use of single user mode, repair mode, and cross-Console Logon in Linux System Repair
Author:North South
From:Linuxsir. org
Abstract: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:
Directory Index
1. single-user mode;
1. Use the grub System Boot manager for single-user logon;
2. Lilo Boot manager single-user mode;
Ii. Linux rescue repair mode;
3. log on to the Apsara stack console;
- 1. log on to the console through grub and Lilo boot;
- 1) if grub is used for system guidance;
- 2) if you use LILO for system boot;
- 2. Linux rescue;
- 3. Use Linux livecd CD or a third-party Linux system;
- 1) mount the file system;
- 2) chroot to the mounted file system;
Iv. postscript;
5. About this article;
6. Thank you;
VII. references;
8. related documents;
++ ++
Body
++ ++
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, the single-user mode also requires that your grub or lilo can work normally, and you know where your system problems occur. When you log on in single-user mode, you can open the write operation of the file system, and then perform the system repair 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 to this line and press the e key to edit the line. At the end of the line, enter a space and 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 editing. 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. However, the write operation on the file system may also look at the following;
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
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. However, the write operation on the file system may also look at the following;
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;
The following steps are required to perform the repair mode;
1. In bios, set the first boot drive to CDROM;
2. Find the first installation disk of the system, and put it into the CDROM. When the disc is running, the installation interface is displayed;
In Boot: Enter Linux rescue 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 to log on across the console, because you can log on to the system without password verification;
Cross-Console Logon 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 to this line and press the e key to edit the line. At the end of the line, enter a space and 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 editing. Press enter to return;
Next we need to start the system and press the B key to start it;
The system may be read-only. Run the following command;
# Mount-O remount, RW/
Then we can use DF-h to check the file system loading. Since all the file systems are mounted, What can't we do? Reset the root password and backup the file ......
For example, resetting 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, or use fdisk-L to view partitions. However, you can write data to the file system, you may want to see 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.
Let's give an example to illustrate how to use mount and chroot;
The use of third-party Linux and livecd on machines is relatively simple;
Livecd is the Linux operating on the CD. You can find a release version of livecd to burn it and use it easily;
:
Http://www.frozentech.com/content/livecd.php
Commonly used include slax, knoppix, damn small Linux, UBUNTU ......
Generally, you can download a small backup file. It depends on how you use it;
Use livecd Linux or other Linux to repair damaged Linux:
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 initialize 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 11g 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 it, it is mounted to the/root/strongmp 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, it works;
Note: During the write operation, you must be overwhelmed. When operating a file, you must 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
The Linux File System types are reiserfs, ext3, and ext2. The specific file system type is what you need. If you still don't know, try it 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 of them runs normally, and the other has some problems (for example, the root password is forgotten). I want to use a normal system to fix the other; the first step is to mount the file system, that is, the previous step is chroot, and 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 11g 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;
Iv. postscript;Writing File System Management may take several days;
5. About this article;
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;
6. Thank you;Thank you for writing the document;
VII. references;Man and help, too;
8. related documents;
- Published-
- Linux
- Basic knowledge