du,df指令和磁盤管理
[root@alex ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 41151808 1872588 37165788 5% /
devtmpfs 498064 0 498064 0% /dev
tmpfs 508196 0 508196 0% /dev/shm
tmpfs 508196 308 507888 1% /run
tmpfs 508196 0 508196 0% /sys/fs/cgroup
tmpfs 101640 0 101640 0% /run/user/0
第一列 檔案系統 和磁盤分區的名字 ,第二列:磁盤的大小
第三:列已使用了多少。第四列:可用的剩餘多少。
第五列:已用百分比. 第六列挂載點名稱
[root@alex ~]# df -h 加上H可以适當的看到磁盤準确的大小
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.8G 36G 5% /
devtmpfs 487M 0 487M 0% /dev
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 497M 308K 496M 1% /run
tmpfs 497M 0 497M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/0
[root@alex ~]# free
total used free shared buff/cache available
Mem: 1016396 69400 116160 312 830836 740212
Swap: 0 0 0
[root@alex ~]# df -i 檢視分區下面有多少個inodes 和inode使用情況
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 2621440 47648 2573792 2% /
devtmpfs 124516 334 124182 1% /dev
tmpfs 127049 1 127048 1% /dev/shm
tmpfs 127049 351 126698 1% /run
tmpfs 127049 16 127033 1% /sys/fs/cgroup
tmpfs 127049 1 127048 1% /run/user/0
[root@alex ~]# df -m 還可以df -m 以兆為機關檢視
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/vda1 40188 1829 36295 5% /
devtmpfs 487 0 487 0% /dev
tmpfs 497 0 497 0% /dev/shm
tmpfs 497 1 496 1% /run
tmpfs 497 0 497 0% /sys/fs/cgroup
tmpfs 100 0 100 0% /run/user/0
du 指令
檢視一個檔案的大小
[root@alex ~]# du -sh /root/
340K /root/
[root@alex ~]# du -sh /boot/
132M /boot/
[root@alex ~]# du -sh /etc/passwd
4.0K /etc/passwd
[root@alex ~]# ls -lh /etc/passwd
-rw-r--r--. 1 root root 1.4K Oct 30 21:39 /etc/passwd
對比不一樣大小 ,上面4K是塊 以最小4K為基礎
[root@alex ~]# du /etc/passwd 也可以 這樣下
4 /etc/passwd
[root@alex ~]# du /etc/ 這樣會全部列出來
16 /etc/pki/rpm-gpg
4 /etc/pki/java
[root@alex ~]# du -sh /root/ 正确的寫法 是-sh
340K /root/
磁盤挂載
[root@alex ~]# fdisk -l 可以把系統目前有的給列出來
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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 label type: dos
Disk identifier: 0x000d2717
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux
Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
如果新插入的磁盤識别不了,可以嘗試重新啟動
fdisk -l 識别新插入的磁盤
[root@alex ~]# fdisk /dev/vda 這個後面跟磁盤的名字
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
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
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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)
對照翻譯
觸發器的一個啟動标志
B編輯BSD磁盤标簽
切換DOS相容性标志
删除一個分區
G建立一個空的GPT分區表
G建立IRIX(SGI)分區表
列出已知分區類型
列印此菜單
添加一個新分區
o建立一個新的空DOS分區表
列印分區表
在不儲存更改的情況下退出
建立一個新的空太陽辨別
更改分區的系統id
更改顯示/輸入單元
v驗證分區表
将表寫入磁盤并退出
額外功能(專家隻)
按 p 按 n
Command (m for help): p
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
可以選擇p 主分區
主分區最多隻能分4個
邏輯分區 可以分多個
如果劃分4個主分區就不能再劃分了 ,就要用 d 預設從第四個删除
所有的操作取消 按 q 按 w是儲存
l是邏輯分區的劃法
總結 分區 n 出現提示 主分區 還是擴充分區
選擇p或者l 然後選擇 幾個G 然後 w
本文轉自 amenging 51CTO部落格,原文連結:http://blog.51cto.com/11335852/1978644