当前位置:Linux教程 - Linux - fdisk命令使用

fdisk命令使用



        

    在linux数个硬盘分区的软件中,fdisk是用的最多的一个:功能强大又易于使用。使用fdisk命令之前,先用su命令获得root权限,然后输入 \"fdisk \", 来执行。device看起来应该是这样的 /dev/hda or /dev/sda 它就是将要被分区的盘 。
    在本例子中,我们要将第二个IDE硬盘分区,所以我们的device是 /dev/hdb ,如果你要分的盘不一样,请做适当的改变。
    输入命令:
    [root@localhost /]# /sbin/fdisk /dev/hdb
    The number of cylinders for this disk is set to 2491.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., LILO)
    2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)
    Command (m for help):

    上面的警告你可能没有,这取决于你的硬盘大小,如果硬盘大于8Gb,就会出现这样的警告。
    下一步该怎么做? 还是先看看 help吧:输入m
    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):
    很好,有了一张完整的命令列表,各个命令的作用将在后面讲到。okey
    先看看已有的分区情况吧。命令是 p .输入后的到结果:
    Command (m for help): p

    Disk /dev/hdb: 255 heads, 63 sectors, 2491 cylinders
    Units = cylinders of 16065 * 512 bytes

    Device Boot Start End Blocks Id System
    /dev/hdb1 * 1 195 1566306 a5 BSD/386
    /dev/hdb2 196 212 136552+ 82 Linux swap
    /dev/hdb3 213 2491 18306067+ 5 Extended
    /dev/hdb5 213 474 2104514+ 83 Linux
    /dev/hdb6 475 506 257039+ 83 Linux
    /dev/hdb7 507 532 208844+ 83 Linux
    /dev/hdb8 795 925 1052257 83 Linux
    /dev/hdb9 926 1056 1052257 83 Linux
    /dev/hdb10 1057 1088 257008+ 83 Linux
    /dev/hdb11 1089 1350 2104483+ 83 Linux
    /dev/hdb12 533 794 2104483+ 83 Linux

    Command (m for help):
    现在对各个列所表示的意思作一个简单的介绍:
    Device - 已有的分区,从最后的/dev/hdb12可以看出一共分了12个区。
    分区1-4是主分区(primary partitions),大于5的都是逻辑分区(logical partition),这里不对这个作详细介绍了。

    Boot - 如果这一列有*,那么说明该盘可用来引导系统。也就是我们平时说的启动盘。这里是/dev/hdb1

    Start - 起始的柱面。并不是所有的硬盘的单个柱面的大小都是一样的。但是你可以从前面的提示消息中看出来。这里的是:Units = cylinders of 16065 * 512 bytes,大概是8M。

    End - 结束柱面。这个是很重要的一个参数,原因就是LILO的1024柱面问提:LILO不能安装在1024柱面以后,而且,有时不能引导1024柱面以后的东西。

    Blocks - 分区所占用的块数,块的大小取决于你的文件系统。一般是1k左右。在这里。这里第一个分区的大小是1566306KB,大概是1.5Gb.

    Id - 分区类型对应的数字代码。其中 82 是交换分区。83是linux的标准分区。

    System - 该分区内安装的系统。和Id号码对应。

    发布人:netbull 来自:网络能源中心