centos6 / 7 boot failure troubleshooting

centos6 start the repair process:

Experiment 1: Delete initramfs-2.6.32-754.el6.x86_64.img recovery

This document is very important initramfs-2.6.32-754.el6.x86_64.img, as an important file to start the system, load the driver file system.

Post press esc to enter rescue mode

chroot / mnt / sysimage root switch

mkinitrd / boot / ininramfs-`uname -r`.img `uname -r` can repair this file

sync sync sync sync to disk

reboot

Experiment II: the destruction of the 446 byte sectors, repair

dd if=/dev/zero of=/dev/sda  bs=1 count=446

hexdump -C / dev / sda -n 512 -v first 446 bytes of the query has been destroyed

Restart Press esc to enter rescue mode

chroot / mnt / sysimage root switch

grub-install / dev / sda sda disk repair equipment

sync sync sync sync to disk

exit

reboot

Experiment three: Password crack centos6

1 Start grub interface

2 . Add a 1 input single-user mode

3. Press passwd to change the password

4 reboot

Add centos6 single-user mode password, you can not break:

grub-crypt

[Root @ centos6 ~] # grub-crypt command to create a password

Password: password

Retype password: password

 

$6$9M4MYaaShQLTXYAU$cIFuNc7SpKZw1NLCBG3/yoi6UHAWiMNxzBtDl3TGYzsmx3lRDjNRoRbNLEN8v8UsWldud2HHFRVqhbSFsqdly0

CD crack the code:

Enter rescue mode

chroot  /mnt/sysimage

vim /boot/gub/grub.conf comment out the line to passwd

reboot

 

Experiment 4: Remove grub.conf

1. Boot error jump directly to the grub interface to enter content:

kernel /vmlinuz-2.6.32-2754.e16.x86_64  root=/dev/sda2

initrd /initramfs-2.6.32-275.e16.86_64.img

2. Temporary into the machine

Then modify the configuration file, save a permanent fix:

vim /boot/grub/grub,conf

default=0

timeout=3

kernel /vmlinuz-2.6.32-2754.e16.x86_64  root=/dev/sda2

initrd /initramfs-2.6.32-275.e16.86_64.img

Save and exit, repaired.

Experiment 5: delete all files in the boot, disc repair needs

1. Press the esc reboot into recovery mode: to fix kernel boot-related files

mkdir / mnt / cdrom to mount a new temporary file

mount / dev / sr0 / mnt / cdrom mount the CD

rpm -ivh / mnt / cdrom / Packages / kernel .... --root = / mnt / sysimage (specify the installation path) --force (mandatory installation)

2. Fix grub file

chroot  /mnt/sysimage

grub-install /dev/sda

sync sync sync

3. Repair grub.conf file

vim /boot/grub/grub,conf

default=0

timeout=3

kernel / vmlinuz-2. kernel version File root = / dev / sda2

initrd /initramfs-...img file

Save and exit, repair is completed!

 

Experiment six: delete all files in the boot, and there is no / etc / fstab file, a disc repair

1. Restart Press esc to enter rescue mode

2.mkdir / mnt / rootfs mount a new temporary file

The devices are mounted, determining root root partition:

mount / dev / sda1 / mnt / rootfs determination / dev / sda1 boot partition is

mount  /dev/sda2  /mnt/rootfs   确定/dev/sda2为/分区

mount  /dev/sda3  /mnt/rootfs    确定/dev/sda3为 data分区

mount  /dev/sda5  /mnt/rootfs    确定/dev/sda5为swap 分区

3.最后确定/dev/sda2为根分区进行挂载

mount  /dev/sda2 /mnt/rootfs   挂载/dev/sda2设备

4.添加文件内容:

vim /mnt/rootfs/etc/fstab

/dev/sda1  /boot  ext4  defaults 0 0

/dev/sda2  /          ext4   defaults 0 0

/dev/sda3  /data   ext4  defaults  0  0

/dev/sda5 swap  swap  defaults  0  0

5.重启进入按esc救援模式:去修复内核启动相关文件

mkdir  /mnt/cdrom  新建临时挂载文件

mount /dev/sr0  /mnt/cdrom  挂载光盘

rpm -ivh /mnt/cdrom/Packages/kernel....  --root=/mnt/sysimage(指定安装路径)  --force(强制安装)

6.修复grub文件

chroot  /mnt/sysimage

grub-install /dev/sda

sync sync sync

7.修复grub.conf文件

vim /boot/grub/grub,conf

default=0

timeout=3

kernel /vmlinuz-2.版本内核文件   root=/dev/sda2

initrd /initramfs-...img文件

保存退出,修复完毕!

 

centos7故障修复流程:

第一种情况:

删除rm -rf /boot/grub2以下的文件进行修复:

1)进入救援模式:

2)然后切换根目录:

chroot /mnt/sysimage

3)生成grub2文件

grub2-install /dev/sda   

4)将grub.cfg启动配置文件生成

grub2-mkconfig  -o /boot/grub2/grub.cfg

5)sync  sync  sync sync  同步写入磁盘中

6)reboot就会修复。

第二种情况:

删除rm -rf /boot/下的文件进行恢复:

1)进入救援模式rescue

2)切换根目录:

chroot /mnt/sysimage

3)进行临时挂载

mount /dev/sr0  /mnt  

4)修复内核里边的相关启动文件

rpm -ivh /mnt/Packages/kernel-3.10.0-957.el7.x86_64.rpm --force

5)修复grub2文件内容

grub2-install /dev/sda

6)最后修复grub.cfg启动的相关配置文件

grub2-mkconfig -o /boot/grub2/grub.cfg

sync sync sync sync 写入磁盘保存

reboot重启。

 

centos7破解root口令方法之一:

1.启动是按任意键

2.按e键进入编辑模式

3.将光标移动到linux16开始的行,再行尾添加内核参数rd.break

4.按ctrl+x启动

5.查询当前挂载的跟:mount,得知当前挂载的在sysroot下

6.由于当前根只有只读,需要重新挂载修改权限:

mount -o remount,rw /sysroot  修改当前根权限

chroot /sysroot  切换根

passwd root  修改当前口令

touch ./autorelabel 开机之后selinux对每个文件重新进行贴标签

exit

reboot

破解CentOS7的root口令方法二

启动时任意键暂停启动
按e键进入编辑模式
将光标移动linux16开始的行尾,改为rw init=/sysroot/bin
按ctrl-x启动
chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot 

centos7加密,就无法破解密码:

grub2-setpassword   创建口令密码

[root@centos7grub]#cat /boot/grub2/user.cfg   保存口令位置

GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.978E5C106D6A102F6912FF51C37CE674483C0AAE52B84EC4DBB6C08AF818CE83BCA8A9743F31A72AA0BD0AB644A66D34AA774EEDDF913DE22C71A6C4A2826860.2B0701EF272ADE6E518EAA613F966F3C1F5C1150B2F61A04FCC34D2588A1FAB2F75922AB8A5DC5C02AA1A84F5EEE919F8C3DE5526FBCB46EA85082EE98CD6919

[root@centos7grub]#mv /boot/grub2/user.cfg /data   口令文件移动走之后,口令就会失效。

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/struggle-1216/p/11701455.html