topimg.jpg


LinuxにおけるLVの削除/拡張/縮小

●LV削除 ※アンマウント必須
[root@localhost tmp]# vgdisplay -C
VG #PV #LV #SN Attr VSize VFree
sharevg 1 2 0 wz--n- 79.97g 0
[root@localhost tmp]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
sharelv1 sharevg -wi-ao 20.00g
sharelv2 sharevg -wi-a- 59.97g


[root@localhost tmp]# umount /dev/sharevg/sharelv1

[root@localhost tmp]# lvremove /dev/sharevg/sharelv1
Do you really want to remove active logical volume sharelv1? [y/n]: y
Logical volume "sharelv1" successfully removed

[root@localhost tmp]# vgdisplay -C
VG #PV #LV #SN Attr VSize VFree
sharevg 1 1 0 wz--n- 79.97g 20.00g
[root@localhost tmp]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
sharelv2 sharevg -wi-a- 59.97g

●拡張
1.LV拡張(60GB⇒+20GB) ※マウントしていても実行可
[root@localhost tmp]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
sharelv2 sharevg -wi-ao 59.97g

[root@localhost tmp]# lvresize -L +20G /dev/mapper/sharevg-sharelv2
Extending logical volume sharelv2 to 79.97 GiB
Logical volume sharelv2 successfully resized

[root@localhost tmp]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
sharelv2 sharevg -wi-ao 79.97g

2.ファイルシステム拡張(60GB⇒LVの最大サイズ) ※マウントしていても実行可(ext3の場合)
[root@localhost tmp]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda3 ext3 2356764 1395584 835472 63% /
tmpfs tmpfs 505780 172 505608 1% /dev/shm
/dev/sda1 ext3 101086 17987 77880 19% /boot
/dev/mapper/sharevg-sharelv2
ext3 61927420 184268 58597428 1% /tmp/test

[root@localhost tmp]# resize2fs /dev/sharevg/sharelv2
resize2fs 1.41.14 (22-Dec-2010)
Filesystem at /dev/sharevg/sharelv2 is mounted on /tmp/test; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 5
Performing an on-line resize of /dev/sharevg/sharelv2 to 20963328 (4k) blocks.
The filesystem on /dev/sharevg/sharelv2 is now 20963328 blocks long.

[root@localhost tmp]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda3 ext3 2356764 1395588 835468 63% /
tmpfs tmpfs 505780 172 505608 1% /dev/shm
/dev/sda1 ext3 101086 17987 77880 19% /boot
/dev/mapper/sharevg-sharelv2
ext3 82537136 188292 78156440 1% /tmp/test


●縮小
1.ファイルシステム縮小(80GB⇒60GB)※アンマウント必須
[root@localhost tmp]# umount /dev/mapper/sharevg-sharelv2
[root@localhost tmp]# fsck.ext3 -f /dev/mapper/sharevg-sharelv2
e2fsck 1.41.14 (22-Dec-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/sharevg-sharelv2: 11/5242880 files (0.0% non-contiguous), 376117/20963328 blocks

[root@localhost tmp]# resize2fs /dev/mapper/sharevg-sharelv2 60G
resize2fs 1.41.14 (22-Dec-2010)
Resizing the filesystem on /dev/mapper/sharevg-sharelv2 to 15728640 (4k) blocks.
The filesystem on /dev/mapper/sharevg-sharelv2 is now 15728640 blocks long.

[root@localhost tmp]# mount /dev/sharevg/sharelv2 /tmp/test
[root@localhost tmp]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda3 ext3 2356764 1395512 835544 63% /
tmpfs tmpfs 505780 172 505608 1% /dev/shm
/dev/sda1 ext3 101086 17987 77880 19% /boot
/dev/mapper/sharevg-sharelv2
ext3 61927420 184268 58597428 1% /tmp/test

2.LV縮小(80GB⇒60GB)※マウントしていても実行可
[root@localhost tmp]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
sharelv2 sharevg -wi-ao 79.97g

[root@localhost tmp]# lvresize -L 60G /dev/mapper/sharevg-sharelv2
WARNING: Reducing active logical volume to 60.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce sharelv2? [y/n]: y
Reducing logical volume sharelv2 to 60.00 GiB
Logical volume sharelv2 successfully resized

[root@localhost tmp]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
sharelv2 sharevg -wi-a- 60.00g



●参考
LVM上のファイルシステムをリサイズ(拡張/縮小)する
http://l-w-i.net/t/fedora/lvm_003.txt
スポンサーサイト
  1. 2013/01/21(月) 02:58:00|
  2. Linux/Unix
  3. | トラックバック:0
  4. | コメント:1
<<VMWare Workstation上にストレージ環境とESXi環境を作成する方法 | ホーム | LinuxでLVMを利用したディスクマウント手順>>

コメント

逆サエコ状態!

0G9vLM1D
まさに逆サエコ状態!
金稼げすぎてワロタwww
http://2225al57.dal-bish.info/2225al57/
  1. 2013/02/09(土) 07:27:54 |
  2. URL |
  3. さえお #ORjyofoE
  4. [ 編集 ]

コメントの投稿


管理者にだけ表示を許可する

トラックバック

トラックバック URL
http://192168111.blog71.fc2.com/tb.php/95-210b8f07
この記事にトラックバックする(FC2ブログユーザー)