LVMの使い方をすぐ忘れてしまうので、覚え書き。
LVM用のパーティションを用意しておいてください。ここでは/dev/sda7とします。
基本編
物理ボリューム作成する
# pvcreate /dev/sda7
確認する
# pvdisplay --- Physical volume --- PV Name /dev/sda7 VG Name vol1 PV Size 672.28 GiB / not usable 3.13 MiB Allocatable yes PE Size 4.00 MiB Total PE 172102 Free PE 171846 Allocated PE 256 PV UUID xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx
ボリュームグループを、vg1という名前で作成する。
# vgcreate vg1 /dev/sda7 Volume group "vg1" successfully created
確認する
# vgdisplay --- Volume group --- VG Name vg1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 672.27 GiB PE Size 4.00 MiB Total PE 172102 Alloc PE / Size 256 / 1.00 GiB Free PE / Size 171846 / 671.27 GiB VG UUID xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-zzzzzz
1GBのロジカルボリュームを、lvol1という名前で vol1 から切り出す
# lvcreate -L 1G -n lv1 vg1 Logical volume "lv1" created
確認する
# lvdisplay --- Logical volume --- LV Name /dev/vg1/lv1 VG Name vg1 LV UUID xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-wwwwww LV Write Access read/write LV Status available # open 0 LV Size 1.00 GiB Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
以上で、/dev/vg1/lv1 を普通のパーティションのように使用できます。
ちなみに、削除は、lvremove, vgremove といったコマンドを使いますし、名前を変更したいならば、vgrenameやlvrenameを使いますが、ここでは省略します。
次ページの応用編に備えて、とりあえずファイルシステム作成しておきます。
# mke2fs -j /dev/vg1/lv1
次は応用編