[root@test-01 ~]# e2label /dev/sdb3 test01 [root@test-01 ~]# e2label /dev/sdb3 test02 [root@test-01 ~]# e2label /dev/sdb3 test02 [root@test-01 ~]#
這個命令不經常使用,瞭解一下就能夠。node
磁盤分區完格式化之後就是一個塊設備了,可是不能直接向裏面寫入數據,必須掛載以後才能寫入,在掛載以前須要建立一個新的掛載點,這個掛載點是以目錄形式出現的,一旦把這個分區掛載到該掛載點下,再往這個目錄寫數據時實際上就寫在了該分區上。因此在掛載之前要肯定該目錄是個空目錄,不然以前該目錄下的數據就看不到了(沒有丟失,只是看不到了,要想看到須卸載該分區)。windows
使用mount命令能夠掛載分區,若是不加任何參數直接運行mount ,會顯示出當前系統以掛載的全部分區、分區文件系統類型、掛載點等信息。下面咱們作一個示例來驗證一下當掛載點不是空目錄的時候所形成的影響;安全
[root@test-01 ~]# ls /new 1.txt [root@test-01 ~]# mount /dev/sdb3 /new [root@test-01 ~]# ls /new lost+found [root@test-01 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 16G 854M 16G 6% / devtmpfs 909M 0 909M 0% /dev tmpfs 914M 0 914M 0% /dev/shm tmpfs 914M 8.5M 905M 1% /run tmpfs 914M 0 914M 0% /sys/fs/cgroup /dev/sda1 197M 75M 123M 38% /boot /dev/sdb3 2.0G 3.1M 1.8G 1% /new [root@test-01 ~]# umount /new [root@test-01 ~]# df -h | grep -v tmpfs 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 16G 854M 16G 6% / /dev/sda1 197M 75M 123M 38% /boot [root@test-01 ~]# ls /new 1.txt
能夠看到,當非空目錄做爲掛載點掛載分區以後,原掛載點下的文件會不被看到,也沒有丟失,當卸載掉分區以後原文件仍是存在的。除了使用mount+分區以外,還可使用mount+LABEL的方式掛載分區code
[root@test-01 ~]# mount LABEL=考試 /new [root@test-01 ~]# df -h /new 文件系統 容量 已用 可用 已用% 掛載點 /dev/sdb3 2.0G 3.1M 1.8G 1% /new
使用umount 後面能夠跟掛載點,也能夠跟分區,都是能夠卸載的,若是在該掛載點目錄中,使用umount會提示目標忙,能夠退出掛載點目錄,或者使用umount -l 命令。進程
[root@test-01 new]# umount /new umount: /new:目標忙。 (有些狀況下經過 lsof(8) 或 fuser(1) 能夠 找到有關使用該設備的進程的有用信息) [root@test-01 new]# umount /dev/sdb3 umount: /new:目標忙。 (有些狀況下經過 lsof(8) 或 fuser(1) 能夠 找到有關使用該設備的進程的有用信息) [root@test-01 new]# cd [root@test-01 ~]# umount /dev/sdb3 [root@test-01 ~]# df -h /new 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 16G 854M 16G 6% /
安裝系統時咱們就設置好了swap的大小,那麼在後期使用當中若是要給swap增長空間怎麼辦?總不能重裝系統吧? 答案是 ,能夠手動增長swap分區的大小。內存
[root@test-01 ~]# dd if=/dev/zero of=/tmp/newdisk bs=1M count=1024 記錄了1024+0 的讀入 記錄了1024+0 的寫出 1073741824字節(1.1 GB)已複製,10.9001 秒,98.5 MB/秒
[root@test-01 ~]# mkswap -f /tmp/newdisk 正在設置交換空間版本 1,大小 = 1048572 KiB 無標籤,UUID=961cbfdf-c645-4192-8899-ee2b7de95208
[root@test-01 ~]# free -m total used free shared buffers cached Mem: 1826 1329 497 8 1 1117 -/+ buffers/cache: 209 1617 Swap: 3999 0 3999 [root@test-01 ~]# swapon /tmp/newdisk swapon: /tmp/newdisk:不安全的權限 0644,建議使用 0600。 [root@test-01 ~]# chmod 0600 /tmp/newdisk [root@test-01 ~]# free -m total used free shared buffers cached Mem: 1826 1330 496 8 1 1118 -/+ buffers/cache: 210 1616 Swap: 5023 0 5023
** 小知識點,free 命令是用來查看內存和swap的使用狀況,free -m 表示顯示容量時用M爲單位。test