天天看點

6月14日任務4.1-4.4

4.1 df指令

4.2 du指令

4.3/4.4 磁盤分區

擴充學習 parted分區gpt格式 http://www.apelearn.com/bbs/thread-7243-1-1.html

4.1 df指令(磁盤容量指令)

1、df指令

[[email protected] ~]# df

檔案系統 1K-塊 已用 可用 已用% 挂載點

/dev/sda3 16849920 3486448 13363472 21% /

devtmpfs 927892 0 927892 0% /dev

tmpfs 937740 0 937740 0% /dev/shm

tmpfs 937740 9128 928612 1% /run

tmpfs 937740 0 937740 0% /sys/fs/cgroup

/dev/sda1 201380 115300 86080 58% /boot

tmpfs 187548 0 187548 0% /run/user/0
           

2、-h 根據具體的大小來顯示不同的機關

[[email protected] ~]# df -h

檔案系統 容量 已用 可用 已用% 挂載點

/dev/sda3 17G 3.4G 13G 21% /

devtmpfs 907M 0 907M 0% /dev

tmpfs 916M 0 916M 0% /dev/shm

tmpfs 916M 9.0M 907M 1% /run

tmpfs 916M 0 916M 0% /sys/fs/cgroup

/dev/sda1 197M 113M 85M 58% /boot

tmpfs 184M 0 184M 0% /run/user/0
           

3、tmpfs 是一個臨時檔案系統,即使寫了東西進去,重新開機也會消失

/dev/shm是記憶體

4、free

[[email protected] ~]# free -h

total used free shared buff/cache available

Mem: 1.8G 133M 1.4G 8.9M 215M 1.5G

Swap: 3.7G 0B 3.7G
           

5、 df -i 顯示inode

[[email protected] ~]# df -i

檔案系統 Inode 已用(I) 可用(I) 已用(I)% 挂載點

/dev/sda3 8430080 123723 8306357 2% /

devtmpfs 231973 382 231591 1% /dev

tmpfs 234435 1 234434 1% /dev/shm

tmpfs 234435 525 233910 1% /run

tmpfs 234435 16 234419 1% /sys/fs/cgroup

/dev/sda1 102400 328 102072 1% /boot

tmpfs 234435 1 234434 1% /run/user/0

有時候顯示空間還有富餘,但寫不進資料,可以檢視inode是否有剩餘
           

6、df -m 以m為機關顯示容量

[[email protected] ~]# df -m

檔案系統 1M-塊 已用 可用 已用% 挂載點

/dev/sda3 16455 3405 13051 21% /

devtmpfs 907 0 907 0% /dev

tmpfs 916 0 916 0% /dev/shm

tmpfs 916 9 907 1% /run

tmpfs 916 0 916 0% /sys/fs/cgroup

/dev/sda1 197 113 85 58% /boot

tmpfs 184 0 184 0% /run/user/0

           

4.2 du指令

1、

[[email protected] ~]# du -sh /

du: 無法通路"/proc/3057/task/3057/fd/4": 沒有那個檔案或目錄

du: 無法通路"/proc/3057/task/3057/fdinfo/4": 沒有那個檔案或目錄

du: 無法通路"/proc/3057/fd/4": 沒有那個檔案或目錄

du: 無法通路"/proc/3057/fdinfo/4": 沒有那個檔案或目錄

3.4G /

[[email protected] ~]# du -sh /etc/

40M /etc/

           

2、-s 表示求和

當這個檔案小于4KB的時候,也會顯示4KB

1個塊隻能有一個檔案,不能多個檔案占用一個檔案

4.3-4.4 磁盤分區(上,下)

1、右擊虛拟機視窗上方的标簽,點選設定

6月14日任務4.1-4.4

2、

6月14日任務4.1-4.4
6月14日任務4.1-4.4
6月14日任務4.1-4.4
6月14日任務4.1-4.4
6月14日任務4.1-4.4

3、添加之前隻有一塊磁盤,添加之後有兩塊磁盤

[[email protected] ~]# fdisk -l



磁盤 /dev/sda:21.5 GB, 21474836480 位元組,41943040 個扇區

Units = 扇區 of 1 * 512 = 512 bytes

扇區大小(邏輯/實體):512 位元組 / 512 位元組

I/O 大小(最小/最佳):512 位元組 / 512 位元組

磁盤标簽類型:dos

磁盤辨別符:0x000c0f6f



裝置 Boot Start End Blocks Id System

/dev/sda1 * 2048 411647 204800 83 Linux

/dev/sda2 411648 8222719 3905536 82 Linux swap / Solaris

/dev/sda3 8222720 41943039 16860160 83 Linux

[[email protected] ~]# reboot



[[email protected] ~]# fdisk -l



磁盤 /dev/sda:21.5 GB, 21474836480 位元組,41943040 個扇區

Units = 扇區 of 1 * 512 = 512 bytes

扇區大小(邏輯/實體):512 位元組 / 512 位元組

I/O 大小(最小/最佳):512 位元組 / 512 位元組

磁盤标簽類型:dos

磁盤辨別符:0x000c0f6f



裝置 Boot Start End Blocks Id System

/dev/sda1 * 2048 411647 204800 83 Linux

/dev/sda2 411648 8222719 3905536 82 Linux swap / Solaris

/dev/sda3 8222720 41943039 16860160 83 Linux



磁盤 /dev/sdb:10.7 GB, 10737418240 位元組,20971520 個扇區

Units = 扇區 of 1 * 512 = 512 bytes

扇區大小(邏輯/實體):512 位元組 / 512 位元組

I/O 大小(最小/最佳):512 位元組 / 512 位元組
           

4、w

[[email protected] ~]# w

20:14:59 up 29 min, 2 users, load average: 0.00, 0.01, 0.04

USER TTY FROM [email protected] IDLE JCPU PCPU WHAT

root tty1 20:14 11.00s 0.03s 0.03s -bash

root pts/0 192.168.171.1 19:49 3.00s 0.07s 0.00s w
           

5、

[[email protected] ~]# fdisk /dev/sdb

歡迎使用 fdisk (util-linux 2.23.2)。



更改将停留在記憶體中,直到您決定将更改寫入磁盤。

使用寫入指令前請三思。



Device does not contain a recognized partition table

使用磁盤辨別符 0xd85aa7d9 建立新的 DOS 磁盤标簽。



指令(輸入 m 擷取幫助):m

指令操作

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)



指令(輸入 m 擷取幫助):



主分區+擴充分區< =4
           

轉載于:https://my.oschina.net/u/3873515/blog/1833088

繼續閱讀