fdisk -l 显示信息详解

来源:互联网 发布:淘宝宝贝品牌怎么填 编辑:程序博客网 时间:2024/06/05 14:53

fdisk -l显示信息详解

[root@www.linuxidc.com ~]# fdisk -l 
Disk /dev/sda: 10.7 GB, 10737418240 bytes 
255 heads, 63 sectors/track, 1305 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disk identifier: 0x00044938 
  Device Boot      Start        End      Blocks  Id  System 
/dev/sda1  *          1        638    5120000  83  Linux 
Partition 1 does not end on cylinder boundary. 
/dev/sda2            638        893    2048000  83  Linux 
Partition 2 does not end on cylinder boundary. 
/dev/sda3            893        1020    1024000  82  Linux swap / Solaris 
Partition 3 does not end on cylinder boundary. 
/dev/sda4            1020        1306    2292736    5  Extended 
/dev/sda5            1021        1306    2291712  83  Linux

解析
Disk /dev/sda: 10.7 GB, 10737418240 bytes
块设备名称为/dev/sda,此设备的大小为10.7GB,这个数字不是特别精确,我系统是10GB;10737418240 bytes这是转换成字节后的大小,即:10737418240/1024/1024/1024=10GB (注:bytes=B,表示“字节”,bit=b,表示“位”)
255 heads, 63 sectors/track, 1305 cylinders
255 heads:表示磁头数为255
63 sectors/track:表示每磁道上有63个扇区
1305 cylinders:表示共有1305个柱面,柱面是分区的最小单位
Units = cylinders of 16065 * 512 = 8225280 bytes

16065=255*63 因为每一个磁头都是在同一个柱面的,63表示每个磁道上的扇区数量,这两个数的乘积表示一个柱面上的扇区数量;所以16065*512表示一个柱面的大小是8225280字节
Sector size (logical/physical): 512 bytes / 512 bytes
表示一个扇区的大小是512字节

总结:所以一个磁盘的大小=一个柱面大小*柱面的总数=磁头数量*每个磁道上的扇区数*一个扇区大小*柱面总数

:磁盘大小=8225280*1305=10733990400bytes=9.99GB=255*63*512*1305
上例中显示出我们的磁盘只有1305个柱面,但下边的分区信息中出现了1306个柱面数,不必太在意,linux显示的这些数据不会十分精确。


以上数据说明:
硬盘分区的表示:在Linux 是通过hd*x 或 sd*x 表示的,其中 * 表示的是a、b、c …… …… x表示的数字 1、2、3 …… …… hd大多是IDE硬盘;sd大多是SCSI或SATA;
引导(Boot):表示引导分区,在上面的例子中 sda1 是引导分区;
Start (开始):表示的一个分区从X cylinder(磁柱)开始;
End (结束):表示一个分区到 Y cylinder(磁柱)结束;
Blocks(容量):其默认单位是K;一个分区容量的值是由下面的公式而来的;
Blocks = (相应分区End数值 - 相应分区Start数值)x 单位cylinder(磁柱)的容量
例如:sda1的 Blocks 的大小 :
sda1 Blocks=(3917-1)x8225.280=32210196.48 K = 32210.19648M
查看分区大小或者文件的时候,一般用的都是十进制,推算办法是 byte 向前推小数点三位就是K ,K单位的值向前推小数点三位就是M,M向前推小数点三位就是G…… …… 一般都是这样,取大概值就行
id和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;
那么怎样才能知道ID对应的分区类型呢?
1、输入命令:fdisk /dev/sda
2、进入fdisk交互界面。出现提示:command(m for help)
3、输入m,回车,显示帮助信息。
4、在显示的帮助信息中选择l,输入l(注:l必须小写)
5、回车即可看到ID所对应的分区类型。
(3)估算一个存储设备是否被完全划分;
估算一个硬盘是否完全被划分,只要看 fdisk -l 输出的内容中的 cylinders(柱体) 上一个分区的End 和 下一个分区的Start是不是一个连续的数字,另外要看一下每个硬盘设备的fdisk -l 的开头部份,看一下他的 cylinders(柱体)的值;
 
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd10cd10c
 
Device Boot     Start       End      Blocks       Id      System
/dev/sda1         1        3917    31463271      7      HPFS/NTFS
/dev/sda2       3918       30401   212732730     f      W95 Ext'd (LBA)
/dev/sda5       3918       12841    71681998+    7      HPFS/NTFS
/dev/sda6       12842      21765    71681998+    7      HPFS/NTFS
/dev/sda7       1766       23070    10482381     b      W95 FAT32
/dev/sda8       3071       25620    20482843+   83      Linux
/dev/sda9      25621       25747     1020096    82      Linux swap / Solaris
/dev/sda10     25748       30401    37383223+   83      Linux
 
比如上面的sda设备,我们看到的是 30401 cylinders ,通过 sda的分区表可以看到上一个分区的End的值+1 就是下一个分区的Start 的值;比如 sda2的Start的值是 sda1 的End 的值+1,这证明 sda1 和sda2 中间没有空白分区,是连续的,以此类推;在 hda10,我们看到 End 的值是30401 ,而在fdisk -l头部信息中也有30401个 cylinders,说明这块硬盘没有空白分区,再回过头来看看sda1和sda2,sda有 30401个cylinders (柱体),有一个主分区和一个扩展分区构成;在扩展分区中,我们看到End的值为30401,而这个移动硬盘的cylinder也是30401,以上数据说明这个硬盘不可能再添加任何主分区了,整个硬盘已完全划分。

0 0