71 fdisk-Linux 的磁盘分区表操作工具。

语法:

fdisk [-l] 装置名称

选项与参数:

  • -l :输出后面接的装置所有的分区内容。若仅有 fdisk -l 时, 则系统将会把整个系统内能够搜寻到的装置的分区均列出来。

实例 

列出所有分区信息

 1 [root@AY120919111755c246621 tmp]# fdisk -l
 2 
 3 Disk /dev/xvda: 21.5 GB, 21474836480 bytes
 4 255 heads, 63 sectors/track, 2610 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 Sector size (logical/physical): 512 bytes / 512 bytes
 7 I/O size (minimum/optimal): 512 bytes / 512 bytes
 8 Disk identifier: 0x00000000
 9 
10     Device Boot      Start         End      Blocks   Id  System
11 /dev/xvda1   *           1        2550    20480000   83  Linux
12 /dev/xvda2            2550        2611      490496   82  Linux swap / Solaris
13 
14 Disk /dev/xvdb: 21.5 GB, 21474836480 bytes
15 255 heads, 63 sectors/track, 2610 cylinders
16 Units = cylinders of 16065 * 512 = 8225280 bytes
17 Sector size (logical/physical): 512 bytes / 512 bytes
18 I/O size (minimum/optimal): 512 bytes / 512 bytes
19 Disk identifier: 0x56f40944
20 
21     Device Boot      Start         End      Blocks   Id  System
22 /dev/xvdb2               1        2610    20964793+  83  Linux

找出你系统中的根目录所在磁盘,并查阅该硬盘内的相关信息

 1 [root@www ~]# df /            <==注意:重点在找出磁盘文件名而已
 2 Filesystem           1K-blocks      Used Available Use% Mounted on
 3 /dev/hdc2              9920624   3823168   5585388  41% /
 4 
 5 [root@www ~]# fdisk /dev/hdc  <==仔细看,不要加上数字喔!
 6 The number of cylinders for this disk is set to 5005.
 7 There is nothing wrong with that, but this is larger than 1024,
 8 and could in certain setups cause problems with:
 9 1) software that runs at boot time (e.g., old versions of LILO)
10 2) booting and partitioning software from other OSs
11    (e.g., DOS FDISK, OS/2 FDISK)
12 
13 Command (m for help):     <==等待你的输入!

输入 m 后,就会看到底下这些命令介绍

 1 Command (m for help): m   <== 输入 m 后,就会看到底下这些命令介绍
 2 Command action
 3    a   toggle a bootable flag
 4    b   edit bsd disklabel
 5    c   toggle the dos compatibility flag
 6    d   delete a partition            <==删除一个partition
 7    l   list known partition types     列出分区信息
 8    m   print this menu                打印分区
 9    n   add a new partition           <==新增一个partition
10    o   create a new empty DOS partition table
11    p   print the partition table     <==在屏幕上显示分割表
12    q   quit without saving changes   <==不储存离开fdisk程序
13    s   create a new empty Sun disklabel
14    t   change a partition's system id
15    u   change display/entry units
16    v   verify the partition table
17    w   write table to disk and exit  <==将刚刚的动作写入分割表
18    x   extra functionality (experts only)

离开 fdisk 时按下 q,那么所有的动作都不会生效!相反的, 按下w就是动作生效的意思。

 1 Command (m for help): p  <== 这里可以输出目前磁盘的状态
 2 
 3 Disk /dev/hdc: 41.1 GB, 41174138880 bytes        <==这个磁盘的文件名与容量
 4 255 heads, 63 sectors/track, 5005 cylinders      <==磁头、扇区与磁柱大小
 5 Units = cylinders of 16065 * 512 = 8225280 bytes <==每个磁柱的大小
 6 
 7    Device Boot      Start         End      Blocks   Id  System
 8 /dev/hdc1   *           1          13      104391   83  Linux
 9 /dev/hdc2              14        1288    10241437+  83  Linux
10 /dev/hdc3            1289        1925     5116702+  83  Linux
11 /dev/hdc4            1926        5005    24740100    5  Extended
12 /dev/hdc5            1926        2052     1020096   82  Linux swap / Solaris
13 # 装置文件名 启动区否 开始磁柱    结束磁柱  1K大小容量 磁盘分区槽内的系统
14 
15 Command (m for help): q

想要不储存离开吗?按下 q 就对了!不要随便按 w 啊!

使用 p 可以列出目前这颗磁盘的分割表信息,这个信息的上半部在显示整体磁盘的状态。

原文地址:https://www.cnblogs.com/luoahong/p/6236237.html