差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
linux:lvm [2009/07/21 02:34] – 作成 ともやん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 Volume - 論理ボリューム) をマッピングして作成する。\\+ そして、VG(ボリュームグループ) の中に LV(Logical Volume - 論理ボリューム) をマッピングして作成する。\\
  LV(論理ボリューム) には、ext4 などのファイルシステムを作成して利用する。\\  LV(論理ボリューム) には、ext4 などのファイルシステムを作成して利用する。\\
 \\ \\
行 48: 行 48:
  VG(ボリュームグループ) の空き容量がなくなってきた場合は、新しい PV(物理ボリューム) を VG(ボリュームグループ) に追加することで、簡単に容量を増やすことがきる。\\  VG(ボリュームグループ) の空き容量がなくなってきた場合は、新しい PV(物理ボリューム) を VG(ボリュームグループ) に追加することで、簡単に容量を増やすことがきる。\\
  
 +===== PV(物理ボリューム) の作成 =====
 +  - pvcreate コマンドを使用して PV(物理ボリューム) を初期化する。<code>
 +# pvcreate /dev/sdb1
 +  Physical volume "/dev/sdb1" successfully created
 +</code>
 +  - pvdisplay コマンドにて作成状況を確認する。<code>
 +# pvdisplay
 +  --- Physical volume ---
 +  PV Name               /dev/sda2
 +  VG Name               vg_monster
 +  PV Size               119.01 GB / not usable 4.16 MB
 +  Allocatable           yes (but full)
 +  PE Size (KByte)       4096
 +  Total PE              30465
 +  Free PE               0
 +  Allocated PE          30465
 +  PV UUID               sVhxN7-Bf8u-35yp-BmZ6-CjSd-9fOn-TNAvCv
 +   
 +  "/dev/sdb1" is a new physical volume of "2.61 TB"
 +  --- NEW Physical volume ---
 +  PV Name               /dev/sdb1
 +  VG Name               
 +  PV Size               2.61 TB
 +  Allocatable           NO
 +  PE Size (KByte)       0
 +  Total PE              0
 +  Free PE               0
 +  Allocated PE          0
 +  PV UUID               OdPiUV-biUo-gha3-cAOA-QiB1-aFyc-waev4A
 +</code>
 +===== VG(ボリュームグループ) の作成 =====
 +<code>
 +# vgcreate vg_monster1 /dev/sdb1
 +  Volume group "vg_monster1" successfully created
 +</code>
 +<code>
 +# vgdisplay
 +  --- Volume group ---
 +  VG Name               vg_monster1
 +  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               2.61 TB
 +  PE Size               4.00 MB
 +  Total PE              684826
 +  Alloc PE / Size       0 / 0   
 +  Free  PE / Size       684826 / 2.61 TB
 +  VG UUID               4YGE0j-AbaM-BKmx-9OVj-fnG8-C5jV-opCUCZ
 +</code>
 +===== VG(ボリュームグループ) の拡張 =====
 +VG(ボリュームグループ) に PV(物理ボリューム) を追加する。
 +<code>
 +# vgextend vg_monster /dev/sdb1
 +  Volume group "vg_monster" successfully extended
 +</code>
 +<code>
 +# vgdisplay
 +  --- Volume group ---
 +  VG Name               vg_monster
 +  System ID             
 +  Format                lvm2
 +  Metadata Areas        2
 +  Metadata Sequence No  14
 +  VG Access             read/write
 +  VG Status             resizable
 +  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       684826 / 2.61 TB
 +  VG UUID               y9vUDl-a5tm-1919-zViH-aaMU-hmNJ-38pcfy
 +</code>
 +===== LV(論理ボリューム) の拡張 =====
 +<code>
 +# lvdisplay
 +  --- Logical volume ---
 +  LV Name                /dev/vg_monster/lv_root
 +  VG Name                vg_monster
 +  LV UUID                oclD9d-LSdM-tWs8-gYmh-O34O-1RJK-L3YunN
 +  LV Write Access        read/write
 +  LV Status              available
 +  # open                 1
 +  LV Size                115.00 GB
 +  Current LE             29441
 +  Segments               1
 +  Allocation             inherit
 +  Read ahead sectors     auto
 +  - currently set to     256
 +  Block device           253:0
 +   
 +  --- Logical volume ---
 +  LV Name                /dev/vg_monster/lv_swap
 +  VG Name                vg_monster
 +  LV UUID                p3eWnk-8ifO-c8tW-uJ7Q-lO4I-0Gk7-2d1APF
 +  LV Write Access        read/write
 +  LV Status              available
 +  # open                 1
 +  LV Size                4.00 GB
 +  Current LE             1024
 +  Segments               1
 +  Allocation             inherit
 +  Read ahead sectors     auto
 +  - currently set to     256
 +  Block device           253:1
 +</code>
 +<code>
 +# lvextend -L +100G /dev/vg_monster/lv_root
 +  Extending logical volume lv_root to 215.00 GB
 +  Logical volume lv_root successfully resized
 +</code>
 +LV(論理ボリューム)に合わせてファイルシステムをリサイズする。
 +<code>
 +# resize2fs /dev/vg_monster/lv_root
 +resize2fs 1.41.4 (27-Jan-2009)
 +Filesystem at /dev/vg_monster/lv_root is mounted on /; on-line resizing required
 +old desc_blocks = 8, new_desc_blocks = 175
 +Performing an on-line resize of /dev/vg_monster/lv_root to 731409408 (4k) blocks.
 +The filesystem on /dev/vg_monster/lv_root is now 731409408 blocks long.
 +
 +</code>
 +リサイズ中の root デバイス\\
 +{{:linux:resize2fs_sysmon_1.png?700|リサイズ中のrootデバイス1}}\\
 +リサイズ後の root デバイス\\
 +{{:linux:resize2fs_sysmon_2.png?700|リサイズ後のrootデバイス2}}\\
 +
 +===== LV(論理ボリューム) の縮小 =====
 +<code>
 +# umount /home
 +# fsck -f /dev/mapper/vg_monster-lv_home
 +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
 +/dev/mapper/vg_monster-lv_home: 704340/241876992 files (0.3% non-contiguous), 255445351/967505920 blocks
 +# resize2fs /dev/mapper/vg_monster-lv_home 3710018M
 +resize2fs 1.41.12 (17-May-2010)
 +Resizing the filesystem on /dev/mapper/vg_monster-lv_home to 949764608 (4k) blocks.
 +The filesystem on /dev/mapper/vg_monster-lv_home is now 949764608 blocks long.
 +# lvreduce -L3710018M /dev/mapper/vg_monster-lv_home
 +  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
 +</code>
 +
 +===== 他で使用していたディスクのLVMを認識させる =====
 +<code>
 +$ sudo lvscan
 +  inactive          '/dev/vg_hoge/lv_swap' [4.00 GiB] inherit
 +  inactive          '/dev/vg_hoge/lv_root' [144.53 GiB] inherit
 +  ACTIVE            '/dev/vg_thecircle-fc/lv_swap' [3.94 GiB] inherit
 +  ACTIVE            '/dev/vg_thecircle-fc/lv_home' [201.56 GiB] inherit
 +  ACTIVE            '/dev/vg_thecircle-fc/lv_root' [50.00 GiB] inherit
 +</code>
 +
 +<code>
 +$ sudo vgchange -ay vg_hoge
 +  2 logical volume(s) in volume group "vg_hoge" now active
 +</code>
 +
 +<code>
 +$ sudo vgchange -an vg_hoge
 +  0 logical volume(s) in volume group "vg_hoge" now active
 +</code>
 +
 +<code>
 +$ sudo lvscan
 +  inactive          '/dev/vg_hoge/lv_swap' [2.00 GiB] inherit
 +  inactive          '/dev/vg_hoge/lv_root' [124.00 GiB] inherit
 +  ACTIVE            '/dev/vg_thecircle-fc/lv_swap' [3.94 GiB] inherit
 +  ACTIVE            '/dev/vg_thecircle-fc/lv_home' [201.56 GiB] inherit
 +  ACTIVE            '/dev/vg_thecircle-fc/lv_root' [50.00 GiB] inherit
 +</code>
  • linux/lvm.1248111241.txt.gz
  • 最終更新: 2019/05/18 02:23
  • (外部編集)