CentOS6.4 system startup failure troubleshooting
If the operating system fails to start, the following error occurs:
Fault symptom:
As you can see, fsck encountered an error while performing file system detection during operating system startup and an error occurred while checking/dev/mapper/VolGroup-lv_home, prompting that this file does not exist;
Fault analysis:
What is this interface, why does it appear?
The general process of operating system startup is: loading BootLoader-à loading kernel-à init to execute system initialization-à user login; while in the process of init to execute system initialization, will execute the system initialization script/etc/rc. d/rc. sysinit: In this script, fsck-A is executed for file system detection;
What operations will fsck-A perform?
Fsck-A traverses the file/etc/fstab and checks all the file systems defined in it. Fsck usually does not check whether the device actually exists before checking the file system. Therefore, if a device does not exist and fsck is executed, fsck will report an error, in this case, the operating system enters the file system repair mode, and the normal system startup is interrupted;
Therefore, this is why this interface appears.
Solution:
Since the fsck fails to be executed, the operating system cannot continue to start. Therefore, when the operating system is started, let fsck skip and check the problematic/dev/mapper/VolGrouplv_home to start the operating system properly. (in/etc/fstab, set the value of fs_passno in this field to 0, that is, fsck does not check this row)
However, in file system repair mode, all files are read-only and cannot be edited. Therefore, you can choose to start from the system disk, select to go to emergency rescue mode and modify the file (because the file will not be executed in emergency repair mode/etc/rc. d/rc. sysinit, so this error is not reported );
123bash-4.1 # chroot/mnt/sysimagesh-4.1 # vim/etc/fstab # Set the 6th fields in the/dev/mapper/VolGrouplv_home row to 0sh-4.1 # reboot-r
At this point, the system can be started normally, but the following interface will be displayed in the middle:
There is no fsck error at this time, but there is a failed message when mounting the file system, because the system initialization script/etc/rc. d/rc. in sysinit, the next step after the file system detection is to mount the file system;
And from this interface can clearly see the problem,/dev/mapper/VolGroup-lv_home does not exist; although the failed information, but does not affect the system can continue to start;
In the green circle, you need to wait for SELinux to automatically complete the re-marking. If you do not want to wait, you can disable the edit mode when the system starts. For example:
--------------------------------------------------------------------
Now the operating system can be started. You need to introduce the background. This system is installed according to the default partition layout (partitioning layout), for example:
A hard disk sda is divided into two partitions: sda1 and sda2. sda2 is made into a physical volume. The volume group created based on this physical volume is named VolGroup, and three logical volumes are created on this volume group, the logical volumes lv_root, lv_home, and lv_swap are mounted to the/directory and/home directory of the file system respectively;
So in the previous article/dev/mapper/VolGroup-lv_home is the logical volume automatically created by the system attached to/home; for example, due to misoperations (umount, lvremove), the logical volume is deleted, then, when you restart your computer, an error is reported at the beginning.
Certificate --------------------------------------------------------------------------------------------------------------------------------------
Now that the operating system has started to log on and you know the problem, how can we restore this logical volume next?
In this case, the logical volume is deleted;
1234567 [root @ mysqlhost1 ~] # LvsLVVGAttrLSizePoolOriginData % MoveLogCpy % SyncConvertlv_rootVolGroup-wi-ao --- 50.00glv _ swapVolGroup-wi-ao --- 992.00 m [root @ mysqlhost1 ~] # Ll/dev/VolGroup/lrwxrwxrwx1rootroot7 October 22 20: 27lv_root-> ../dm-0lrwxrwxrwx1rootroot7 October 22 20: 27lv_swap-> ../dm-1
Because the logical volume is attached to the/home directory and the logical volume is lost, are the data in the/home directory also lost? How to restore the original data in the/home directory?
Lvremove deletes a logical volume. It only clears some metadata information (metadata) of the LVM, and the real data is still completely retained. That is, although the logical volume lv_home is deleted, however, the data in/home still exists, but it is not visible now;
In addition, the menter configuration means that before any changes are made to the physical volume, volume group, or logical volume of the LVM, the metadata of the LVM is automatically saved to the/etc/lvm/archive directory;
Therefore, we only need to restore the metadata of the LVM that is automatically backed up before the logical volume lv_home is deleted. The logical volume lv_home can be automatically restored and then remounted, you can view the original data in the/home directory;
123456 # view metadata backup information related to the volume group VolGroup [root @ mysqlhost1 ~] # Vgcfgrestore -- listVolGroupFile:/etc/lvm/archive/VolGroup_00001-560861966.vgVGname: VolGroupDescription: Created * before * executing 'lvremove/dev/VolGroup/lv_home 'BackupTime: WedOct2217: 33: 172014
The results show that the metadata of the volume group is automatically backed up to the file/etc/lvm/archive/VolGroup_00001-560861966.vg before 'lvremove/dev/VolGroup/lv_home 'is executed.
1234567891011121314 # restore the metadata of the volume group VolGroup from the corresponding file [root @ mysqlhost1 ~] # Vgcfgrestore-f/etc/lvm/archive/VolGroup_00001-560861966.vgVolGroupRestoredvolumegroupVolGroup # Now you can see this logical volume lv_home [root @ mysqlhost1 ~] # LvscanACTIVE '/dev/VolGroup/lv_root' [inherit] inheritinactive '/dev/VolGroup/lv_home' [108.54GiB] inheritACTIVE '/dev/VolGroup/lv_swap' [992.00MiB] inherit ## activate this logical volume [root @ mysqlhost1 ~] # Lvchange-ay/dev/VolGroup/lv_home [root @ mysqlhost1 ~] # LvscanACTIVE '/dev/VolGroup/lv_root' [50.00GiB] inheritACTIVE '/dev/VolGroup/lv_home' [108.54GiB] inheritACTIVE '/dev/VolGroup/lv_swap' [992.00MiB] inherit123456 # restore the changes just made in/etc/fstab [root @ mysqlhost1 ~] # Vi/etc/fstab # remount [root @ mysqlhost1 ~] # Mount-a # the original data in the/home directory can also be viewed in [root @ mysqlhost1 ~] # Ls/home