CentOS パーティション再割当 [LINUX]
アプリケーション利用前には大体の規模見積もりをしてパーティション割り当てをしますが、運用開始すると思ったよりもログやバックアップで領域を消費することがあります。
シンボリックリンクで空いてるファイルシステムに割り当てるという手がありますが、今回はパーティションの再割り当てを実行してみました。
/が窮屈になったので、あまり使っていない/homeを削って、/に追加します。
OSは「CentOS release 6.7 (Final)」です。
■最初の状態
[root@hogehoge ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_edu01-lv_root
ext4 71G 37G 31G 55% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 477M 69M 384M 16% /boot
/dev/mapper/vg_edu01-lv_home
ext4 50G 352M 47G 1% /home
■/homeサイズ変更
[root@hogehoge ~]# umount /home
[root@hogehoge ~]# fsck.ext4 -f /dev/mapper/vg_edu01-lv_home
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_edu01-lv_home: 22/3276800 files (13.6% non-contiguous), 328396/13107200 blocks
[root@hogehoge ~]# resize2fs /dev/mapper/vg_edu01-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_edu01-lv_home to 5242880 (4k) blocks.
The filesystem on /dev/mapper/vg_edu01-lv_home is now 5242880 blocks long.
[root@hogehoge ~]# lvreduce -L 20G /dev/mapper/vg_edu01-lv_home
WARNING: Reducing active logical volume to 20.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Size of logical volume vg_edu01/lv_home changed from 50.00 GiB (12800 extents) to 20.00 GiB (5120 extents).
Logical volume lv_home successfully resized
[root@hogehoge ~]# mount -t ext4 /dev/mapper/vg_edu01-lv_home /home
[root@hogehoge ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_edu01-lv_root
ext4 71G 37G 31G 55% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 477M 69M 384M 16% /boot
/dev/mapper/vg_edu01-lv_home
ext4 20G 344M 19G 2% /home
■/サイズ変更⇒空きを全て / に割り当てる
[root@hogehoge ~]# lvextend -l +100%FREE /dev/mapper/vg_edu01-lv_root
Size of logical volume vg_edu01/lv_root changed from 72.60 GiB (18586 extents) to 102.60 GiB (26266 extents).
Logical volume lv_root successfully resized
[root@hogehoge ~]# resize2fs /dev/mapper/vg_edu01-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_edu01-lv_root is mounted on /; on-line resizing required
old desc_blocks = 5, new_desc_blocks = 7
Performing an on-line resize of /dev/mapper/vg_edu01-lv_root to 26896384 (4k) blocks.
The filesystem on /dev/mapper/vg_edu01-lv_root is now 26896384 blocks long.
■最終結果
[root@hogehoge ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_edu01-lv_root
ext4 101G 37G 60G 38% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 477M 69M 384M 16% /boot
/dev/mapper/vg_edu01-lv_home
ext4 20G 344M 19G 2% /home
シンボリックリンクで空いてるファイルシステムに割り当てるという手がありますが、今回はパーティションの再割り当てを実行してみました。
/が窮屈になったので、あまり使っていない/homeを削って、/に追加します。
OSは「CentOS release 6.7 (Final)」です。
■最初の状態
[root@hogehoge ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_edu01-lv_root
ext4 71G 37G 31G 55% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 477M 69M 384M 16% /boot
/dev/mapper/vg_edu01-lv_home
ext4 50G 352M 47G 1% /home
■/homeサイズ変更
[root@hogehoge ~]# umount /home
[root@hogehoge ~]# fsck.ext4 -f /dev/mapper/vg_edu01-lv_home
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_edu01-lv_home: 22/3276800 files (13.6% non-contiguous), 328396/13107200 blocks
[root@hogehoge ~]# resize2fs /dev/mapper/vg_edu01-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_edu01-lv_home to 5242880 (4k) blocks.
The filesystem on /dev/mapper/vg_edu01-lv_home is now 5242880 blocks long.
[root@hogehoge ~]# lvreduce -L 20G /dev/mapper/vg_edu01-lv_home
WARNING: Reducing active logical volume to 20.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Size of logical volume vg_edu01/lv_home changed from 50.00 GiB (12800 extents) to 20.00 GiB (5120 extents).
Logical volume lv_home successfully resized
[root@hogehoge ~]# mount -t ext4 /dev/mapper/vg_edu01-lv_home /home
[root@hogehoge ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_edu01-lv_root
ext4 71G 37G 31G 55% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 477M 69M 384M 16% /boot
/dev/mapper/vg_edu01-lv_home
ext4 20G 344M 19G 2% /home
■/サイズ変更⇒空きを全て / に割り当てる
[root@hogehoge ~]# lvextend -l +100%FREE /dev/mapper/vg_edu01-lv_root
Size of logical volume vg_edu01/lv_root changed from 72.60 GiB (18586 extents) to 102.60 GiB (26266 extents).
Logical volume lv_root successfully resized
[root@hogehoge ~]# resize2fs /dev/mapper/vg_edu01-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_edu01-lv_root is mounted on /; on-line resizing required
old desc_blocks = 5, new_desc_blocks = 7
Performing an on-line resize of /dev/mapper/vg_edu01-lv_root to 26896384 (4k) blocks.
The filesystem on /dev/mapper/vg_edu01-lv_root is now 26896384 blocks long.
■最終結果
[root@hogehoge ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_edu01-lv_root
ext4 101G 37G 60G 38% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 477M 69M 384M 16% /boot
/dev/mapper/vg_edu01-lv_home
ext4 20G 344M 19G 2% /home
2015-09-16 16:11
nice!(0)
コメント(0)
トラックバック(0)
コメント 0