目錄表

Linux 建立 LVM 磁碟方式

目標

要將 /dev/sdb 建立成一個 LVM 磁碟

  • 可以使用 fdisk -l 列出目前主機內的所有實體硬碟資料清單

- fdisk

:
Command (m for help): n
:
   p   primary partition (1-4) p
Partition number (1-4): 1
First cylinder (1-24321, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-24321, default 24321): 
Using default value 24321

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

- pvcreate/vgcreate

  --- Volume group ---
  VG Name               vg-seagate1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               298.09 GB
  PE Size               4.00 MB
  Total PE              76310
  Alloc PE / Size       0 / 0
  Free  PE / Size       76310 / 298.09 GB
  VG UUID               XrrB58-E5zC-OFg0-e3Ch-lNsj-wr0n-LiyH33

- create, format, and mount logical volume

看執行的內容

當在 /dev 內看不到 vg-xxx 時,可先透過 lvdisplay 確認 LV Status,如果出現的是 NOT available 可以透過 vgchange 命令來解決,Exp.
vgchange -a y vg-iscsi-01

當出現結果是 now active

[root@vm-mail ~]# vgchange -a y vg-iscsi-01
  1 logical volume(s) in volume group "vg-iscsi-01" now active

就表示正確啟動,這問題通常會出現在調整 vg 大小失敗時出現

- Resize logical volume

參考網址

1)
8.09G 會出現空間不足的問題