2014年4月8日星期二

Linux_028:常用命令之四:fdisk

fdisk命令用来对硬盘进行分区操作。
分区前,可以使用fdisk -l查看机器的硬盘及设备情况。
运行fdisk -l后,会显示如下信息:

Disk /dev/sda: 1000.0 GB, 999999668224 bytes
255 heads, 63 sectors/track, 121576 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: 0x0004ee9e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       25497   204800000   83  Linux
/dev/sda2           25497       89238   512000000   83  Linux
/dev/sda3           89238       91788    20480000   82  Linux swap / Solaris

这个硬盘是1000G的,有3个分区,sda1是引导分区。

在MAC OS X 10.9.4 环境下,运行fdisk -l,会提示不支持“-l”参数,输出如下信息:
fdisk: illegal option -- l
usage: fdisk [-ieu] [-f mbrboot] [-c cyl -h head -s sect] [-S size] [-r] [-a style] disk
    -i: initialize disk with new MBR
    -u: update MBR code, preserve partition table
    -e: edit MBRs on disk interactively
    -f: specify non-standard MBR template
    -chs: specify disk geometry
    -S: specify disk size
    -r: read partition specs from stdin (implies -i)
    -a: auto-partition with the given style
    -d: dump partition table
    -y: don't ask any questions
    -t: test if disk is partitioned
`disk' is of the form /dev/rdisk0.
auto-partition styles:
  boothfs     8Mb boot plus HFS+ root partition (default)
  hfs         Entire disk as one HFS+ partition
  dos         Entire disk as one DOS partition
  raid        Entire disk as one 0xAC partition

在MAC OS X 10.9.4 环境下,可以运行diskutil list,其功能与fdisk -l类似,输出信息如下:
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            499.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            RHEL_6.4 x86_64        *3.7 GB     disk1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *7.3 MB     disk2
   1:        Apple_partition_map                         32.3 KB    disk2s1
   2:                  Apple_HFS Adobe Flash Player I... 7.3 MB     disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *16.0 GB    disk3
   1:             Windows_FAT_32 雨林木风 GH             16.0 GB    disk3s4

参考文献:
1. http://blog.chinaunix.net/uid-23929712-id-2650378.html
2. http://www.linuxdiyf.com/viewarticle.php?id=55799



没有评论: