Single-user mode Linux system, repair mode, cross-console login to use the system repair

Author: North-South-North
from: League of Legends Community
Abstract: This paper focuses on system repair, logging into the system in several ways; for example, when we forget the root password, or the system starts normally encounter difficulties, we can single-user mode , repair mode linux rescue and across the console login methods has finished loading the file system, log in, and then make the appropriate repair;

When the system is damaged, or trouble logging in, how can we enter the system? For example, we forget the root password, or the system can not boot properly, how to log into the system, the file system or how to back up important that we first thought transactions; below there are several ways for reference

Contents Index

A single-user mode;
1, grub to boot the system manager, a single user login method;
2, LILO boot manager single-user mode;

Two, linux rescue repair mode;

Third, across the console login;

Fourth, the postscript;
Fifth, on paper;
Six, thanks;
Seven, reference documentation;
Eight, related documents;


++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
text
+++++++++++++++++++++++++++++++++++++++++++ +++++++++++++


A single-user mode;

Single-user mode requires us to enter the root user's password, or you can not log in single user mode; if you lose your root user's password, do not use single-user mode to reset your root password;

In addition there is a single-user mode as long as your grub or lilo is able to work properly; and you know that your system where the problem occurs, when you log in single-user mode, you can open the file system writes, and then You want to fix the system;

Some brothers might say, "I really do not know which place the system out of the question," Oh, if you really do not know, I can not do anything, because this document covers registration mode, not about how to repair the system;


1, grub to boot the system manager, a single user login method;

After grub boot, to move the keyboard Linux boot entry; Press e; then moved to a keyboard similar to the following line, the line is the kernel:

kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/1 rhgb quiet 

After moving the cursor line, then click the e key to enable this line; end of the line a space bar, 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

Finish editing, press Enter to return;

Then we have to start the system, press the b key to boot;

When entering single-user mode, the system prompts us to enter the root password; enter the correct system will enter; you can use df -h to view the file system mount location, you can also use fdisk -l to view the partition and so on; but write to the file system, may depend on the following;

After a single user into the system, the system may be read-only; to run the following command;

#mount -o remount,rw /


2, lilo boot manager single-user mode;

Input: the boot

linux single

When entering single-user mode, the system prompts us to enter the root password; enter the correct system will enter; you can use df -h to view the file system mount location, you can also use fdisk -l to view the partition and so on; but write to the file system, may depend on the following;

After a single user into the system, the system may be read-only; to run the following command;

#mount -o remount,rw /


Two, linux rescue repair mode;

Linux repair mode is linux rescue; repair mode does not require a system password, after entering repair mode, the system will prompt the file system on which partition we want to mount our own system according to the situation select it wants to. After registration is completed, the system will prompt the partition of the file system will be mounted which directory; if you do not know where to mount, please df -h to see;

Repair mode requires the first independent repair disk or installation disk; such as Fedora have specialized repair disk; in fact similar livecd repair disk in a certain sense, it is not necessary to install to the hard disk can also run the system; then mount to mount the file system; in fact, when we execute linux rescue, such as Fedora system, there will be some tips, for example, he notes that he which partition to mount, we chose to look on the line;

When you perform a repair mode, the following steps;

First: In the BIOS, set the first boot drive is CDROM;
Second; to find the first system installation disk; into the CDROM; When the disc is running, you will be prompted to install the interface;

The boot: the rear input linux rescue, and then press ENTER;

boot:linux rescue

Repair mode, what can we do about it? ? What can be done, such as mounted usb disk data backup; modify system configuration files ... ... reset the root password to mount file systems ... ... just can think of, most can be completed;


Third, across the console login;

The real leap console login is not required to enter the root password, if you have the root password is lost, you should expect across the console login; we said before linux rescue in essence, is across the console login, because there is no need password authentication will be able to log into the system;

Login across the console include: borrow grub and lilo across the console login; linux rescue mode; livecd third-party systems and third-party Linux systems;

1, through grub and lilo boot across the console log in;


1) If you are using grub system boot;

After grub boot, to move the keyboard Linux boot entry; Press e; then moved to a keyboard similar to the following line, the line is the kernel:

kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/1 rhgb quiet 

After moving the cursor line, then click the e key to enable this line; end of the line a space bar, 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 init=/bin/bash

Finish editing, press Enter to return;

Then we have to start the system, press the b key to boot;

The system may be read-only; you want to run the following command;

#mount -o remount,rw /

Then we can load the situation to see -h file system by df; now regard the file system is mounted, what living can not do it? Reset root password, the backup file ... ...

For example root password reset;

#passwd


2) If you are using lilo boot the system;

Input: the boot

boot:linux init=/bin/bash

When entering the system, you can use df -h to view the file system mount location, you can also use fdisk -l to view the partition and so on; but write to the file system, may depend on the following;

may only system reading; to run the following command;

#mount -o remount,rw /


2、linux rescue ;

Please refer to the aforesaid second point repair mode;


3, by the livecd linux linux CD or a third-party system;

livecd linux version is no need to install linux system, linux system on the disc can run; livecd is mostly used for repair purposes, livecd integrates commonly used operating system tools;

Linux system is a third party on your machine to install more than one Linux system, if one occurs, we can use another to repair;

linux livecd and third-party systems to repair already damaged Linux, commonly used tools mount and chroot and so on; if you simply change the file system problems, with the mount is sufficient. chroot tool may change /, and then into another system, this is indeed a useful tool.

We give you an example to illustrate how to mount and chroot;

As for third-party Linux machine and Livecd is relatively simple to use, there is not much to say;

livecd linux is running on a disc, you can find a livecd release version will be able to burn it to use, easy to use;

Download:

http://www.frozentech.com/content/livecd.php

Commonly used SLAX, Knoppix, Damn Small Linux, Ubuntu ... ...

Generally are similar, downloading a small spare also, to see how your use;

To repair the damage already by livecd linux linux Linux or other steps are as follows:

. 1) Mount mount a file system;

Note: When you perform mount and chroot, to be run as root, following the same;

For example, there is a problem of the system is located in / dev / hda5, if you do not know which partition is linux, you can fdsik -l to see;

[root@localhost ~]# fdisk -l 注:查看分区情况;
[root@localhost ~]# pwd   注:确定当前工作目录;
/root                     注:当前工作目录为/root
[root@localhost ~]# mkdir systmp 注:在当前工作目录下创建一个临时目录;
[root@localhost ~]# mount /dev/hda5 systmp/ 注:挂载hda5到tmpsys目录中;
[root@localhost ~]# df -h   注:查看是否已经挂载;
Filesystem            容量  已用 可用 已用% 挂载点
/dev/hda8              11G  9.8G  581M  95% /
/dev/shm              236M     0  236M   0% /dev/shm
/dev/hda5             7.9G  5.9G  2.0G  76% /root/systmp  注:看好了,是挂载到了/root/systmp目录中;

Since the / dev / hda5 partition file system has been mounted, and we can already mounted file system write; if it is a simple backup and file modification, is entirely can do it;

Note: During a write operation, not to be doubly heart, when a file operation, first back up; when the situation can not mount appears, may be used in your current kernel does not support the appropriate file system; if the system when asked to specify the file systems, see the following example;

Mount -t type of file system partition mount destination directory

For file system type linux mainly: reiserfs, ext3, ext2; specifically what type of file system used, you know best; if you still do not know, one by one try; such as my hda5 is reiserfs, you can use the following command to mount;

[root@localhost ~]# mount -t reiserfs   /dev/hda5 systmp/


2) chroot to the file system has been mounted;

chroot This tool is useful, a lot of Linux support chroot to switch to another file system, and then a series of system installation and system configuration packages; This is not to say that any file system can chroot cut, first of all have to have the file system the system is running certain tools and environments, such as / bin and / sbin directories are owned and so on ....

Expression in Chinese unclear, or for example described;

For example, my machine has two Linux systems, a functioning, another little problem (such as root password is forgotten), I would like to fix another through the normal system; First of all we are mount, which is in front of the say, then the next step is chroot; switch to the file you want to repair the system via chroot;

Problems such as the system is located in / dev / hda5

[root@localhost ~]# fdisk -l 
[root@localhost ~]# pwd  
/root                    
[root@localhost ~]# mkdir systmp
[root@localhost ~]# mount /dev/hda5 systmp/ 
[root@localhost ~]# df -h   
Filesystem            容量  已用 可用 已用% 挂载点
/dev/hda8              11G  9.8G  581M  95% /
/dev/shm              236M     0  236M   0% /dev/shm
/dev/hda5             7.9G  5.9G  2.0G  76% /root/systmp  

[root@localhost ~]# chroot systmp   注:chroot到hda5分区的系统中;
bash-3.00#     注:已经登录;
bash-3.00# df -lh   注:查看文件系统挂载情况;
Filesystem            容量  已用 可用 已用% 挂载点
/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

Above we completed the cross-console login via one system to another system via chroot command; Livecd To complete this task, but also through such process is complete.

Since we are already logged into the system in question, you can make the appropriate repair work, such as restoration of root password to install the package, the corresponding file modification ... ... I think you should know how to do, right ? ? ?

Some distributions installation disk similar livecd, such as the first installation disk slackware when he starts to let you enter a user name and password during installation, we do not have any input or direct input root, you can enter a virtual environment cdrom ; then we said earlier mount loaded with file system, then chroot mounted file system;

Fourth, the postscript; writing file management system, it may take a few days; in effort;

Fifth, on paper;

The forum also saw the brothers shouted lost root password how to recover, although the altar, there are many documents, but mostly no system, in order to solve the problem and rewrite the article, some brothers may require such a document; since there "market", I wrote, no big deal; some brothers thought to be making a fuss, when I exercise good; who would write such a document, there is no difficulty;

VI Acknowledgments; this time to thank myself about it, because I still insist on writing documents; to add more fuel; ha ha;

Seven, reference documentation; man and help it; brother, you will;

Eight, the relevant documents;

Reproduced in: https: //www.cnblogs.com/licheng/archive/2008/01/21/1047457.html

Guess you like

Origin blog.csdn.net/weixin_33724570/article/details/92630658