Linux Troubleshooting (ii) Changing the root password and repairing the file system

Source: Internet
Author: User

Linuxfault Handling (ii) ChangeRootPassword and repair file system

First, forget Root User's password

most of the time Linux the host has Root There is only one user for permissions, so there are other ways to reset Root account password. The simplest approach is to enter single-user mode by modifying the GRUB boot parameters at boot time, and the other way is to use the system CD to enter the first aid mode.

1 , reset via single user mode Root password for the account

steps are as follows

1 ), reboot the host, and GRUB menu, press "↑", "↓" arrow keys to cancel the countdown and navigate to the operating system selection to enter, press e key to enter edit mode.


2 ), navigate to the Kernel start with a row and press e key, add at the end of the line Single "The startup parameters, where" Single "can also be converted into letters" s "or number" 1 ", you can also indicate entry into single-user mode.


3 ), after the loss, press Enter key to confirm, press b key to boot the system into single-user mode, directly into Shell Environment (no password authentication is required).


4 ), in single-user mode Shell environment, you can perform the " passwd the command is reset Root the user's password. Reboot the system after Setup.


Second, the exclusion of file system class failure


1 , repair file system

When the file system's Super block data is corrupted, Linux the file system will not be recognized, and the mount will appear " You must specify the filesystem type "is not used properly.

For example, performing the following actions can destroy /DEV/SDB1 The file system's super-block database will not succeed when trying to mount.

[[email protected] ~]# dd If=/dev/zero of=/dev/sdb1 bs=512 count=4 recorded 4+0 read write 2048 bytes (4+0 KB) copied, 0.024955 seconds, 2.0 kb /sec [[email protected] ~]# mount/dev/sdb1/tmp/mount:you must specify the filesystem type


for passing /etc/fstab file is automatically mounted and set fsck Parameters (Section 6 Column non- 0 ) file system, if there is an error in the Super block, linux The system will error when booting, and prompt" give root password for maintenance

When this occurs, follow the prompts to enter Root user Password, you can enter a temporary Shell environment where users can fix the file system where the error occurred. you can exit and restart the system by executing the "exit" command after the repair is complete.


fixed a general file system error that can be used " fsck "command, combine" - T "option specifies the file system type, combined with the" - y "option to automatically answer questions found" Yes ".

Mount it again, and it can be mounted successfully!


2 , disk resource exhaustion failure

when a file system is running out of disk space, you will not be able to continue creating new file data in that partition, causing the failure to occur. For example, execute the "dd if=/dev/zero of=/somefile bs=1m count=999999" command. When there is not enough disk space in the root partition to boot into the Linux System, you can enter the first aid mode through the system's installation CD, and transfer or clean up the files that occupy a large amount of space in the root partition.

in each of the ext3 File system, the number of files that can be used (corresponding I number of nodes) is also limited. When a file system is formatted, the number of nodes I have is the number of files that have been fixed. This can happen if the user creates a huge amount of small files (draining the I node) in the partition : Although there is still a lot of disk space remaining in the partition, no new files can be created.

Simulation I node exhaustion Failure

2.1 ), create a new 1G size of EXT4 file system, mounting to /temp directory. Use the "df–i" command to confirm the use of the I nodein the file system .

[Email protected] ~]# mkdir/temp[[email protected] ~]# mount/dev/sdb1/temp/[[email protected] ~]# df-i/temp/filesys TEM inodes iused IFree iuse% mounted on/dev/sdb1 66384 one 66373 1%/temp Filesystem: File system inode:i node total Number iused: (i) used IFree: (i) available iuse%:% mounted on: mount point


2.2 ), write a test program script, simulate I node Exhaustion

[Email protected] ~]# vim mkfile.sh#!/bin/bashi=1while [$i-le 66384]dotouch/temp/file$ilet i++done[[email protected]  ~]# sh mkfile.sh[[email protected] ~]# df-i/temp/filesystem inodes iused IFree iuse% mounted ON/DEV/SDB1 66384 66384 0 100%/temp

you can see that the number of I nodes is already full, and then use the df–ht command to view disk space. and create a file to view the information.


2.3 ), view results

[Email protected] ~]# df-ht/temp/filesystem Type Size used Avail use% mounted on/dev/sdb1 ext2 1020M 2.8M 965M 1%/temp can see,/temp still have a lot of disk space [[email protected] ~]# Touch/temp/123456touch: Unable to create "/temp/123456": No space on device

Create a file hint on the device is not, this situation is usually the I node exhaustion


2.4 ), repair I node exhaustion Failure

after understanding the root knot of the I node failure, the problem is better solved. Just find the small files in the partition that occupy a large number of i nodes and transfer or delete them. For file systems that are common to many users, it is recommended that you set disk quota limits (including both disk space and number of files) for the relevant users.

[Email protected] ~]# rm-rf/temp/file*[[email protected] ~]# df-i/tempfilesystem inodes iused IFree iuse% Mounted ON/DEV/SDB1 66384 66374 1%/temp


3 , detect hard drive bad channel

The bad path of the disk is divided into logical bad and physical bad, the former mainly due to improper software operation, you can use software repair, the latter is physical damage, can only be changed by changing the disk partition or sector occupied location to improve, excluding the disk space containing the bad block. The disk device emits an abnormal sound when the following behavior occurs on the disk.

The disk device makes an abnormal sound when it reads data from the disk.

When accessing a file on the disk, it is repeatedly read and error, prompting for file corruption.

The format cannot be completed for the newly created partition.

The system frequently freezes when it uses the disk.

After a bad drive, if not replaced in time or technical processing, the bad road will be more and more, and may cause frequent crashes and data loss consequences. Therefore, it is necessary to check the disk periodically to see if there is a bad path.

in the Linux in the system, the bad track condition of the detected disk can be used Badblocks command, combined with " - S "option to display progress information," - v option to display the details.

[[email protected] ~]# badblocks-sv/dev/sdb checking blocks from 0 to 20971519 checking for bad blocks (read-only test): Complete Pass completed, 0 bad blocks found.


in the long-term use of the computer process, the file system and the disk class fault phenomenon is difficult to completely avoid, the repair of such failures need to be very cautious, if the operation inadvertently may add to the extent of data corruption .



Linux Troubleshooting (ii) Changing the root password and repairing the file system

Related Article

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.