- 追加された行はこの色です。
- 削除された行はこの色です。
**LVMの操作 [#rd7c7df4]
RIGHT:更新日 &lastmod();
Disk2 Disk3 Disk4
---------- ----------- ----------
| | | | | |
| XXGB | | YYG | | ZZGB | 物理Disk
| | | | | |
---------- ----------- ----------
| | |
V V V
---------- ----------- ----------
| | | | | |
| sdb1 | | sdc1 | | sdd1 | 物理ボリューム(PV)
| | | | | |
---------- ----------- ----------
| | |
V V V
-----------------------------------------
| | 論理ボリュームグループ(VG)
| Volume 00 |
-----------------------------------------
| |
V V
---------------- -----------------
| | | | 論理ボリューム(LV)
| Log Vol 01 | | Log Vol 02 |
---------------- -----------------
| |
V V
/mnt1 /mnt2 マウントポイント
***物理ボリュームの作成 [#r1c9aed2]
# /sbin/fdisk /dev/sdb1
/dev/sdb1 1 783 6289416 8e Linux LVM
# /sbin/fdisk -l
Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 783 6289416 8e Linux LVM
Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 1044 8385898+ 8e Linux LVM
Disk /dev/sde: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 1305 10482381 8e Linux LVM
***物理ボリュームの作成 [#v230b637]
パーティションを物理ボリュームとして初期化
# /usr/sbin/pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
# /usr/sbin/pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
# /usr/sbin/pvcreate /dev/sde1
Physical volume "/dev/sde1" successfully created
LVMの領域として利用するすべての物理ボリュームに対して、初期化が完了した物理ボリュームは、/sbin/pvscanで確認
# /sbin/pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [15.88 GB / 0 free]
PV /dev/sdb1 lvm2 [6.00 GB]
PV /dev/sdc1 lvm2 [8.00 GB]
PV /dev/sde1 lvm2 [10.00 GB]
Total: 4 [39.87 GB] / in use: 1 [15.88 GB] / in no VG: 3 [23.99 GB]
***ボリュームグループの作成 [#wc95adf8]
# /usr/sbin/vgcreate VolGroup01 /dev/sdb1 /dev/sdc1 /dev/sde1
Volume group "VolGroup01" successfully created
***ボリュームグループの確認 [#s7116984]
# /sbin/vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup01" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
***ボリュームグループの削除 [#v78259d8]
# /usr/sbin/vgremove Volume00
Volume group "Volume00" successfully removed
''PE(Physical Extent) ''
ボリュームグループはPEという単位の集まり、PEの大きさはデフォルトでは4MB、つのボリュームグループは最大64K個までのPE、デフォルトでは1つのボリュームグループの大きさは最大で256GB(4MB X 64k) vgcreateコマンドの -s オプションでPEのサイズを変更可能。
***論理ボリュームの作成 [#k48cdce2]
7GBの論理ボリューム(LogVol01)をボリュームグループ(VolGroup01)から作成
# /usr/sbin/lvcreate -L 7G -n LogVol01 VolGroup01
Logical volume "LogVol01" created
***論理ボリュームの確認 [#l886aeed]
# /usr/sbin/lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup01/LogVol01
VG Name VolGroup01
LV UUID 8vxvb9-1O1c-EwyS-W5N9-Fpsv-g8xO-MH0efZ
LV Write Access read/write
LV Status available
# open 0
LV Size 7.00 GB
Current LE 1792
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
***論理ボリュームの削除 [#e19b65ad]
# /usr/sbin/lvremove /dev/VolGroup01/LogVol01
Do you really want to remove active logical volume LogVol01? [y/n]: y
Logical volume "LogVol01" successfully removed
「/dev/ボリュームグループ名/論理ボリューム名」となる
***論理ボリュームのフォーマット [#g92970cb]
# /sbin/mkfs -t ext3 /dev/VolGroup01/LogVol11
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
(略)
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
''マウント''
# mount /dev/VolGroup01/LogVol11 /mnt1
# mount
/dev/mapper/VolGroup01-LogVol11 on /mnt1 type ext3 (rw)
**LVの拡大/縮小 [#e19dc0ad]
***LVのサイズ拡大 [#v1428ee9]
# /usr/sbin/lvextend -L +1024M /dev/VolGroup01/LogVol11
Extending logical volume LogVol11 to 8.00 GB
Logical volume LogVol11 successfully resized
***FileSystemの拡大(ext3/ext4) [#ibead5f9]
# /sbin/resize2fs /dev/VolGroup01/LogVol11
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup01/LogVol11 is mounted on /mnt1; on-line resizing required
Performing an on-line resize of /dev/VolGroup01/LogVol11 to 2097152 (4k) blocks.
The filesystem on /dev/VolGroup01/LogVol11 is now 2097152 blocks long.
# df
/dev/mapper/VolGroup01-LogVol11
8256952 363528 7474008 5% /mnt1
***LVのサイズ縮小 [#oce3dd4d]
縮小時はumountの必要あり
FileSystemの縮小(ext3/ext4)(6GBに)
# umount /mnt1
# /sbin/fsck.ext3 -f /dev/VolGroup01/LogVol11
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup01/LogVol11: 10076/1048576 files (0.1% non-contiguous), 123796/2097152 blocks
# /sbin/resize2fs /dev/VolGroup01/LogVol11 6G
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/VolGroup01/LogVol11 to 1572864 (4k) blocks.
The filesystem on /dev/VolGroup01/LogVol11 is now 1572864 blocks long.
***LVのサイズ縮小(-2GB) [#aa47800e]
# /usr/sbin/lvreduce -L -2GB /dev/VolGroup01/LogVol11
WARNING: Reducing active logical volume to 6.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LogVol11? [y/n]: y
Reducing logical volume LogVol11 to 6.00 GB
Logical volume LogVol11 successfully resized
# mount -t ext3 /dev/VolGroup01/LogVol11 /mnt
# df
/dev/mapper/VolGroup01-LogVol11
6192704 361740 5579308 7% /mnt
**参考 [#g5a4b357]
-https://www.miraclelinux.com/technet/document/linux/training/2_2_3.html#training2_2_3_1
http://pantora.net/pages/linux/lvm/3/