新建一個邏輯卷

2案例2:新建一個邏輯卷

2.1 問題

本例要求沿用前一天案例,使用分區/dev/vdb1構建LVM存儲,相關要求如下:

  1. 新建一個名爲systemvg的卷組
  2. 在此卷組中創建一個名爲vo的邏輯卷,大小爲180MiB
  3. 將邏輯卷vo格式化爲ext4文件系統
  4. 將邏輯卷vo掛載到/vo目錄,並在此目錄下建立一個測試文件votest.txt,內容爲“I AM KING.”
2.2 方案

LVM創建工具的基本用法:

vgcreate  卷組名  物理設備.. ..
lvcreate  -L  大小  -n  邏輯卷名  卷組名
2.3步驟

實現此案例需要按照如下步驟進行。

步驟三:創建卷組

1)新建名爲systemvg的卷組

[root@server0 ~]# vgcreate  systemvg  /dev/vdb1
  Physical volume "/dev/vdb1" successfully created
  Volume group "systemvg" successfully created

2)確認結果

[root@server0 ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "systemvg" using metadata type lvm2

步驟二:創建邏輯卷

1)新建名爲vo的邏輯卷

[root@server0 ~]# lvcreate  -L  180MiB  -n  vo  systemvg 
  Logical volume "vo" created

2)確認結果

[root@server0 ~]# lvscan
  ACTIVE            '/dev/systemvg/vo' [180.00 MiB] inherit

步驟三:格式化及掛載使用

1)格式化邏輯卷/dev/systemvg/vo

[root@server0 ~]# mkfs.ext4  /dev/systemvg/vo
.. ..
Allocating group tables: done 
Writing inode tables: done 
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

2)掛載邏輯卷/dev/systemvg/vo

[root@server0 ~]# mkdir  /vo                              //創建掛載點
[root@server0 ~]# mount  /dev/systemvg/vo  /vo             //掛載
[root@server0 ~]# df  -hT  /vo/                         //檢查結果
Filesystem              Type  Size  Used Avail Use% Mounted on
/dev/mapper/systemvg-vo ext4  171M  1.6M  157M   1% /vo

3)訪問邏輯卷/dev/systemvg/vo

[root@server0 ~]# cat  /vo/votest.txt
I AM KING.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章