Linux rescue single-user mode Repair Mode

Source: Internet
Author: User
Tags virtual environment

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. 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;

1. single-user mode;

Linux rescue in single-user mode, there is also a premise 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 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 single end edit, press enter to return; then we want to start the system, press B to start; 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. 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 also look at the following: After a single user enters the system, the system may be read-only; to 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; mount the file system;

In fact, when we execute Linux rescue, there will be some prompts for systems such as Fedora. For example, if he prompts Which partition he wants to mount, we can just select it. When we execute the repair mode, the following steps are required;

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 enters the repair mode. What can we do ?? 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 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, 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. However, 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;

 
 
  1. [Root @ localhost ~] # Fdisk-l note: view the partition information;
  2. [Root @ localhost ~] # Pwd Note: determine the current working directory;
  3. /Root note: the current working directory is/root
  4. [Root @ localhost ~] # Mkdir upload MP Note: create a temporary directory under the current working directory;
  5. [Root @ localhost ~] # Mount/dev/hda5 into MP/Note: mount hda5 to the tmpsys directory;
  6. [Root @ localhost ~] # Df-h Note: Check whether the disk has been mounted;
  7. Filesystem capacity in use available % mount point
  8. /Dev/hda8 11 GB 9.8G 581 M 95%/
  9. /Dev/shm 236 M 0 236 M 0%/dev/shm
  10. /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, 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 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.

 
 
  1. [Root @ localhost ~] # Fdisk-l
  2. [Root @ localhost ~] # Pwd
  3. /Root
  4. [Root @ localhost ~] # Mkdir upload MP
  5. [Root @ localhost ~] # Mount/dev/hda5 initialize MP/
  6. [Root @ localhost ~] # Df-h
  7. Filesystem capacity in use available % mount point
  8. /Dev/hda8 11 GB 9.8G 581 M 95%/
  9. /Dev/shm 236 M 0 236 M 0%/dev/shm
  10. /Dev/hda5 7.9G 5.9G 2.0G 76%/root/batch MP
  11.  
  12. [Root @ localhost ~] # Chroot slave MP Note: chroot is in the hda5 partition system;
  13. Bash-3.00 # Note: You have logged on;
  14. Bash-3.00 # df-lh Note: view the mounting status of the file system;
  15. Filesystem capacity in use available % mount point
  16. /Dev/hda5 7.9G 5.9G 2.0G 76%/
  17. Proc 7.9G 5.9G 2.0G 76%/proc
  18. Sysfs 7.9G 5.9G 2.0G 76%/sys

On Linux rescue, we use 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 ???

Linux rescue some release versions of the installation disk are similar to livecd, such as the first slackware installation disk. When it is started, we do not have to enter anything when you enter the user name and password for installation, you can also directly enter root to enter the cdrom virtual environment. In this case, we will use the mount command to load the file system and then chroot to mount the file system;

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;

  1. Linux rescuev repair mode logon across the Console
  2. A Brief Introduction to Linux rescue
  3. Description of network interfaces and configuration tools in Linux ifconfig
  4. Linux vmware OS v adds the vmhgfs module to the kernel
  5. Linux Monitorix package uncovers zookeeper and modifies the Security Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.