差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| linux:lvm [2009/07/21 02:43] – ともやん | linux:lvm [2019/05/18 02:23] (現在) – 外部編集 非ログインユーザー | ||
|---|---|---|---|
| 行 42: | 行 42: | ||
| ===== LVM の PV、VG、LV について ===== | ===== LVM の PV、VG、LV について ===== | ||
| LVM では、PV(Physical Volume - 物理ボリューム)を作成し、PV を1つ以上使って VG(Volume Group - ボリュームグループ)を作成する。\\ | LVM では、PV(Physical Volume - 物理ボリューム)を作成し、PV を1つ以上使って VG(Volume Group - ボリュームグループ)を作成する。\\ | ||
| - | そして、VG(ボリュームグループ) の中に LV(Physical | + | そして、VG(ボリュームグループ) の中に LV(Logical |
| LV(論理ボリューム) には、ext4 などのファイルシステムを作成して利用する。\\ | LV(論理ボリューム) には、ext4 などのファイルシステムを作成して利用する。\\ | ||
| \\ | \\ | ||
| 行 48: | 行 48: | ||
| VG(ボリュームグループ) の空き容量がなくなってきた場合は、新しい PV(物理ボリューム) を VG(ボリュームグループ) に追加することで、簡単に容量を増やすことがきる。\\ | VG(ボリュームグループ) の空き容量がなくなってきた場合は、新しい PV(物理ボリューム) を VG(ボリュームグループ) に追加することで、簡単に容量を増やすことがきる。\\ | ||
| - | ===== PV(Physical Volume - 物理ボリューム) の作成 ===== | + | ===== PV(物理ボリューム) の作成 ===== |
| - pvcreate コマンドを使用して PV(物理ボリューム) を初期化する。< | - pvcreate コマンドを使用して PV(物理ボリューム) を初期化する。< | ||
| # pvcreate /dev/sdb1 | # pvcreate /dev/sdb1 | ||
| 行 77: | 行 77: | ||
| Allocated PE 0 | Allocated PE 0 | ||
| PV UUID | PV UUID | ||
| + | </ | ||
| + | ===== VG(ボリュームグループ) の作成 ===== | ||
| + | < | ||
| + | # vgcreate vg_monster1 /dev/sdb1 | ||
| + | Volume group " | ||
| + | </ | ||
| + | < | ||
| + | # vgdisplay | ||
| + | --- Volume group --- | ||
| + | VG Name | ||
| + | System ID | ||
| + | Format | ||
| + | Metadata Areas 1 | ||
| + | Metadata Sequence No 1 | ||
| + | VG Access | ||
| + | VG Status | ||
| + | MAX LV 0 | ||
| + | Cur LV 0 | ||
| + | Open LV 0 | ||
| + | Max PV 0 | ||
| + | Cur PV 1 | ||
| + | Act PV 1 | ||
| + | VG Size 2.61 TB | ||
| + | PE Size 4.00 MB | ||
| + | Total PE 684826 | ||
| + | Alloc PE / Size 0 / 0 | ||
| + | Free PE / Size | ||
| + | VG UUID | ||
| + | </ | ||
| + | ===== VG(ボリュームグループ) の拡張 ===== | ||
| + | VG(ボリュームグループ) に PV(物理ボリューム) を追加する。 | ||
| + | < | ||
| + | # vgextend vg_monster /dev/sdb1 | ||
| + | Volume group " | ||
| + | </ | ||
| + | < | ||
| + | # vgdisplay | ||
| + | --- Volume group --- | ||
| + | VG Name | ||
| + | System ID | ||
| + | Format | ||
| + | Metadata Areas 2 | ||
| + | Metadata Sequence No 14 | ||
| + | VG Access | ||
| + | VG Status | ||
| + | MAX LV 0 | ||
| + | Cur LV 2 | ||
| + | Open LV 2 | ||
| + | Max PV 0 | ||
| + | Cur PV 2 | ||
| + | Act PV 2 | ||
| + | VG Size 2.73 TB | ||
| + | PE Size 4.00 MB | ||
| + | Total PE 715291 | ||
| + | Alloc PE / Size 30465 / 119.00 GB | ||
| + | Free PE / Size | ||
| + | VG UUID | ||
| + | </ | ||
| + | ===== LV(論理ボリューム) の拡張 ===== | ||
| + | < | ||
| + | # lvdisplay | ||
| + | --- Logical volume --- | ||
| + | LV Name / | ||
| + | VG Name vg_monster | ||
| + | LV UUID oclD9d-LSdM-tWs8-gYmh-O34O-1RJK-L3YunN | ||
| + | LV Write Access | ||
| + | LV Status | ||
| + | # open 1 | ||
| + | LV Size 115.00 GB | ||
| + | Current LE 29441 | ||
| + | Segments | ||
| + | Allocation | ||
| + | Read ahead sectors | ||
| + | - currently set to 256 | ||
| + | Block device | ||
| + | |||
| + | --- Logical volume --- | ||
| + | LV Name / | ||
| + | VG Name vg_monster | ||
| + | LV UUID p3eWnk-8ifO-c8tW-uJ7Q-lO4I-0Gk7-2d1APF | ||
| + | LV Write Access | ||
| + | LV Status | ||
| + | # open 1 | ||
| + | LV Size 4.00 GB | ||
| + | Current LE 1024 | ||
| + | Segments | ||
| + | Allocation | ||
| + | Read ahead sectors | ||
| + | - currently set to 256 | ||
| + | Block device | ||
| + | </ | ||
| + | < | ||
| + | # lvextend -L +100G / | ||
| + | Extending logical volume lv_root to 215.00 GB | ||
| + | Logical volume lv_root successfully resized | ||
| + | </ | ||
| + | LV(論理ボリューム)に合わせてファイルシステムをリサイズする。 | ||
| + | < | ||
| + | # resize2fs / | ||
| + | resize2fs 1.41.4 (27-Jan-2009) | ||
| + | Filesystem at / | ||
| + | old desc_blocks = 8, new_desc_blocks = 175 | ||
| + | Performing an on-line resize of / | ||
| + | The filesystem on / | ||
| + | |||
| + | </ | ||
| + | リサイズ中の root デバイス\\ | ||
| + | {{: | ||
| + | リサイズ後の root デバイス\\ | ||
| + | {{: | ||
| + | |||
| + | ===== LV(論理ボリューム) の縮小 ===== | ||
| + | < | ||
| + | # umount /home | ||
| + | # fsck -f / | ||
| + | fsck from util-linux-ng 2.17.2 | ||
| + | e2fsck 1.41.12 (17-May-2010) | ||
| + | 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 | ||
| + | / | ||
| + | # resize2fs / | ||
| + | resize2fs 1.41.12 (17-May-2010) | ||
| + | Resizing the filesystem on / | ||
| + | The filesystem on / | ||
| + | # lvreduce -L3710018M / | ||
| + | Rounding up size to full physical extent 3.54 TiB | ||
| + | WARNING: Reducing active logical volume to 3.54 TiB | ||
| + | THIS MAY DESTROY YOUR DATA (filesystem etc.) | ||
| + | Do you really want to reduce lv_home? [y/n]: y | ||
| + | Reducing logical volume lv_home to 3.54 TiB | ||
| + | Logical volume lv_home successfully resized | ||
| + | </ | ||
| + | |||
| + | ===== 他で使用していたディスクのLVMを認識させる ===== | ||
| + | < | ||
| + | $ sudo lvscan | ||
| + | inactive | ||
| + | inactive | ||
| + | ACTIVE | ||
| + | ACTIVE | ||
| + | ACTIVE | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ sudo vgchange -ay vg_hoge | ||
| + | 2 logical volume(s) in volume group " | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ sudo vgchange -an vg_hoge | ||
| + | 0 logical volume(s) in volume group " | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ sudo lvscan | ||
| + | inactive | ||
| + | inactive | ||
| + | ACTIVE | ||
| + | ACTIVE | ||
| + | ACTIVE | ||
| </ | </ | ||