在使用Fedora13-x86_64过程中,发现系统分配给root用户lvm份额太少.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 11G 37G 23% /
tmpfs 878M 100K 878M 1% /dev/shm
/dev/sda1 485M 28M 432M 7% /boot
/dev/mapper/VolGroup-lv_home
406G 411M 385G 1% /home
/dev/sdc 124M 107M 18M 86% /media/16F0-286F
[root@localhost ~]#
总共才50G,决定给它增加份额,现做好重要文件备份,以防万一.
思路:
先减掉VolGroup-lv_home的份额,再把减掉份额增加到VolGroup-lv_root.
[root@localhost ~]# pvscan
PV /dev/sda2 VG VolGroup lvm2 [465.25 GiB / 0 free]
Total: 1 [465.25 GiB] / in use: 1 [465.25 GiB] / in no VG: 0 [0 ]
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 206G
resize2fs 1.41.10 (10-Feb-2009)
Filesystem at /dev/mapper/VolGroup-lv_home is mounted on /home; on-line resizing required
On-line shrinking from 107954176 to 54001664 not supported.
[root@localhost ~]# umount /home
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 206G
resize2fs 1.41.10 (10-Feb-2009)
Please run 'e2fsck -f /dev/mapper/VolGroup-lv_home' first.
[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_home
e2fsck 1.41.10 (10-Feb-2009)
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/VolGroup-lv_home: 1534/26992640 files (1.2% non-contiguous), 1799101/107954176 blocks
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 206G
resize2fs 1.41.10 (10-Feb-2009)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 54001664 (4k) blocks.
Begin pass 3 (max = 3295)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 54001664 blocks long.
[root@localhost ~]# mount /home
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 11G 37G 23% /
tmpfs 878M 100K 878M 1% /dev/shm
/dev/sda1 485M 28M 432M 7% /boot
/dev/sdc 124M 107M 18M 86% /media/16F0-286F
/dev/mapper/VolGroup-lv_home
203G 400M 193G 1% /home
[root@localhost ~]# lvreduce -L 206G /dev/mapper/VolGroup-lv_home
WARNING: Reducing active and open logical volume to 206.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Reducing logical volume lv_home to 206.00 GiB
Logical volume lv_home successfully resized
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 11G 37G 23% /
tmpfs 878M 100K 878M 1% /dev/shm
/dev/sda1 485M 28M 432M 7% /boot
/dev/sdc 124M 107M 18M 86% /media/16F0-286F
/dev/mapper/VolGroup-lv_home
203G 400M 193G 1% /home
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 465.25 GiB
PE Size 32.00 MiB
Total PE 14888
Alloc PE / Size 8302 / 259.44 GiB
Free PE / Size 6586 / 205.81 GiB
VG UUID ymBJK0-SNdq-DWHg-MlPu-31sG-ZpO1-kCrUmu
[root@localhost ~]# man lvextend
[root@localhost ~]# lvextend -L +205.81G /dev/mapper/VolGroup-lv_root
Rounding up size to full physical extent 205.81 GiB
Extending logical volume lv_root to 255.81 GiB
Logical volume lv_root successfully resized
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
resize2fs 1.41.10 (10-Feb-2009)
Filesystem at /dev/mapper/VolGroup-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/VolGroup-lv_root to 67059712 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 67059712 blocks long.
让我们看一下,
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
252G 11G 229G 5% /
tmpfs 878M 100K 878M 1% /dev/shm
/dev/sda1 485M 28M 432M 7% /boot
/dev/sdc 124M 107M 18M 86% /media/16F0-286F
/dev/mapper/VolGroup-lv_home
203G 400M 193G 1% /home
[root@localhost ~]#
已经可以了.
reference to:
1.http://www.computers-it.com/linux/linux_lvm_resize_filesystem.php
2.http://www.howtoforge.com/linux_lvm
breakbrain 于 2011-03-04 19:17:38发表:
弄个DVD刻录机,迟早要备份的.
现在的硬盘便宜.
alick 于 2011-03-03 22:29:02发表:
顶。楼主的硬盘好大啊。
pallana 于 2011-03-03 13:28:55发表:
可惜,我的系统不是LVM。。。。早知道我也按照默认的LVM分区了
现在想换分区又没有地方存放数据,纠结了。
Growth兆 于 2011-03-03 09:45:17发表:
感谢breakbrain的技术分享,本贴加入到顶置的Linux应用贴中
nxzcc 于 2011-03-03 08:52:52发表:
不错哈,学习了