ページ更新: 2003-12-14 (日) (5028日前)
[編集]

LVを消す。 #

LV (/dev/vghda/lvol1) を消し、VG (/dev/vghda) を消すには、次のようにする。

現在の構成はこうなっている:

# df
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3              35G  8.4G   24G  26% /
/dev/vghda/lvol1       97M  4.1M   87M   5% /mnt

ちなみに、このLVは次のようにして作成した:

 (/dev/hda1のpartition typeを8eに設定しておく。cfdiskとかfdiskとかで)

# pvcreate /dev/hda1
pvcreate -- physical volume "/dev/hda1" successfully created

# vgcreate vghda /dev/hda1
vgcreate -- INFO: using default physical extent size 4 MB
vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte
vgcreate -- doing automatic backup of volume group "vghda"
vgcreate -- volume group "vghda" successfully created and activated

# lvcreate -L 100M /dev/vghda
lvcreate -- doing automatic backup of "vghda"
lvcreate -- logical volume "/dev/vghda/lvol1" successfully created

ここで /dev/vghda/lvol1 を消すには、まずは、umountして、

# umount /mnt

# df
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3              35G  8.4G   24G  26% /

LVを消す。lvdisplayで状態を確認、lvremoveで消し、lvscanを実行(不要かもしれないが)。

# lvdisplay /dev/vghda/lvol1
--- Logical volume ---
LV Name                /dev/vghda/lvol1
VG Name                vghda
LV Write Access        read/write
LV Status              available
LV #                   1
# open                 0
LV Size                100 MB
Current LE             25
Allocated LE           25
Allocation             next free
Read ahead sectors     120
Block device           58:0
# lvscan
lvscan -- ACTIVE            "/dev/vghda/lvol1" [100 MB]
lvscan -- 1 logical volumes with 100 MB total in 1 volume group
lvscan -- 1 active logical volumes

# lvremove /dev/vghda/lvol1
lvremove -- do you really want to remove "/dev/vghda/lvol1"? [y/n]: y
lvremove -- doing automatic backup of volume group "vghda"
lvremove -- logical volume "/dev/vghda/lvol1" successfully removed

# lvscan
lvscan -- no logical volumes found

VGを消す。vgdisplayで状態を確認、vgchangeで'non-active'にしてから、vgremoveで消し、vgscanでLVMの状態を更新する(不要かもしれないが)。

# vgdisplay /dev/vghda
--- Volume group ---
VG Name               vghda
VG Access             read/write
VG Status             available/resizable
VG #                  0
MAX LV                256
Cur LV                0
Open LV               0
MAX LV Size           255.99 GB
Max PV                256
Cur PV                1
Act PV                1
VG Size               972 MB
PE Size               4 MB
Total PE              243
Alloc PE / Size       0 / 0
Free  PE / Size       243 / 972 MB
VG UUID               Z8tTn5-XUth-NN3D-BLXk-iKc0-krc5-zhYFv3

# vgscan
vgscan -- reading all physical volumes (this may take a while...)
vgscan -- found active volume group "vghda"
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume group
# vgchange -an /dev/vghda
vgchange -- volume group "vghda" successfully deactivated
# vgremove /dev/vghda
vgremove -- volume group "vghda" successfully removed
# vgscan
vgscan -- reading all physical volumes (this may take a while...)
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume group

PV (/dev/hda1) を消すのは、cfdiskやfdiskを使う。 で、上記のVGに属しているPVってどうやって調べるの?

# pvdisplay /dev/hda1
pvdisplay -- "/dev/hda1" is a new physical volume of 976.47 MB
# pvscan
pvscan -- reading all physical volumes (this may take a while...)
pvscan -- inactive PV "/dev/hda1" is in no VG  [976.47 MB]
pvscan -- total: 1 [976.47 MB] / in use: 0 [0] / in no VG: 1 [976.47 MB]