- During boot, hold the "ESC" key to enter the GRUB menu. A "grub>" command prompt should appear.
- Execute the "ls" command. The console will display available partitions, for example:
(hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (lvm/ubuntu--vg-ubuntu--lv) - Now, check these partitions with the commands:
ls (hd0,gpt1)/
ls (hd0,gpt2)/
ls (hd0,gpt3)/
ls (lvm/ubuntu--vg-ubuntu--lv)/
You need to find:
The System Partition - contains directories like familiar folders at its root: boot, home, usr, etc.
The Boot Partition - contains:
- The kernel file (vmlinuz): a file whose name starts with "vmlinuz-", e.g., "vmlinuz-6.8.0-31-generic".
- The initrd file: a file whose name starts with "initrd.img-" and contains the same version as the kernel, e.g., "initrd.img-6.8.0-31-generic".
Write down or remember the full names of these two files. - Manually set the boot commands.
Let's assume your boot partition is "(hd0,gpt2)" and the system partition is "(lvm/ubuntu--vg-ubuntu--lv)". - Tell GRUB where to find the boot files (the boot partition):
set root=(hd0,gpt2) - Load the kernel:
linux /vmlinuz-6.8.0-31-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv rw init=/bin/bash
where
root=/dev/mapper/ubuntu--vg-ubuntu--lv - the path to the LVM volume as the root partition;
rw - mount for writing (ro - read-only);
init=/bin/bash - boot directly into the root shell. - Load the initrd image (necessary for LVM to work):
initrd /initrd.img-6.8.0-31-generic - Start the boot process:
boot
After the OS image loads, an input prompt in the format "root@(none):/#" will appear. - Change the password for "root" or another user:
passwd root - Perform a reboot:
reboot -f
If boot errors occur and the "(initramfs)" input prompt appears instead of "root@(none):/#", try mounting the filesystem manually:
- Create a mount point:
mkdir /rootfs - Mount your LVM volume:
mount /dev/mapper/ubuntu--vg-ubuntu--lv /rootfs - Check the mount:
ls /rootfs
You should see the contents of the root filesystem (/): folders like bin, home, usr, etc, etc. - Use the chroot command to make the mounted partition the root for subsequent commands:
chroot /rootfs - Change the password for "root" or another user:
passwd root
Enter the new password twice. - Reboot the system to normal mode:
Exit chroot:
exit
Unmount the partition:
umount /rootfs
Perform a reboot:
reboot -f
Note: Make sure to use the exact kernel version and LVM path found on your system when entering the commands.
No comments:
Post a Comment