問題:安裝ubuntu22版本后無法啟動
安裝好ubuntu22之后,重啟進入了grub模式,沒有自動啟動ubuntu
網上查了一下,這算一個通病。
問題解決
在grub模式下輸入boot命令:
boot (lvm/ubuntu--vg-ubuntu--lv)/boot
error: you need to load the kernel first.
問題變成先load內核。
查找啟動內核的位置
使用ls列出所有的磁盤,然后在所有的磁盤里面找類似mlinuz-5.15.0-107-generic initrd.img? initrd.img-5.15.0-107-generic 這兩個文件。
ls (host)/boot
lua/ zfs/ loader.help.userboot boot2 fonts/ loader.help.efi uboot/ isoboot userboot.so de
lay.4th mbr version.4th userboot_lua.so boot0sio loader_4th userboot_4th.so brand.4th men
usets.4th logo-beastie.4th boot1 menu.4th device.hints color.4th defaults/ loader.4th loa
der_4th.efi pxeboot frames.4th loader_simp entropy screen.4th dtb/ brand-fbsd.4th efi/ mo
dules/ menu-commands.4th loader.rc logo-beastiebw.4th cdboot logo-orb.4th loader firmware
/ loader.conf gptzfsboot pmbr images/ boot kernel/ gptboot.efi zfsloader zfsboot boot1.ef
i beastie.4th support.4th logo-orbbw.4th shortcuts.4th loader.help.bios menu.rc loader_si
mp.efi loader.efi logo-fbsdbw.4th loader_lua.efi boot0 efi.4th check-password.4th loader_
lua gptboot loader.conf.d/
這個目錄(host)/boot里面沒有
在(hd0,gpt2)/找到內核和啟動文件
ls (hd0,gpt2)/
lost+found/ grub/ config-5.15.0-107-generic initrd.img.old vmlinuz.old System.map-5.15.0-
107-generic vmlinuz-5.15.0-107-generic initrd.img vmlinuz initrd.img-5.15.0-107-generic
?
設置根文件系統:
一旦找到了內核文件,就需要設置正確的根文件系統。這通常是包含?/
?目錄的分區或邏輯卷。
例如,如果根文件系統在 LVM 邏輯卷上,可以這樣設置:
grub> set root=(lvm/ubuntu--vg-ubuntu--lv)
?
加載內核和 initramfs:
使用?linux
?命令加載內核,并用?initrd
?或?initramfs
?命令加載 initramfs。
grub> linux /boot/vmlinuz-X.X.X-YY-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv
grub> initrd /boot/initrd.img-X.X.X-YY-generic
最后再輸入boot就行了。
因此之后每次啟動進入grub之后
?
最終執行的命令
set root=(lvm/ubuntu--vg-ubuntu--lv)
linux (hd0,gpt2)/vmlinuz-5.15.0-107-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv
initrd (hd0,gpt2)/initrd.img-5.15.0-107-generic
boot
終于啟動成功了!
如何設為自動啟動呢??
設置grub自動啟動
修改配置文件,可以用 vm config vmubuntu命令 ,也可以直接vi編輯配置文件:
vi vmubuntu.conf?
在文件中加入以下語句
grub_run_partition="0"
grub_run0="set root=(lvm/ubuntu--vg-ubuntu--lv)"
grub_run1="linux (hd0,gpt2)/vmlinuz-5.15.0-107-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv"
grub_run2="initrd (hd0,gpt2)/initrd.img-5.15.0-107-generic"
grub_run3="boot"
這樣就能自動啟動,不用每次都在grub下輸入命令了。
ps,光盤啟動后掛載硬盤,使用如下命令
mount /dev/vda2 /mnt
mount /dev/mapper/ubuntu--vg-ubuntu--lv /mnt