歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Linux中df命令查詢磁盤信息和fdisk命令分區的用法

Linux中df命令查詢磁盤信息和fdisk命令分區的用法

日期:2017/3/1 17:32:20   编辑:Linux技術

df - 報告文件系統磁盤空間的使用情況

總覽

df [OPTION]... [FILE]... POSIX 選項: [-kP]

GNU 選項 (最短方式): [-ahHiklmPv] [-t fstype] [-x fstype] [--block-size=size] [--print-type] [--no-sync] [--sync] [--help] [--version] [--]

描述

此手冊頁文檔是df的GNU版本. df命令列出指定的每一個文件名所在的文件系統上可用磁盤空間的數量。 如果沒有指定文件名,則顯示當前所有使用中的文件系統.缺省設置時, 磁盤空間以1K為一塊顯示,如果環境變量POSIXLY_CORRECT已設 置,則采用512字節為一塊顯示. 如果參數是一個包含已使用文件系統的磁盤設備名, df命令顯示出的是該文件系統的可用空間,而非包含設備結點的文件系 統(只能是根文件系統).此版本的df不能顯示未使用文件系統的可用空 間,這是由於大多數系統在響應這樣的請求時必須很清楚該文件系統的 結構.

GNU 參數說明

-a, --all
列出包括BLOCK為0的文件系統
--block-size=SIZE use SIZE-byte blocks
指定塊的大小
-h,--huma-readable
用常見的格式顯示出大小(例如:1K 234M 2G)
-H,--si
同上,但是這裡的1k等於1000字節而不是1024字節
-i, --inodes
用信息索引點代替塊表示使用狀況
-k, --kilobytes
指定塊大小等於1024字節來顯示使用狀況
-l, --local
只顯示本地文件系統使用狀況
-m, --megabytes
以指定塊大小等於1048576字節(1M)來顯示使用狀況
--no-sync
在取得使用信息前禁止調用同步 (default)
-P, --portability
使用POSIX格式輸出
--sync
在取得使用信息前調用同步
-t, --type=TYPE
只顯示指定類型(TYPE)的文件系統
-T, --print-type
輸出每個文件系統的類型
-x, --exclude-type=TYPE
只顯示指定類型(TYPE)之外的文件系統.
-v (忽略)
--help
輸出該命令的幫助信息並退出
--version
輸出版本信息並退出

例:


復制代碼代碼如下:
[root@localhost ~]# df #列出各文件系統的磁盤空間使用情況
[root@localhost ~]# df -ia #列出各文件系統的i節點使用情況
[root@localhost ~]# df -T #列出文件系統的類型
[root@localhost ~]# df -h #目前磁盤空間和使用情況 以更易讀的方式顯示
[root@localhost ~]# df -k #以單位顯示磁盤的使用情況



fdisk磁盤分區命令

-v
打印 fdisk 的版本信息並退出.
-l
列出指定設備的分區表信息並退出。 如果沒有給出設備,那麼使用那些在 /proc/partitions (如果存在)提到的.
-u
以扇區數而不是以柱面數的形式顯示分區表中各分區的信息. -s 分區 將分區的 大小 (單位為塊)信息輸出到標准輸出

例a,查看所有分區

復制代碼代碼如下:
[root@localhost ~]# fdisk -l </p> <p>Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes</p> <p> Device Boot Start End Blocks Id System
/dev/sda1 * 1 17 136552 83 Linux
/dev/sda2 18 279 2104515 82 Linux swap / Solaris
/dev/sda3 280 60801 486142965 5 Extended
/dev/sda5 280 60801 486142964+ 83 Linux

例b,fdisk分區

復制代碼代碼如下:
[root@localhost ~]# fdisk /dev/hdc #分區時,不要加上數字
The number of cylinders for this disk is set to 5005.
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., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
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 #改變分區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): p
Disk /dev/hdc: 41.1 GB, 41174138880 bytes #磁盤名稱和大小
255 heads, 63 sectors/track, 5005 cylinders #磁頭、磁區與磁柱數量,多少
Units = cylinders of 16065 * 512 = 8225280 bytes #每個磁柱的大小
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 13 104391 83 Linux
/dev/hdc2 14 1288 10241437+ 83 Linux
/dev/hdc3 1289 1925 5116702+ 83 Linux
/dev/hdc4 1926 5005 24740100 5 Extended
/dev/hdc5 1926 2052 1020096 82 Linux swap / Solaris
Command (m for help): q # q是不保存退出,w不要隨便輸入

例c,-c 以柱面顯示

復制代碼代碼如下:
[root@server7 ~]# fdisk -cl /dev/vdb
Disk /dev/vdb: 8589 MB, 8589934592 bytes
16 heads, 63 sectors/track, 16644 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce720981
Device Boot Start End Blocks Id System
/dev/vdb1 3 206 102400 83 Linux
/dev/vdb2 206 409 102400 83 Linux
/dev/vdb3 409 612 102400 83 Linux
[root@server7 ~]# fdisk -ul /dev/vdb
Disk /dev/vdb: 8589 MB, 8589934592 bytes
16 heads, 63 sectors/track, 16644 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce720981
Device Boot Start End Blocks Id System
/dev/vdb1 2048 206847 102400 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vdb2 206848 411647 102400 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/vdb3 411648 616447 102400 83 Linux
Partition 3 does not end on cylinder boundary.

Copyright © Linux教程網 All Rights Reserved