fdisk -l
     df -Th

     parted

----------------------------------------详解-------------------------------------


fdisk -l 命令查看一下

    # fdisk -l
    Disk /dev/sda: 12.8 GB, 12884901888 bytes
    255 heads, 63 sectors/track, 1566 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x0003bbd5
   
    Device Boot         Start        End      Blocks    Id System
    /dev/sda1   *           1        1494    12000523+ 83 Linux
    /dev/sda2            1495        1566      578340    5 Extended
    /dev/sda5            1495        1566      578308+ 82 Linux swap / Solaris


查看硬盘是什么分区,使用fdisk -l,但是看不到文件系统类型,只能看到分区类型,以Redhat 9为例:

        [root@redhat9 root]# fdisk -l
       
        Disk /dev/sda: 8589 MB, 8589934592 bytes
        255 heads, 63 sectors/track, 1044 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
       
        Device Boot    Start       End    Blocks   Id System
        /dev/sda1   *         1        13    104391   83 Linux
        /dev/sda2            14      1012   8024467+ 83 Linux
        /dev/sda3          1013      1044    257040   82 Linux swap


df -Th 命令
    友好一些,容量大小是以易读的方式显示的,而且它是显示所有分区,并不是一个分区。这个命令最方便。

        [root@redhat9 root]# df -Th
        Filesystem    Type    Size Used Avail Use% Mounted on
        /dev/sda2     ext3    7.6G 2.3G 4.9G 32% /
        /dev/sda1     ext3     99M 9.3M   85M 10% /boot
        none         tmpfs     62M     0   62M   0% /dev/shm

parted
    倒是有点复杂了,因为它的功能很强,redhat 9中的parted不支持-p参数,但是用parted命令进入后可以用p命令显示出当前的磁盘分区和文件系统情况:

        # parted
        GNU Parted 1.6.3
        Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
        This program is free software, covered by the GNU General Public License.
       
        This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
        even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
        General Public License for more details.
       
        Using /dev/sda
        Information: The operating system thinks the geometry on /dev/sda is 1044/255/63. Therefore,
        cylinder 1024 ends at 8032.499M.
        (parted) p                                                               
       
        Disk geometry for /dev/sda: 0.000-8192.000 megabytes
        Disk label type: msdos
        Minor    Start       End     Type      Filesystem Flags
        1          0.031    101.975 primary   ext3        boot
        2        101.975   7938.369 primary   ext3       
        3       7938.369   8189.384 primary   linux-swap




       
        ==============================================================
        ubuntu下使用parted:
       
       
        root@bai-desktop:/home/bai# parted
        GNU Parted 1.7.1
        Using /dev/sda
        Welcome to GNU Parted! Type 'help' to view a list of commands.
        (parted) help                                                            
        check NUMBER                             do a simple check on the file system
        cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition
        help [COMMAND]                           prints general help, or help on COMMAND
        mklabel LABEL-TYPE                       create a new disklabel (partition table)
        mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partititon NUMBER
        mkpart PART-TYPE [FS-TYPE] START END     make a partition
        mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system
        move NUMBER START END                    move partition NUMBER
        name NUMBER NAME                         name partition NUMBER as NAME
        print [free|NUMBER|all]                  display the partition table, a partition, or all devices
        quit                                     exit program
        rescue START END                         rescue a lost partition near START and END
        resize NUMBER START END                  resize partition NUMBER and its file system
        rm NUMBER                                delete partition NUMBER
        select DEVICE                            choose the device to edit
        set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
        toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
        unit UNIT                                set the default unit to UNIT
        version                                  displays the current version of GNU Parted and copyright information
        (parted) print                                                           
       
        Disk /dev/sda: 12.9GB
        Sector size (logical/physical): 512B/512B
        Partition Table: msdos
       
        Number Start   End     Size    Type      File system Flags
        1      32.3kB 12.3GB 12.3GB primary   ext3         boot
        2      12.3GB 12.9GB 592MB   extended                   
        5      12.3GB 12.9GB 592MB   logical   linux-swap       
       
        (parted) quit                                                            
        Information: Don't forget to update /etc/fstab, if necessary.