Linux Common trouble Shooting fault error

Source: Internet
Author: User

Linux Common trouble shooting fault error

The program that you must run to back up the boot is very necessary for an OPS person. In the actual production environment, the system and data are basically installed on different hard disks, because the most concern of the enterprise is the data, the system crashes, the worst way is to reinstall the system, but the data is lost, it will directly bring losses to the enterprise, if the system and data are placed on the same hard disk, the system is not going to go, What to say about data. Solve common trouble shooting, do not in the system failure, think of the first is to re-install the system. In order to solve the common trouble shooting, we must first understand the system start-up process.

Common trouble shooting:

1. Faults with Grub

A) Loss of grub.conf configuration file

Fault System Information

When the system is powered on, a grub prompt appears, indicating that your grub profile is corrupted or has been lost.

Idea: In this case, the grub configuration file can be re-directly at the grub prompt.

How to know the mount point of the system root, generally used for rhel6.x version above, 5.x version does not need to specify the path of the root.

Insert Disc Select the third Rescue, first aid mode, or press ESC two times consecutively, enter Linux Rescue under the boot: prompt, and then press ENTER.

Select Local Disc

Select Continue, continue.

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

2) boot partition corruption

The system does not enter properly when the boot partition of the system is damaged

Train of thought 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 the bad boot partition of the system, install grub for this new hard disk, and copy the Vmlinuz kernel file, Initramfs kernel image file, and then build the Grub configuration file, Use the boot of this new hard drive to boot the system when the new hard drive is plugged into the host that damaged the boot partition

123456789101112131415161718192021222324252627282930313233 [[email protected] boot]# fdisk  /dev/sdb  #为新添加的磁盘分区Command (m forhelp): nCommand action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-2610, default 1314):Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):+50MCommand (m forhelp): w[[email protected] ~]# partprobe[[email protected] ~]#mkfs -t ext4 /dev/sdb1  #格式化分区[[email protected] ~]# mkdir /mnt/boot  #为新添加磁盘的分区建立一个挂载点[[email protected] ~]# mount /dev/sdb1 /mnt/boot/[[email protected] ~]# cd /mnt/boot/[[email protected] boot]# lslost+found[[email protected] boot]# grub-install --root-directory=/mnt /dev/sdb #为新添加的硬盘安装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 ifthis 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[[email protected] boot]# lsgrub  lost+found[[email protected] boot]# cp /boot/vmlinuz-2.6.32-358.el6.x86_64 /mnt/boot/  #复制系统盘的内核文件到新添加的盘[[email protected] boot]# cp /boot/initramfs-2.6.32-358.el6.x86_64.img  /mnt/boot/ #复制系统盘的内核镜像文件到新添加的盘[[email protected] boot]# lsgrub                                 lost+foundinitramfs-2.6.32-358.el6.x86_64.img  vmlinuz-2.6.32-358.el6.x86_64

After installing the Grub partition on the new hard disk, connect to the host that cannot be booted and boot.

Idea 2: Enter the first aid mode, install grub for the system, then mount the disc, copy the Vmlinuz kernel file inside the CD and the image file of the initrd.img kernel to the boot directory, and then manually edit the grub configuration file

123456789101112131415161718 #设置为光盘启动,进行Rescue模式bash-4.1#chroot /mnt/sysimagesh-4.1#mount /dev/cdrom /mediash-4.1#cd bootsh-4.1#grub-install --root-directory=/ /dev/sda  #为硬盘安装grubsh-4.1#cp /media/isolinux/vmlinuz /boot/vmlinuz-2.6.32-358.el6.x86_64 #复制光盘的内核文件,并改名sh-4.1#cp /media/isolinux/initrd.img /boot/initramfs-2.6.32-358.el6.x86_64.img #复制光盘的内核镜像文件,并改名sh-4.1#cat >> /boot/grub/grub.conf << EOF    #手动建立grub配置文件> 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#然后更改启动项,设置为本地硬盘启动

2./etc/inittab file lost

Idea: See if the Inittab file was installed by that RPM package, then go to emergency mode, mount the disc and reinstall RPM

12 [[email protected] ~]# rpm -qf /etc/inittab #查看RHEL5.x版本的inittab文件是由那个软件包安装的initscripts-8.45.42-1.el5

Insert disc into First aid mode

123456 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, bash corruption can not enter the login screen

Idea: To view bash commands installed by that RPM package, then go to emergency mode, mount the disc and reinstall RPM

123456 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. Forgotten root password

1),Grub is not encrypted, change root password

Enter single-user mode to set the password

2), add password to grub configuration file enable kernel image protection, change root password

3), enable grub edit protection, change the root password

5. MBR sector failure

MBR sector corruption of system boot disk

123 [[email protected] ~]# mkdir /mnt/backup[[email protected] ~]# mount /dev/sdb1  /mnt/backup/[[email protected] ~]# dd if=/dev/sda of=/mnt/backup/sda.mbr.bak bs=512 count=1 #备份系统盘的MBR扇区,一定是备份到另外的一块盘上面

Idea: Enter the first aid mode and restore the MBR sector of the previously backed up system disk.

123456 bash-4.1#chroot /mnt/sysimagesh-4.1#mkdir /dir #为备份有系统盘的MBR新建一个目录用于挂载sh-4.1#mount /dev/sdb1 /dir  #挂载带有备份文件的分区sh-4.1#dd if=/dir/sda.mbr.bak of=/dev/sda bs=512 count=1 #恢复备份数据sh-4.1#exitbash-4.1#reboot

6, repair the file system, repair the Inode node exception

12345678910111213 [[email protected]  /]# touch /mnt/backup/myfiletouch: cannot touch"/mnt/backup/myfile":device does not have space  #创建文件显示没有可用空间[[email protected] /]# df -lh /dev/sdb1  #查看磁盘显示还有空间Filesystem            Size  Used Avail Use% Mounted on/dev/sdb19.9G  780M  8.9G   9% /mnt/backup[[email protected]  /]# df -i /dev/sdb1 #查看inode节点,发现以没有可用inode节点Filesystem            Inodes   IUsed   IFree IUse% Mounted on/dev/sdb1 655776   655776    0    100% /mnt/backup[[email protected]  /]#  find /mnt/backup/ -empty -a -type f -exec rm -rf {} \; #删除该分区为空的文件[[email protected] /]# df -lh /dev/sdb1Filesystem            Size  Used Avail Use% Mounted on/dev/sdb19.9G  780M  8.9G   9% /mnt/backup[[email protected]  /]# touch /mnt/backup/myfile  #现在可以创建

As a qualified operation and maintenance personnel, the key files of the system should be done before the backup operation, in order to avoid "mend, too Late" situation occurs.

Linux Common trouble Shooting fault error

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.