Ubuntu Desktop 3.1: Boot problems: GRUB 2 and the initramfs
Making the GRUB menu show at every boot with kernel messages instead of
the logo, recovery mode, getting a system back from grub rescue>, and
rebuilding the initramfs. Tasks 2 and 3 need the VM's console.
Before you start
The lab saves /etc/default/grub and /etc/default/grub.d/ so reset can
put them back (and runs update-grub if they changed). It changes
nothing else. On cloud images,
/etc/default/grub.d/50-cloudimg-settings.cfg is read after
/etc/default/grub and sets GRUB_TIMEOUT=0.
Tasks
- Make the GRUB menu appear for 10 seconds at every boot, and make every
boot show kernel messages instead of the logo (no
quietorsplashon the kernel command line). Reboot to see it. - Boot once into recovery mode, get a root shell, and make sure
/is writable. Not graded: in that shell,cat /proc/cmdlinecontainsrecovery,systemctl is-active friendly-recovery.serviceprintsactive, andtouch /root/recovery-testsucceeds. - Rename
/boot/grubto/boot/grub.bak, reboot, and get the system booted fromgrub rescue>. Then repair it for good. Not graded: aftersudo mv /boot/grub.bak /boot/grub,sudo grub-install DISKprintsInstallation finished. No error reported., and the next reboot shows the normal menu. Take a snapshot of the VM before this one. - Rebuild the initramfs of every installed kernel.
Hints
GRUB_TIMEOUT_STYLE=menu,GRUB_TIMEOUT=10andGRUB_CMDLINE_LINUX_DEFAULT, in/etc/default/grubor a file in/etc/default/grub.d/that sorts after the cloud image's; thensudo update-grub. After a reboot,cat /proc/cmdline.- In the menu: Advanced options, then the
(recovery mode)entry, thenroot.mount -o remount,rw /if/is read-only. - At
grub rescue>:setshows the prefix GRUB looked in;ls (hd0,gpt16)/findsgrub.bak(on cloud images/bootis its own partition). Thenset prefix=(hd0,gpt16)/grub.bak,set root=(hd0,gpt16),insmod normal,normal.lsblkshows the disk forgrub-install. sudo update-initramfs -u -k allprints aGeneratingline for each kernel inls /boot/vmlinuz-*.