Troubleshooting of Common trouble shooting in Linux

Source: Internet
Author: User

Troubleshooting of Common trouble shooting in Linux

It is necessary for an O & M personnel to back up the programs that must be run at startup. In the actual production environment, the system and data are basically installed on different hard disks, because enterprises are most concerned about data and the system crashes. The worst way is to reinstall the system, however, if the data is lost, it will directly cause losses to the enterprise. If both the system and the data are placed on the same hard disk, the system will not be able to enter. To solve the Common trouble shooting, do not reload the system when the system fails. To solve common trouble shooting problems, you must first understand the system startup process.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS54V6-0.png "title =" 1.png"/>


Common trouble shooting:

1. grub faults

A) the configuration file of grub. conf is lost.

Fault System Information

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS52621-1.png "title =" 2.png"/>

When the system starts up, the grub prompt appears, indicating that your grub configuration file is damaged or has been lost.

Idea: in this case, you can directly go to the grub prompt and re-configure the grub file.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS53P7-2.png "title =" 3.png"/>

How to know the mount point of the system root is generally used in the RHEL6.x version, and the 5.x version does not need to specify the root path.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS53394-3.png "title =" 4.png"/>

Select the third Rescue for the disc to be inserted, the first aid mode, or press Esc twice consecutively. Enter the linux rescue at the boot: prompt and press Enter.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS5GY-4.png "title =" 5.png"/>

Select Local CD

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS51J6-5.png "title =" 6.png"/>

Select Continue to Continue.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS54242-6.png "title =" 7.png"/>

After entering the emergency mode, the system will mount your real root system to the/mnt/sysimage directory, if you want to switch to the real root choot/mnt/sysimage

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS533O-7.png "title =" 8.png"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS53H4-8.png "title =" 9.png"/>

2) The boot partition is damaged.

When the boot partition of the system is damaged, the system cannot enter normally.

Idea 1: Use a new hard disk to access the host that can enter the system, and the kernel version information of the host must be the same as that of the system boot partition. Install grub for the new hard disk, copy the vmlinuz Kernel File, initramfs kernel image file, and create a grub configuration file to connect the new hard disk to the host that damaged the boot partition, use the boot of the new hard disk to boot the system.


[Root @ Redhat6 boot] # fdisk/dev/sdb # Command (m for help): nCommand action e extended p primary partition (1-4) for the Newly Added Disk partition) pPartition number (1-4): 1 First cylinder (1-2610, default 1314): Last cylinder, + cylinders or + size {K, M, G} (1-2610, default 2610): + 50 MCommand (m for help): w [root @ Redhat6 ~] # Partprobe [root @ Redhat6 ~] # Mkfs-t ext4/dev/sdb1 # format the partition [root @ Redhat6 ~] # Mkdir/mnt/boot # create a mount point for the Newly Added Disk Partition [root @ Redhat6 ~] # Mount/dev/sdb1/mnt/boot/[root @ Redhat6 ~] # Cd/mnt/boot/[root @ Redhat6 boot] # lslost + found [root @ Redhat6 boot] # grub-install -- root-directory =/mnt/dev/sdb # New install grubProbing devices to guess BIOS drives. this may take a long time. installation finished. no error reported. this is the contents of the device map/mnt/boot/grub/device. map. check if this is correct or not. if any of the lines is incorrect, fix it and re-run the script 'grub-install '. (fd0)/dev/fd0 (hd0)/dev/sda (hd1) /dev/sdb [root @ Redhat6 boot] # lsgrub lost + found [root @ Redhat6 boot] # cp/boot/vmlinuz-2.6.32-358.el6.x86_64/mnt/boot/# copy the kernel file of the system disk to add disk [root @ Redhat6 boot] # cp/boot/initramfs-2.6.32-358.el6.x86_64.img/mnt/boot/# copy the kernel image file of the system disk to the Newly Added Disk [root @ Redhat6 boot] # lsgrub lost + foundinitramfs-2.6.32-358.el6.x86_64.img vmlinuz-2.6.32-358.el6.x86_64


After the grub partition is installed on the new hard disk, it is connected to a host that cannot be started for boot.


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS52520-9.png "title =" 11.png"/>


Idea 2: Enter the First Aid mode, install grub for the system, mount the CD, and run the vmlinuz Kernel File and initrd in the CD. copy the image file of the img kernel to the boot directory and manually edit the grub configuration file.

