|
目的:由于安装系统的时候根分区分配的空间过小,/home太多与标准不符,需要修改lvm大小。
1、首先查看磁盘分区:
[root@VM_Moretv_java_01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G 2.3G 45G 5% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-lv_home 144G 188M 136G 1% /home
2、卸载/home分区:
[root@VM_Moretv_java_01 ~]# umount /dev/mapper/VolGroup-lv_home
[root@VM_Moretv_java_01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G 2.3G 45G 5% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
3、检查文件系统,确定没有坏块:
[root@VM_Moretv_java_01 ~]# e2fsck -f /dev/mapper/VolGroup-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/VolGroup-lv_home: 17/9551872 files (0.0% non-contiguous), 647479/38176768 blocks
4、缩小文件系统到20G:
[root@VM_Moretv_java_01 ~]# resize2fs /dev/mapper/VolGroup-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 5242880 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_home is now 5242880 blocks long.
5、缩小逻辑卷:
[root@VM_Moretv_java_01 ~]# lvreduce -L 20G /dev/mapper/VolGroup-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
Reducing logical volume lv_home to 20.00 GiB
Logical volume lv_home successfully resized
6、挂载/home分区:
[root@VM_Moretv_java_01 ~]# mount /dev/mapper/VolGroup-lv_home
[root@VM_Moretv_java_01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G 2.3G 45G 5% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-lv_home 20G 172M 19G 1% /home
7、查看vg大小:
[root@VM_Moretv_java_01 ~]# 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 199.51 GiB
PE Size 4.00 MiB
Total PE 51074
Alloc PE / Size 18912 / 73.88 GiB
Free PE / Size 32162 / 125.63 GiB
VG UUID kbnkX4-Sd6E-lmu2-ygp9-lahU-jpKB-UYKo5G
可以看出来vg还有125.63G剩余空间。
8、增加根分区lv的大小:
[root@VM_Moretv_java_01 ~]# lvextend -L +125G /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 175.00 GiB
Logical volume lv_root successfully resized
9、调整文件系统大小:
[root@VM_Moretv_java_01 ~]# resize2fs /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 11
Performing an on-line resize of /dev/VolGroup/lv_root to 45875200 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 45875200 blocks long.
10、查看文件系统是否正常:
[root@VM_Moretv_java_01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 173G 2.3G 162G 2% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-lv_home 20G 172M 19G 1% /home
结果显示/分区已经扩展。
|
|