Ubuntu/UUID/blkid/fstab/Grub2 boot and rescue

邓韬
2023-12-01

1. sudo blkid


lake@lake-Latitude-5491:~$ blkid 
/dev/nvme0n1p1: LABEL="EFI" UUID="6E2F-5B3B" TYPE="vfat" PARTUUID="8ca6e523-01"
/dev/nvme0n1p2: LABEL="MSR" UUID="C466-BFF3" TYPE="vfat" PARTUUID="8ca6e523-02"
/dev/nvme0n1p3: LABEL="Ubuntu" UUID="b3227854-1508-4a0e-ab9b-a222e279f1e1" TYPE="ext4" PARTUUID="8ca6e523-03"
lake@lake-Latitude-5491:~$ 

2. ls -l /dev/disk/by-uuid

 

3. /etc/fstab

 

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p3 during installation
UUID=b3227854-1508-4a0e-ab9b-a222e279f1e1 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=6E2F-5B3B  /boot/efi       vfat    umask=0077      0       1

 

4. fdisk info/MBR 
lake@lake-Latitude-5491:~$ sudo  fdisk   -l   /dev/nvme0n1
Disk /dev/nvme0n1: 477 GiB, 512110190592 bytes, 1000215216 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
Disklabel type: dos
Disk identifier: 0x8ca6e523

Device         Boot    Start      End  Sectors  Size Id Type
/dev/nvme0n1p1          2048  1538047  1536000  750M  b W95 FAT32
/dev/nvme0n1p2       1538048 12023807 10485760    5G  b W95 FAT32
/dev/nvme0n1p3 *    12023808 74938367 62914560   30G 83 Linux
lake@lake-Latitude-5491:~$ 

 

5. Update grub2 menu 

$ sudo grub2-mkconfig  -o /boot/grub2/grub.cfg

or

$update-grub

6.grub2 rescue

 

grub rescue>ls

Example 

(hd0),(hd0,msdos1),(hd0,msdos2)

search /boot/grub2 folder in each partition 

Example1:  ls (hd0,X)/boot/grub2

Example2:  ls (hd0,X)/grub2

Output.... 

 -grub2  grub  grub.cfg  i386-pc ...

 

Fix/Rescure

grub rescue> set root=hd0,msdos2 

grub rescue> set prefix=(hd0,msdos2)/grub2

grub rescue> insmod (hd0,msdos2)/grub2/i386-pc/normal.mod

// 加载normal模块

grub rescue> normal // 调用normal模块

grub rescue> insmod part_gpt   //方便Grub看见gpt分区

Get the menu of Grub2 

 

Get into System/Linux/Centos/RHEL etc

########## Grub2/GPT/UEFI   Example

/boot/efi   mount   /dev/nvme0n1p1   ----->  vfat  with folders :  EFI, en-us 

/boot  in / (root example: /dev/nvme0n1p2) or specified partition, with vmliuz*, grub,grub2 and the mount point /boot/efi for UEFI vfat partition.

 

## rpm -ivh  eflbootmgr-xxxx.rpm  grub2-xxx.rpm 

# grub2-install  /dev/nvme0n1  ->  UEFI  Hardware Disk without partition No. number!!!

--> grub2-install completed, No Error occured.

 

7.grub2 rescue by linux/initrd loading 

  

grub rescue> linux (hd0,msdos2)/boot/vmlinuz-4.1.13  root=/dev/nvme0n1p3

grub rescue> initrd  (hd0,msdos2)/boot/initrd-4.1.13

grub rescue> boot

 

 类似资料: