首页 Linux网维 fdisk命令 – 管理磁盘分区

fdisk命令 – 管理磁盘分区

fdisk命令来自于英文词组“Partition table manipulator for Linux”的缩写,其功能是用于管理磁盘的分区信息。如果一套几百平米的房子内部没有墙壁…

fdisk命令来自于英文词组“Partition table manipulator for Linux”的缩写,其功能是用于管理磁盘的分区信息。如果一套几百平米的房子内部没有墙壁,虽然看起来会很敞亮,但是各种声音、气味、物品会随意充斥在整个房子内,让人极不舒适,因此需要用墙壁按照功能进行划分,例如卧室、厕所、厨房、阳台等等。

fdisk命令可以用于对磁盘进行分区操作,用户可以根据实际情况进行合理划分,这样后期挂载和使用时会方便很多。

语法格式:fdisk [参数] [设备]

常用参数:

-b 指定每个分区的大小
-l 列出指定的外围设备的分区表状况
-s 将指定的分区大小输出到标准输出上,单位为区块
-u 搭配”-l”参数列表,会用分区数目取代柱面数目,来表示每个分区的起始地址
-v 显示版本信息

参考实例

查看当前系统的分区情况:

[root@linuxcool ~]# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x5f1d8ee5

Device     Boot   Start      End  Sectors Size Id Type
/dev/sda1  *       2048  2099199  2097152   1G 83 Linux
/dev/sda2       2099200 41943039 39843840  19G 8e Linux LVM
………………省略部分输出信息………………

管理指定硬盘的分区(过程省略,以《Linux就该这么学》第6章节为准):

[root@linuxcool ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): n 
All space for primary partitions is in use.
Command (m for help): m 

Help:
  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table
………………省略部分输出信息………………
免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。

作者: 3182235786a

为您推荐

linux文件命令

linux文件命令

在 Linux 中,我们可以使用 `with open()` 语句和 `write()` 函数来写入文件。以下是一个简单...
linux的命令

linux的命令

以下是一个简单的 Linux 命令示例,该命令将显示当前日期和时间: “`c #include <st...
linux 命令

linux 命令

由于 Linux 命令是由 C 语言编写的,因此下面是一个简单的用中文编写的 Linux 命令示例,它将输出“Hello...
linux命令tar

linux命令tar

这个问题看起来有些模糊,我不确定您是想了解如何在 Linux 系统中使用 tar 命令,还是如何编写一个名为 tar 的...
linux压缩命令

linux压缩命令

Linux压缩命令:高效管理文件和目录 Linux操作系统提供了一系列强大的压缩命令,使您能够高效地管理文件和目录。无论...

发表回复

返回顶部