linux——系统排错之引导恢复shell
生活随笔
收集整理的這篇文章主要介紹了
linux——系统排错之引导恢复shell
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、grub 磁盤引導階段
MBR
mbr 的作用是為了記錄 /boot 目錄所在分區位置,磁盤的 0 磁道 1 扇區的前 446 字節
[root@localhost Desktop]# fdisk -l Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00000000Device Boot Start End Blocks Id System /dev/vda1 * 2048 20970332 10484142+ 83 LinuxDisk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost Desktop]# dd if=/dev/zero of=/dev/vda bs=446 count=1 1+0 records in 1+0 records out 446 bytes (446 B) copied, 0.000137605 s, 3.2 MB/s [root@localhost Desktop]# reboot重啟后的操作如下圖:
上圖過后,還有一個選擇,也是選擇OK,就會進入下圖界面
二、grub 文件引導階段
當你用命令 rm -fr 誤刪除了/boot/grub2/grub.cfg文件時,介紹兩種恢復方法。
1. 當發現誤刪除該文件后,如果你還沒有重啟系統的話,那么恭喜你,這很好恢復,如下操作:
[root@localhost Desktop]# rm -fr /boot/grub2/grub.cfg [root@localhost Desktop]# grub2-mkconfig > /boot/grub2/grub.cfg ? ?##因為文件grub2-mkconfig里的內容與刪掉的文件內容一樣 Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-946cb0e817ea4adb916183df8c4fc817 Found initrd image: /boot/initramfs-0-rescue-946cb0e817ea4adb916183df8c4fc817.img done [root@localhost Desktop]# ? ?##恢復文件成功 2.?當發現誤刪除該文件后,如果你已經重啟系統的話,那就好好的跟著下圖的操作做吧操作截圖:
注意:進入系統后,一定要執行下面的命令!!!不然下次還需要重新引導
三、內核引導階段(一)
錯誤執行 rm -fr vmlinuz-3.10.0-123.el7.x86_64 該條命令后
1. 若還沒有重啟系統,可做如下操作恢復
四、內核引導階段(二)
錯誤執行 rm -fr /boot/initramfs-3.10.0-123.el7.x86_64.img 該條命令后
[root@localhost boot]# rm -fr /boot/initramfs-3.10.0-123.el7.x86_64.img [root@localhost boot]# mkinitrd /boot/initramfs-3.10.0-123.el7.x86_64.img 3.10.0-123.el7.x86_64 [root@localhost boot]# ls config-3.10.0-123.el7.x86_64 grub grub2 initramfs-0-rescue-946cb0e817ea4adb916183df8c4fc817.img initramfs-3.10.0-123.el7.x86_64.img initrd-plymouth.img symvers-3.10.0-123.el7.x86_64.gz System.map-3.10.0-123.el7.x86_64 vmlinuz-0-rescue-946cb0e817ea4adb916183df8c4fc817 vmlinuz-3.10.0-123.el7.x86_64 [root@localhost boot]# ? ? ? ? ? ? ?##恢復成功 2. 若已經重啟了系統,那么接下來的操作如下圖:
五、啟動級別被改變后所引起的系統問題
啟動級別設置
systemctl set-default + 啟動級別
此時的操作如下圖所示:
注意:進入系統后,一定要執行下面的命令!!!不然下次還需要重新設置
[root@localhost Desktop]# systemctl set-default graphical.target rm '/etc/systemd/system/default.target' ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target' [root@localhost Desktop]#系統啟動級別介紹
runlever0.target -> poweroff.target runlever1.target -> rescue.target runlever2.target -> multi-user.target runlever3.target -> multi-user.target runlever4.target -> multi-user.target runlever5.target -> grapical.target runlever6.target -> reboot.target運行級別0:系統停機狀態,系統默認運行級別不能設為0,否則不能正常啟動運行級別1:單用戶工作狀態,root權限,用于系統維護,禁止遠程登陸
運行級別2:多用戶狀態(沒有NFS)
運行級別3:完全的多用戶狀態(有NFS),登陸后進入控制臺命令行模式
運行級別4:系統未使用,保留
運行級別5:X11控制臺,登陸后進入圖形GUI模式
運行級別6:系統正常關閉并重啟,默認運行級別不能設為6,否則不能正常啟動
總結
以上是生活随笔為你收集整理的linux——系统排错之引导恢复shell的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linun——SElinux的简单理解
- 下一篇: linux——高级网络配置之bond、t