縮放卷冊群組和邏輯卷冊的大小

增加實體卷冊到卷冊群組
# vgdisplay systemVG
— Volume group —
VG Name systemVG
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 125 / 500.00 MiB
Free PE / Size 385 / 1.50 GiB
VG UUID oWUkZt-IOhU-1qw2-THBl-qRfY-w3xK-JDCPXe

VG Size 為 2G,Cur PV 2 由 2 個 PV 組成

[@more@]# vgextend systemVG /dev/sda7
Volume group “systemVG” successfully extended

# vgdisplay systemVG
— Volume group —
VG Name systemVG
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 2.99 GiB
PE Size 4.00 MiB
Total PE 765
Alloc PE / Size 125 / 500.00 MiB
Free PE / Size 640 / 2.50 GiB
VG UUID oWUkZt-IOhU-1qw2-THBl-qRfY-w3xK-JDCPXe

VG 變成 3G,Cur PV 由 3 個 PV 所組成

將實體卷冊從卷冊群組中移除
# vgreduce systemVG /dev/sda7
Removed “/dev/sda7” from volume group “systemVG”
vgreduce 指令工具可以將尚未使用到的實體卷冊從卷冊群組中移除,但如果實體卷冊已經被有存取容量空間占用時,就會無法刪除

透過指令來縮放邏輯卷冊
# df -h | grep www_LV
/dev/mapper/systemVG-www_LV 500M 33M 468M 7% /var/www

# lvdisplay | grep “LV Size”
LV Size 500.00 MiB

加大 www_LV 邏輯卷冊 加到 750M(原有 500M + 250M)
# umount /var/www
# lvextend -L +250M /dev/systemVG/www_LV
Rounding up size to full physical extent 252.00 MiB
Extending logical volume www_LV to 752.00 MiB
Logical volume www_LV successfully resized

# ls -l /var/www
總計 0
-rw-r–r– 1 root root 0 5月 17 21:16 test.html

格式化後續新增的部分
ext2/ext3 resizefs
# resize2fs -s +250M /dev/systemVG/www_LV
# resize_reiserfs -s +250M /dev/systemVG/www_LV
resize_reiserfs 3.6.21 (2009 www.namesys.com)

ReiserFS report:
blocksize 4096
block count 192000 (128000)
free blocks 183783 (119785)
bitmap block count 6 (4)

Syncing..done

resize_reiserfs: Resizing finished successfully.

重新掛載
# mount -t reiserfs /dev/systemVG/www_LV /var/www
檢查容量
# lvdisplay | grep “LV Size”
LV Size 752.00 MiB
# df -h | grep www_LV
/dev/mapper/systemVG-www_LV 750M 33M 718M 5% /var/www

縮小邏輯卷冊的大小
# umount /var/www
# resize_reiserfs -s -100M /dev/systemVG/www_LV
resize_reiserfs 3.6.21 (2009 www.namesys.com)

You are running BETA version of reiserfs shrinker.
This version is only for testing or VERY CAREFUL use.
Backup of you data is recommended.

Do you want to continue? [y/N]: y
Processing the tree: 0%….20%….40%….60%….80%….100% left 0, 0 /sec

nodes processed (moved):
int 0 (0),
leaves 1 (0),
unfm 0 (0),
total 1 (0).

check for used blocks in truncated region

ReiserFS report:
blocksize 4096
block count 166400 (192000)
free blocks 158183 (183783)
bitmap block count 6 (6)

Syncing..done

resize_reiserfs: Resizing finished successfully.

使用 lvreduce 減少 www_LV 的 100 空間
# lvreduce -L -100M /dev/systemVG/www_LV
WARNING: Reducing active logical volume to 652.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce www_LV? [y/n]: y
Reducing logical volume www_LV to 652.00 MiB
Logical volume www_LV successfully resized

重新掛載
# mount -t reiserfs /dev/systemVG/www_LV /var/www
# df -h | grep www_LV
/dev/mapper/systemVG-www_LV 650M 33M 618M 5% /var/www
# lvdisplay | grep “LV Size”
LV Size 652.00 MiB