设置可引导分区命令行

Wil*_*iam 28 parted

如何使用 parted 中的命令行设置可引导分区?

理想情况下,我想要一个编号列表,以便我可以轻松选择要从哪个分区启动。

dub*_*bis 32

我使用 fdisk。在应用此之前,我建议使用 live CD 或 USB 并备份您的数据。

首先检查是否存在任何可引导分区,例如在我的系统中,“/dev/sda1”是可引导分区:

fdisk -l /dev/sda                                                      

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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
Disk identifier: 0x00003256

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1    *       2048   959991807   479994880   83  Linux
/dev/sda2       959993854   976766975     8386561    5  Extended
/dev/sda5       959993856   976766975     8386560   82  Linux swap / Solaris
Run Code Online (Sandbox Code Playgroud)

如果没有任何引导分区,请使用 root 登录执行以下操作:

fdisk  /dev/sda
Command (m for help): m

Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): a
Partition number (1-5): 
Run Code Online (Sandbox Code Playgroud)

如果要使分区 1 可引导,则必须键入 1,如果要使第二个分区可引导,则必须键入 2,等等...

并像这样使用“w”进行修改

Command (m for help): w
Run Code Online (Sandbox Code Playgroud)

用于修改磁盘表并使所需的分区可启动。

希望有所帮助

  • fdisk 似乎不再具有可引导标志选项......在 20190712 上尝试安装 archlinux (5认同)

rob*_*ert 21

使用该print命令可以获取分区号(第一列)。让我们说它是 1. 使其可启动:

(parted) set 1 boot on
Run Code Online (Sandbox Code Playgroud)

  • @robert,感谢您对问题的正确回答! (2认同)