日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux从入门到精通——磁盘与目录的容量(du、df)

發布時間:2024/4/17 linux 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux从入门到精通——磁盘与目录的容量(du、df) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

###Linux中的磁盤與目錄的容量###

1.Linux 磁盤管理

?

  Linux磁盤管理好壞直接關系到整個系統的性能問題。

  Linux磁盤管理常用三個命令為df、du和fdisk。

    df:列出文件系統的整體磁盤使用量

    du:評估文件系統的磁盤使用量(常用于目錄所占容量)

    fdisk:用于磁盤分區

?

2.df命令  選項與參數:

    -a :列出所有的文件系統,包括系統特有的 /proc 等文件系統; 

    -k :以 KBytes 的容量顯示各文件系統;

    -m :以 MBytes 的容量顯示各文件系統;

    -h :以人們較易閱讀的 GBytes, MBytes, KBytes 等格式自行顯示;

    -H :以 M=1000K 取代 M=1024K 的進位方式;

    -T :顯示文件系統類型, 連同該 partition 的 filesystem 名稱 也列出;

    -i :不用硬盤容量,而以 inode 的數量、剩余容量等,來顯示;

?

  實例 1

  將系統內所有的文件系統列出來!

  [root@www ~]# dfFilesystem 1K-blocks Used Available Use% Mounted on   /dev/hdc2 9920624 3823112 5585444 41% /   /dev/hdc3 4956316 141376 4559108 4% /home   /dev/hdc1 101086 11126 84741 12% /boot   tmpfs 371332 0 371332 0% /dev/shm

  在 Linux 底下如果 df 沒有加任何選項,那么默認會將系統內所有的 (不含特殊內存內的文件系統與 swap) 都以 1 Kbytes 的容量來列出來!

  實例 2

  將容量結果以易讀的容量格式顯示出來

  [root@www ~]# df -h   Filesystem Size Used Avail Use% Mounted on   /dev/hdc2 9.5G 3.7G 5.4G 41% /   /dev/hdc3 4.8G 139M 4.4G 4% /home   /dev/hdc1 99M 11M 83M 12% /boot   tmpfs 363M 0 363M 0% /dev/shm

  實例 3

  將系統內的所有特殊文件格式及名稱都列出來

  [root@www ~]# df -aT   Filesystem Type 1K-blocks Used Available Use% Mounted on   /dev/hdc2 ext3 9920624 3823112 5585444 41% /   proc proc 0 0 0 - /proc   sysfs sysfs 0 0 0 - /sys   devpts devpts 0 0 0 - /dev/pts   /dev/hdc3 ext3 4956316 141376 4559108 4% /home   /dev/hdc1 ext3 101086 11126 84741 12% /boot   tmpfs tmpfs 371332 0 371332 0% /dev/shm   none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc   sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs

  實例 4

  將 /etc 底下的可用的磁盤容量以易讀的容量格式顯示

  [root@www ~]# df -h /etc   Filesystem Size Used Avail Use% Mounted on   /dev/hdc2 9.5G 3.7G 5.4G 41% /

  輸出結果信息:
  filesystem:表示該文件系統是在哪個分區,所以列出設備的名稱
  1k-blocks:表示下面的數字的單位是KB。可以利用 -h 或者 -m 改變容量的單位
  used:表示已經使用的磁盤的大小
  avaliable:表示磁盤空間剩余的空間大小
  use%:表示磁盤的使用率
  mounte on:表示磁盤掛載的目錄

3.du命令
  
選項與參數:

    -a :列出所有的文件與目錄容量,因為默認僅統計目錄底下的文件量而已。

    -h :以人們較易讀的容量格式 (G/M) 顯示;

    -s :列出總量而已,而不列出每個各別的目錄占用容量;

    -S :不包括子目錄下的總計,與 -s 有點差別。

    -k :以 KBytes 列出容量顯示;

    -m :以 MBytes 列出容量顯示;

  實例 1

  列出目前目錄下的所有文件容量

  [root@www ~]# du

  8 ./test4 <==每個目錄都會列出來   8 ./test2   ....中間省略....   12 ./.gconfd <==包括隱藏文件的目錄   220 . <==這個目錄(.)所占用的總量

直接輸入 du 沒有加任何選項時,則 du 會分析當前所在目錄的文件與目錄所占用的硬盤空間。

  實例 2

  將文件的容量也列出來

  [root@www ~]# du -a

  12 ./install.log.syslog <==有文件的列表了

  8 ./.bash_logout

  8 ./test4

  8 ./test2

  ....中間省略....

 12 ./.gconfd  220 .

  實例 3

  檢查根目錄底下每個目錄所占用的容量

  [root@www ~]# du -sm /*   7 /bin   6 /boot   .....中間省略....   0 /proc   .....中間省略....   1 /tmp   3859 /usr <==系統初期最大就是他了啦!   77 /var

  通配符 * 來代表每個目錄。與 df 不一樣的是,du 這個命令其實會直接到文件系統內去搜尋所有的文件數據。

?

4.fdisk命令

  fdisk 是 Linux 的磁盤分區表操作工具。

?

  語法:fdisk [-l] 裝置名稱

?

  選項與參數:  -l :輸出后面接的裝置所有的分區內容。若僅有 fdisk -l 時, 則系統將會把整個系統內能夠搜尋到的裝置的分區均列出來。

?

?

  實例 1

  列出所有分區信息

?

  [root@AY120919111755c246621 tmp]# fdisk -l   Disk /dev/xvda: 21.5 GB, 21474836480 bytes   255 heads, 63 sectors/track, 2610 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: 0x00000000 Device Boot Start End Blocks Id System   /dev/xvda1 * 1 2550 20480000 83 Linux   /dev/xvda2 2550 2611 490496 82 Linux swap / Solaris   Disk /dev/xvdb: 21.5 GB, 21474836480 bytes   255 heads, 63 sectors/track, 2610 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: 0x56f40944 Device Boot Start End Blocks Id System   /dev/xvdb2 1 2610 20964793+ 83 Linux

?

  實例 2

?

  找出你系統中的根目錄所在磁盤,并查閱該硬盤內的相關信息

?

  [root@www ~]# df / <==注意:重點在找出磁盤文件名而已   Filesystem 1K-blocks Used Available Use% Mounted on   /dev/hdc2 9920624 3823168 5585388 41% /   [root@www ~]# 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 (m for help): m <== 輸入 m 后,就會看到底下這些命令介紹   Command action   a toggle a bootable flag   b edit bsd disklabel   c toggle the dos compatibility flag   d delete a partition <==刪除一個partition    l list known partition types    m print this menu   n add a new partition <==新增一個partition   o create a new empty DOS partition table    p print the partition table <==在屏幕上顯示分割表   q quit without saving changes <==不儲存離開fdisk程序    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)

?

  離開 fdisk 時按下?q,那么所有的動作都不會生效!相反的, 按下w就是動作生效的意思。

?

  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   # 裝置文件名 啟動區否 開始磁柱 結束磁柱 1K大小容量 磁盤分區槽內的系統   Command (m for help): q

?

  想要不儲存離開嗎?按 q?

?

  使用?p?可以列出目前這顆磁盤的分割表信息,這個信息的上半部在顯示整體磁盤的狀態。

?

?

?

?

轉載于:https://www.cnblogs.com/wf-aiyouwei/p/10414508.html

總結

以上是生活随笔為你收集整理的Linux从入门到精通——磁盘与目录的容量(du、df)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。