最初的分区:
现在要压缩myserver-home ,增加myserver-root。
查看物理卷
#pvdisplay
略……
查看卷组
#vgdisplay
略……
查看逻辑卷
#lvdisplay
--- Logical volume ---
LV Name /dev/myserver/root
VG Name myserver
LV UUID g8bztp-lrp3-XGhk-O6PB-ctZn-Yl5M-Dr247z
LV Write Access read/write
LV Status available
# open 1
LV Size 6.52 GB
Current LE 1668
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Name /dev/myserver/swap_1
VG Name myserver
LV UUID fsoPym-loXw-NfQW-3Uff-jMtM-1N1q-NGwSIr
LV Write Access read/write
LV Status available
# open 1
LV Size 5.63 GB
Current LE 1441
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
--- Logical volume ---
LV Name /dev/myserver/home
VG Name myserver
LV UUID 2fdbfk-sc9H-bKHn-Po5s-8q38-67Di-lFKZXz
LV Write Access read/write
LV Status available
# open 1
LV Size 293.00 GB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:2
确定要变更的两个逻辑卷名:
/dev/myserver/home 挂载点是 /home
/dev/myserver/root 挂载点是 /
(一)减少/dev/myserver/home
#umount /home
#mke2fs -n /dev/myserver/home
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
18563072 inodes, 74249216 blocks
3712460 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2266 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616
执行这个命令是要计算调整块的最终大小。我要将/dev/myserver/home减少到50G,而将腾出的空间给/dev/myserver/root.
上面的数据显示,每块大小为4096Bytes ,总共有74249216块。
50G=53687091200 Bytes =13107200 blocks
减少的块数=74249216 - 13107200=61142016
减少的61142016块= 238836M
#resize2fs -f /dev/myserver/home 13107200
#lvreduce -L-238836M /dev/myserver/home
#mount /home
检查是否减少了
#df -lh
(二)扩展/dev/myserver/root 的大小
#lvextend -L+238836M /dev/myserver/root
注意,这里在其他某些linux系统本可以执行ext2online 来实现,但是Lenny中没有这个命令,本应该用
# umount /dev/myserver/root但是因为 /dev/myserver/root在使用中,无法执行umount ,所以直接执行如下命令即可:
# resize2fs /dev/myserver/root
# mount /dev/myserver/root /
#resize2fs /dev/myserver/root
检查是否增加了
#df -lh
完毕!
参考:
http://www.ownlinux.cn/2009/03/26/debian-linux-lvm/
lvm(逻辑卷管理器)的介绍和常用功能流程实验
LVM使用手册
没有评论:
发表评论