2016年2月19日 星期五

檢查硬碟分割區與對應的容量

之前的文章有提到硬碟的狀態,這篇則是要介紹如何看硬碟有哪些分割區(partition),還有相對應的容量。以下的指令都來自Silver Moon發表的文章«9 commands to check hard disk partitions and disk space on Linux»。一樣會先列出指令,後面再詳細介紹
  1. fdisk -l 
  2. sfdisk -l -uM 
  3. cfdisk
  4. parted -l
  5. lsblk
  6. hwinfo --block --short
  7. blkid
  8. df -h
  9. pydf -h
指令1, 2, 3, 4是用來看與編輯分割區(partition), 指令5, 6只有用來看,指令8, 9則是看容量大小。如果遇到GPT分割的硬碟,那編輯分割居只剩下parted可以用
我會建議先用lsblk看分割,再用blkid看分割區編號,最後用pydf看容量大小





以下則是上述指令在我的筆電上執行的結果

# fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sda: 256.1 GB, 256059432448 bytes
255 heads, 63 sectors/track, 31130 cylinders, total 500116079 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        4095        2047+  ee  GPT
Partition 1 does not start on physical sector boundary.
/dev/sda2   *        4096   483915775   241955840   83  Linux
/dev/sda3       483915776   500115455     8099840   82  Linux swap / Solaris


# sfdisk -l -uM 
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util sfdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 31130 cylinders, 255 heads, 63 sectors/track
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sda1         0+     1      2-      2047+  ee  GPT
start: (c,h,s) expected (0,0,2) found (0,0,1)
end: (c,h,s) expected (0,65,1) found (1023,254,63)
/dev/sda2   *     2  236286  236285  241955840   83  Linux
start: (c,h,s) expected (0,65,2) found (1023,254,63)
/dev/sda3     236287  244196   7910    8099840   82  Linux swap / Solaris
/dev/sda4         0      -      0          0    0  Empty


cfdisk
                           cfdisk (util-linux 2.20.1)

                              Disk Drive: /dev/sda
                       Size: 256059432448 bytes, 256.0 GB
             Heads: 255   Sectors per Track: 63   Cylinders: 31130

    Name        Flags      Part Type  FS Type          [Label]        Size (MB)
 ------------------------------------------------------------------------------
    sda1        NC          Primary   GPT                                  2.10*
    sda2        Boot        Primary   ext4                            247762.79*
    sda3                    Primary   swap                              8294.24*
                            Pri/Log   Free Space                           0.32*



     [ Bootable ]  [  Delete  ]  [   Help   ]  [ Maximize ]  [  Print   ]
     [   Quit   ]  [   Type   ]  [  Units   ]  [  Write   ]


                  Quit program without writing partition table

# parted -l
Model: ATA PLEXTOR PX-256M5 (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  2097kB  1049kB                        bios_grub
 2      2097kB  248GB   248GB   ext4
 3      248GB   256GB   8294MB  linux-swap(v1)


# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238.5G  0 disk 
├─sda1   8:1    0     1M  0 part 
├─sda2   8:2    0 230.8G  0 part /
└─sda3   8:3    0   7.7G  0 part 
sr0     11:0    1  1024M  0 rom 


# hwinfo --block --short
disk:                                                           
  /dev/sda             PLEXTOR PX-256M5
  /dev/sdb             APPLE SD Card Reader
partition:
  /dev/sda1            Partition
  /dev/sda2            Partition
  /dev/sda3            Partition
cdrom:
  /dev/sr0             MATSHITA DVD-R   UJ-868


# blkid
/dev/sda2: UUID="093d0c10-1978-49c3-a79d-a170b14bac59" TYPE="ext4" 
/dev/sda3: UUID="56e1f9cb-2192-4687-a97b-0d98ebb25a52" TYPE="swap"


# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.8G   12K  3.8G   1% /dev
tmpfs           771M  1.5M  770M   1% /run
/dev/sda2       228G   12G  205G   6% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            3.8G  120M  3.7G   4% /run/shm
none            100M   44K  100M   1% /run/user


# pydf -h
Filesystem Size Used Avail Use%                 Mounted on
/dev/sda2  227G  11G  204G  5.0 [#............] /








沒有留言:

張貼留言