首页 > 志趣人生 > Ubuntu系统Ubuntu系统

在grub> 模式下确定根分区的盘符

方法一:查看/etc/fstab文件(最可靠)grub> cat (hd0,msdos3)/etc/fstab输出示例:# /etc/fstab: static file system information. # # Use 'blkid' to print the un...

方法一:查看/etc/fstab文件(最可靠)

grub> cat (hd0,msdos3)/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/sda3 during installation
UUID=12345678-1234-1234-1234-123456789abc / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=ABCD-1234 /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda2 during installation
UUID=87654321-4321-4321-4321-cba987654321 none swap sw 0 0

关键信息:

  • 根分区通常是 /dev/sda3(在示例中)

  • UUID信息用于更精确的识别

方法二:查看/proc/cmdline(如果可访问)

grub> cat (hd0,msdos3)/proc/cmdline

输出示例:

BOOT_IMAGE=/boot/vmlinuz-6.14.0-27-generic root=UUID=12345678-1234-1234-1234-123456789abc ro quiet splash

关键信息:

  • root=UUID=...root=/dev/sda3显示根分区

方法三:查看/boot/grub/grub.cfg文件

grub> cat (hd0,msdos3)/boot/grub/grub.cfg

查找关键行:

# 搜索包含root=的行grub> grep "root=" (hd0,msdos3)/boot/grub/grub.cfg

输出示例:

linux /boot/vmlinuz-6.14.0-27-generic root=UUID=12345678-1234-1234-1234-123456789abc ro quiet splash

方法四:使用GRUB的search命令

搜索UUID

# 搜索根分区的UUIDgrub> search --fs-uuid --set=root 12345678-1234-1234-1234-123456789abc

搜索设备文件

# 搜索/dev/sda3grub> search --file --set=root /dev/sda3

方法五:检查/etc/mtab文件

grub> cat (hd0,msdos3)/etc/mtab

输出示例:

/dev/sda3 / ext4 rw,relatime,errors=remount-ro 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0

方法六:查看/etc/hostname和系统信息

# 查看主机名确认这是正确的系统grub> cat (hd0,msdos3)/etc/hostname# 查看系统版本grub> cat (hd0,msdos3)/etc/os-release

方法七:使用parttool命令查看分区信息

# 查看分区详细信息grub> parttool (hd0,msdos3) print

输出示例:

Partition 3: start=123456, size=987654, type=0x83 (Linux)

方法八:检查分区大小和类型

# 列出分区并查看大小grub> ls -l (hd0,msdos1)/grub> ls -l (hd0,msdos2)/grub> ls -l (hd0,msdos3)/

根分区特征:

  • 通常最大

  • 包含完整的Linux目录结构

  • 包含/boot目录

方法九:使用blkid信息(如果存在)

# 查看blkid信息grub> cat (hd0,msdos3)/etc/blkid.tab

方法十:检查/etc/passwd确认系统

# 查看用户列表确认这是正确的系统grub> cat (hd0,msdos3)/etc/passwd

快速确认流程

步骤1:快速检查fstab

grub> cat (hd0,msdos3)/etc/fstab | grep " / "

步骤2:验证UUID

# 从fstab中提取UUIDgrub> cat (hd0,msdos3)/etc/fstab | grep " / " | awk '{print $1}'

步骤3:使用UUID启动

# 使用UUID启动更可靠grub> linux /boot/vmlinuz-6.14.0-27-generic root=UUID=12345678-1234-1234-1234-123456789abc rogrub> initrd /boot/initrd.img-6.14.0-27-genericgrub> boot

最可靠的方法组合

推荐流程:

  1. 首先检查fstab

grub> cat (hd0,msdos3)/etc/fstab
  1. 提取根分区信息

# 查找根分区的UUID或设备名grub> cat (hd0,msdos3)/etc/fstab | grep " / "
  1. 使用UUID启动(最可靠):

grub> set root=(hd0,msdos3)grub> linux /boot/vmlinuz-6.14.0-27-generic root=UUID=12345678-1234-1234-1234-123456789abc rogrub> initrd /boot/initrd.img-6.14.0-27-genericgrub> boot

故障排除

如果fstab文件损坏:

# 尝试其他方法grub> cat (hd0,msdos3)/proc/cmdlinegrub> cat (hd0,msdos3)/boot/grub/grub.cfg | grep "root="

如果UUID不确定:

# 使用设备名启动grub> linux /boot/vmlinuz-6.14.0-27-generic root=/dev/sda3 rogrub> initrd /boot/initrd.img-6.14.0-27-genericgrub> boot

总结:cat (hd0,msdos3)/etc/fstab** 确实是最可靠的方法,因为它直接显示了系统的挂载配置。结合UUID使用可以确保启动的准确性。**

3
0

文章导航

共有 0 条热心评论

快快抢占沙发吧!

发表评论

安全验证
Top