#fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
# Start End Size Type Name
1 2048 8191 3M BIOS boot parti
2 8192 2105343 1G EFI System
3 2105344 106962943 50G Microsoft basic
4 106962944 111157247 2G Microsoft basic
5 111157248 468860927 170.6G Microsoft basic
# ttyS0 - getty## This service maintains a getty on ttyS0 from the point the system is# started until it is shut down again.startonstoppedrcRUNLEVEL=[12345]stoponrunlevel [!12345]respawnexec/sbin/getty-L115200ttyS0vt102
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
GRUB_DEFAULT=0
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
通过chroot方式运行ubuntu的grub配置
sudo -s
for f in dev dev/pts proc sys; do mount --bind /$f /media/$f ; done
chroot /media
grub rescue> ls (hd0,gpt1)
(hd0,gpt1): Filesystem is unknown.
grub rescue> ls (hd0,gpt2)
(hd0,gpt2): Filesystem is ext2.
grub rescue> ls (hd0,gpt3)
(hd0,gpt3): Filesystem is ext2.
grub rescue> ls (hd0,gpt4)
(hd0,gpt4): Filesystem is ext2.
尝试启动grub
grub rescue> set root=(hd0,gpt4)
grub rescue> set prefix=(hd0,gpt4)/usr/lib/grub
grub rescue> insmod normal
error: file `/boot/grub/i386-pc/normal.mod' not found.
如果错误,则重新设置root和prefix,再次尝试上述步骤
grub rescue> set root=(hd0,gpt3)
grub rescue> set prefix=(hd0,gpt3)/usr/lib/grub
grub rescue> insmod normal
这次成功了!!! 这个(hd0,gpt3)分区是原先CentOS的系统分区
继续按照
grub rescue > normal
检查分区UUID(可以看到UUID确实是CentOS的系统分区)
grub> ls (hd0,gpt3)
Partition hd0,gpt3: Filesystem type ext* - Label `/' - Last
modification time 2018-01-29 06:43:17 Monday, UUID
96219e3e-c371-47a9-baaf-cc2b1b9f8b33 - Partition start at 1052672KiB - Total
size 52428800KiB
grub>
设置启动内核及root分区UUID
linux /boot/vmlinuz-3.10.0-327.el7.x86_64 root=UUID=96219e3e-c371-47a9-baaf-cc2b1b9f8b33 ro console=tty0 console=ttyS1,115200
但是这里遇到问题,系统始终报告error: file/boot/vmlinuz-3.10.0-327.el7.x86_64' not found.`
set root=(hd0,gpt4)
set prefix=(hd0,gpt4)/usr/lib/grub
insmod normal
normal
检查分区UUID
grub> ls (hd0,gpt4)
Partition hd0,gpt4: Filesystem type ext* - Last modification time
2018-01-28 22:46:34 Sunday, UUID 79140412-5137-45cc-81a5-58a8a7dac4d9 -
Partition start at 53481472KiB - Total size 180949575.5KiB
继续加载
linux /boot/vmlinuz-4.10.0-28-generic root=UUID=79140412-5137-45cc-81a5-58a8a7dac4d9 ro console=tty0 console=ttyS0,115200n8
也是报错
error: file `/boot/vmlinuz-4.10.0-28-generic' not found.
grub> ls -l
...
error: file `/usr/lib/grub/i386-pc/cpio.mod' not found.
error: file `/usr/lib/grub/i386-pc/cbfs.mod' not found.
error: file `/usr/lib/grub/i386-pc/btrfs.mod' not found.
error: file `/usr/lib/grub/i386-pc/bfs.mod' not found.
error: file `/usr/lib/grub/i386-pc/afs.mod' not found.
error: file `/usr/lib/grub/i386-pc/affs.mod' not found.
No known filesystem detected - Sector size 512B - Total size 234431064KiB
Partition hd0,gpt4: Filesystem type ext* - Last modification time
2018-01-28 22:46:34 Sunday, UUID 79140412-5137-45cc-81a5-58a8a7dac4d9 -
Partition start at 53481472KiB - Total size 180949575.5KiB
Partition hd0,gpt3: Filesystem type ext* - Label `/' - Last
modification time 2018-01-29 06:43:17 Monday, UUID
96219e3e-c371-47a9-baaf-cc2b1b9f8b33 - Partition start at 1052672KiB - Total
size 52428800KiB
Partition hd0,gpt2: Filesystem type ext* - Label `/boot' - Last
modification time 2018-01-29 02:34:03 Monday, UUID
5f67c5f1-be04-406e-964c-f49f8b8e940c - Partition start at 4096KiB - Total size
1048576KiB
Partition hd0,gpt1: No known filesystem detected - Partition start at
1024KiB - Total size 3072KiB
Device hd1: No known filesystem detected - Sector size 512B - Total size
390711384KiB
尝试启动
set root=(hd0,4)
linux (hd0,4)/boot/vmlinuz-4.10.0-28-generic root=UUID=b513f893-96ca-494c-8634-0ce8eb7dc135 ro console=tty0 console=ttyS0,115200n8
initrd (hd0,4)/boot/initrd.img-4.10.0-28-generic
依然找不到
发现可以通过指定(hd0,2)包含CentOS /boot分区来启动
grub> set root=(hd0,3)
grub> linux (hd0,2)/vmlinuz-3.10.0-327.ali2014.alios7.x86_64 root=UUID=96219e3e-c371-47a9-baaf-cc2b1b9f8b33 ro console=tty0 console=ttyS1,115200
grub> initrd (hd0,2)/initramfs-3.10.0-327.el7.x86_64.img
然后可以尝试启动CentOS系统了
grub> boot
CentOS启动
CentOS启动
...
[ 185.715802] dracut-initqueue[749]: Warning: dracut-initqueue timeout - starting timeout scripts
[ 186.221782] dracut-initqueue[749]: Warning: dracut-initqueue timeout - starting timeout scripts
[ 186.727769] dracut-initqueue[749]: Warning: dracut-initqueue timeout - starting timeout scripts
[ 187.233784] dracut-initqueue[749]: Warning: dracut-initqueue timeoWarning: /dev/disk/by-uuid/96219e3e-c371-47a9-baaf-cc2b1b9f8b33 does not exist
Generating "/run/initramfs/rdsosreport.txt"
Entering emergency mode. Exit the shell to continue.
Type "journalctl" to view system logs.
You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot
after mounting them and attach it to a bug report.
dracut:/#
重新开始
reboot之后重新开始
检查当前配置:
grub rescue> set
cmdpath=(hd0)
prefix=(hd0,gpt3)/boot/grub
root=hd0,gpt3
grub rescue> ls
(hd0) (hd0,gpt4) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1)
加载grub模块
grub rescue> set prefix=(hd0,gpt3)/usr/lib/grub
grub rescue> insmod normal
grub rescue> normal
进入常规模式后,检查设备uuuid
grub> ls -l
Device hd0: No known filesystem detected - Sector size 512B - Total size
234431064KiB
Partition hd0,gpt4: Filesystem type ext* - Last modification time
2018-01-28 22:46:34 Sunday, UUID 79140412-5137-45cc-81a5-58a8a7dac4d9 -
Partition start at 53481472KiB - Total size 180949575.5KiB
Partition hd0,gpt3: Filesystem type ext* - Label `/' - Last
modification time 2018-01-29 06:43:17 Monday, UUID
96219e3e-c371-47a9-baaf-cc2b1b9f8b33 - Partition start at 1052672KiB - Total
size 52428800KiB
Partition hd0,gpt2: Filesystem type ext* - Label `/boot' - Last
modification time 2018-01-29 02:34:03 Monday, UUID
5f67c5f1-be04-406e-964c-f49f8b8e940c - Partition start at 4096KiB - Total size
1048576KiB
Partition hd0,gpt1: No known filesystem detected - Partition start at
1024KiB - Total size 3072KiB
Device hd1: No known filesystem detected - Sector size 512B - Total size
390711384KiB
grub> linux (hd0,2)/vmlinuz-3.10.0-327.ali2014.alios7.x86_64 root=/dev/sda3 ro console=tty0 console=ttyS1,115200
grub> initrd (hd0,2)/initramfs-3.10.0-327.el7.x86_64.img