LoginSignup
1
1

More than 3 years have passed since last update.

LVMでボリューム同士をまとめる方法

Last updated at Posted at 2020-05-26

ホームディレクトリにでかい容量割り当てられていて、ルートボリュームとまとめてしまいたい時とかに!

現在の状況を確認

[root@cmst301 ~]# lvdisplay -C
  LV      VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home vg_cmst301 -wi-ao---- 197.68g
  lv_root vg_cmst301 -wi-ao----  50.00g
  lv_swap vg_cmst301 -wi-ao----   7.83g

対象ディレクトリのバックアップ

[root@cmst301 ~]# cp -rp /home /home_bk

fstabの以下の行をコメントアウト

/dev/mapper/vg_cmst301-lv_home /home                   ext4    defaults        1 2

homeディレクトリのマウントを解除

現在の状況
[root@cmst301 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_cmst301-lv_root
                       50G  6.0G   41G  13% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/sda1             477M   78M  374M  18% /boot
/dev/mapper/vg_cmst301-lv_home
                      195G  416M  185G   1% /home
マウント解除
[root@cmst301 ~]# umount /home

確認
[root@cmst301 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_cmst301-lv_root
                       50G  5.0G   42G  11% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/sda1             477M   78M  374M  18% /boot

論理ボリュームの削除

[root@cmst301 ~]# lvremove /dev/vg_cmst301/lv_home
Do you really want to remove active logical volume lv_home? [y/n]: y
  Logical volume "lv_home" successfully removed

論理ボリュームの拡張

[root@cmst301 ~]# lvextend -L +200G /dev/mapper/vg_cmst301-lv_root
  Size of logical volume vg_cmst301/lv_root changed from 247.49 GiB (63357 extents) to 247.59 GiB (63382 extents).
  Logical volume lv_root successfully resized.

ファイルシステムの拡張

[root@cmst301 ~]# resize2fs /dev/mapper/vg_cmst301-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_cmst301-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 16
Performing an on-line resize of /dev/mapper/vg_cmst301-lv_root to 64903168 (4k) blocks.
The filesystem on /dev/mapper/vg_cmst301-lv_root is now 64903168 blocks long.

拡張結果の確認

[root@cmst301 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_cmst301-lv_root
                      244G  5.0G  227G   3% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/sda1             477M   78M  374M  18% /boot
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1