partprobe命令

更改系统分区表后。您可能需要强制系统重新读取其分区表。

Linux修改分区后,如何不重启机器识别新分区表

语法

partprobe [-d] [-s] [devices ....] 

Partprobe选项

-d不更新内核。
-s显示设备及其分区的摘要。
-h显示选项摘要。

示例

root@john-desktop:~# partprobe -s
/dev/sda: msdos partitions 1 2 <5>
fdisk命令

Linux fdisk-操作分区表

fdisk命令

fdisk命令用于显示或操作Linux系统上的分区表。fdisk是菜单驱动的实用程序,用于处理物理磁盘。

fdisk命令的基本语法为:fdisk [ device ]

fdisk也可以用于在交互式菜单系统外部快速显示分区表。

root@john-desktop:~# fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders, total 312581808 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: 0x000132a7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   307357695   153677824   83  Linux
/dev/sda2       307359742   312580095     2610177    5  Extended
/dev/sda5       307359744   312580095     2610176   82  Linux swap / Solaris

进入交互式菜单

执行fdisk device

注意fdisk可以删除可能导致数据丢失并导致系统无法启动的分区!!除非你知道自己在做什么,否则不要使用fdisk。

root@john-desktop:~# 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):

执行命令fdisk /dev/sda后,按下 m键 打印出帮助菜单。
此菜单使用的所有命令仅适用于设备/dev/sda

当使用主分区和扩展分区时,提供的选择编号为1到4。逻辑分区仅在创建扩展分区时可用。逻辑分区号是5到16。

常用操作

root@john-desktop:~# fdisk /dev/sda
Command (m for help): m
Command action
   a   将启动分区标准设置为`打开`或`关闭` 
   b   修改bsd磁盘标签
   c   打开或者关闭DOS兼容标签
   d   删除分区。系统将要求您指定需要删除的分区号。
   l   列出已知的分区类型:
   m   交互式帮助菜单。
   n   创建新分区,在此将提示您输入分区类型-`主`,`扩展`或`逻辑`。
   o   创建一个新的空DOS分区表
   p   显示分区表。
   q   退出fdisk而不进行任何更改。
   s   创建一个新的空的sun磁盘标签
   t   更改分区系统ID(类型),这是使用` l`选项时显示的数字。
   u   修改显示单位
   v   检查分区表
   w   将分区表写入磁盘并退出
   x   额外功能(仅限专家使用)
日期:2019-04-29 03:17:32 来源:oir作者:oir