# Set to start the CD, rescue mode bash-4.1 # chroot/mnt/sysimagesh-4.1 # mount/dev/cdrom/mediash-4.1 # cd bootsh-4.1 # grub-install -- root-directory = // dev/sda # For Hard Disk install grubsh-4.1 # cp/media/isolinux/vmlinuz/boot/vmlinuz-2.6.32-358.el6.x86_64 # copy the CD Kernel File, and renamed sh-4.1 # cp/media/isolinux/initrd. img/boot/initramfs-2.6.32-358.el6.x86_64.img # copy the kernel image file on the CD and rename it sh-4.1 # cat>/boot/grub. conf <EOF # manually create the grub Configuration File> default = 0> timeout = 5> title CentOS (2.6.32-358. el6.x86 _ 64)> root (hd0, 0)> kernel/vmlinuz-2.6.32-358.el6.x86_64 ro root =/dev/mapper/vg0-root> initrd/initramfs-2.6.32-358.el6.x86_64.img> EOFsh-4.1 # exitbash-4.1 # reboot # Then change the boot item, set as local hard disk boot


2. the/etc/inittab file is lost.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS5J31-10.png "title =" 13.png"/>

Idea: Check that the inittab file was installed by the rpm package, and then enter emergency mode. Mount the disc and reinstall the rpm.

[Root @ Redhat5 ~] # Rpm-qf/etc/inittab # view RHEL5.x the inittab file is the initscripts-8.45.42-1.el5 installed by that package

Insert a CD to the emergency mode

bash-4.1#chroot /mnt/sysimagesh-4.1#mount /dev/cdrom /mediash-4.1#cd /media/Packages/sh-4.1#rpm -ivh --replacepkgs initscripts-8.45.42-1.el5.rpmsh-4.1#exitbash-4.1#reboot

3. Enter the logon page if bash is damaged.

Idea: Check that the bash command was installed by the rpm package, and then enter emergency mode. Mount the disc and reinstall the rpm.

bash-4.1#chroot /mnt/sysimagesh-4.1#mount /dev/cdrom /mediash-4.1#cd /media/Packages/sh-4.1#rpm -ivh --replacepkgs bash-4.1.2-14.el6.x86_64.rpmsh-4.1#exitbash-4.1#reboot


4. Forget the root password

1) grub is not encrypted. Modify the root password.

Set the password in single-user mode.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS51447-11.png "title =" 21.png"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS5FP-12.png "title =" 22.png"/>


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS5BM-13.png "title =" 23.png"/>

2) Add the password to the grub configuration file to enable kernel image protection and change the root password.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS5J62-14.png "title =" 25.png"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS51G2-15.png "title =" 27.png"/>

3) Enable grub editing protection and change the root password

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS55L0-16.png "title =" 28.png"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1GS520W-17.png "title =" 30.png"/>


5. MBR sector failure

The MBR sector of the system boot disk is damaged.

[Root @ Redhat6 ~] # Mkdir/mnt/backup [root @ Redhat6 ~] # Mount/dev/sdb1/mnt/backup/[root @ Redhat6 ~] # Dd if =/dev/sda of =/mnt/backup/sda. mbr. bak bs = 512 count = 1 # back up the MBR sector of the system disk, which must be backed up to another disk.

Idea: Go to the emergency mode and restore the MBR sector of the system disk that was previously backed up.

Bash-4.1 # chroot/mnt/sysimagesh-4.1 # mkdir/dir # create a directory for the MBR with the backup system disk for mounting sh-4.1 # mount/dev/sdb1/dir # mount with backup file partition sh-4.1 # dd if =/dir/sda. mbr. bak of =/dev/sda bs = 512 count = 1 # restore backup data sh-4.1 # exitbash-4.1 # reboot

6. Fix the file system and inode node exceptions.

[Root @ Redhat6/] # touch/mnt/backup/myfiletouch: cannot touch "/mnt/backup/myfile ": device does not have space # No available space is displayed when the file is created [root @ Redhat6/] # df-lh/dev/sdb1 # Check whether the disk shows space Filesystem Size Used Avail Use % Mounted on /dev/sdb1 9.9G 780 M 8.9G 9%/mnt/backup [root @ Redhat6/] # df-I/dev/sdb1 # view inode nodes, no inode node is available. Filesystem Inodes IUsed IFree IUse % Mounted on/dev/sdb1 655776 655776 0 100%/mnt/backup [root @ Redhat6/] # find/mnt/backup /- empty-a-type f-exec rm-rf {}\; # delete an empty file [root @ Redhat6/] # df-lh/dev/sdb1Filesystem Size Used Avail Use % Mounted on/dev/sdb1 9.9G 780 M 8.9G 9% /mnt/backup [root @ Redhat6/] # touch/mnt/backup/myfile # Now you can create

As a qualified O & M personnel, the key files of the system should be backed up in advance to avoid the occurrence of "it is too late to make up for it.








This article is from the "technical path-NLP" blog, please be sure to keep this source http://litaotao.blog.51cto.com/6224470/1263946

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.