分类: LINUX
2011-10-18 10:39:42
记一下记录,忘了好找
某服务器硬盘没划分完,某个分区相当小,很浪费
[root@svr68 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 6
Open LV 5
Max PV 0
Cur PV 2
Act PV 2
VG Size 836.34 GB
PE Size 32.00 MB
Total PE 26763
Alloc PE / Size 18238 / 569.94 GB
Free PE / Size 8525 / 266.41 GB
VG UUID GQxsHi-QnFz-54YO-Htzs-jwBp-n7t5-DoEv8R
###可以看到有266G的空闲空间
[root@svr68 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
3.9G 477M 3.3G 13% /
/dev/mapper/VolGroup00-LogVol05
252G 2.7G 239G 2% /home
/dev/mapper/VolGroup00-LogVol04
3.9G 730M 3.0G 20% /var
/dev/mapper/VolGroup00-LogVol03
35G 221M 33G 1% /tmp
/dev/mapper/VolGroup00-LogVol02
256G 9.5G 234G 4% /usr
/dev/sda3 190M 15M 166M 9% /boot
tmpfs 7.9G 0 7.9G 0% /dev/shm
### 目标是/home目录,准备扩它。其他也可以扩,看自己需要。
[root@svr68 ~]# umount /dev/mapper/VolGroup00-LogVol05
umount: /home: device is busy
umount: /home: device is busy
###卸载home目录所在逻辑卷,但是有进程在用
[root@svr68 ~]# fuser -m /dev/mapper/VolGroup00-LogVol05
/dev/mapper/VolGroup00-LogVol05: 4996c 4997c
###看谁在用它
[root@btirsvr68 ~]# kill 4996 4997
-bash: kill: (22338) - 没有那个进程
-bash: kill: (22340) - 没有那个进程
###干掉
[root@svr68 ~]# fuser -m /dev/mapper/VolGroup00-LogVol05
### 嗯,没了
[root@svr68 ~]# umount /dev/mapper/VolGroup00-LogVol05
###这下卸载了
[root@svr68 ~]# lvextend -l +8525 /dev/VolGroup00/LogVol05
Extending logical volume LogVol05 to 526.41 GB
Logical volume LogVol05 successfully resized
###扩展8525个单位,从vgdisplay看到的最大了。也可以用-L 参数扩充具体的大小如lvextend -L+266G /dev/VolGroup00/LogVol05
[root@svr68 ~]# resize2fs /dev/VolGroup00/LogVol05
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/VolGroup00/LogVol05' first.
###挂在钱要重新改变尺寸才真正生效,噢,碰到一个问题,要先检查一下磁盘。
[root@svr68 ~]# e2fsck -f /dev/VolGroup00/LogVol05
e2fsck 1.39 (29-May-2006)
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/VolGroup00/LogVol05: 30956/68157440 files (0.8% non-contiguous), 2819130/68157440 blocks
###查吧,花点时间而已,约1分钟
[root@btirsvr68 ~]# resize2fs /dev/VolGroup00/LogVol05
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/VolGroup00/LogVol05 to 137994240 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol05 is now 137994240 blocks long.
###改大小成功
[root@btirsvr68 ~]# mount /dev/VolGroup00/LogVol05
###挂上啦
[root@btirsvr68 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
3.9G 477M 3.3G 13% /
/dev/mapper/VolGroup00-LogVol04
3.9G 730M 3.0G 20% /var
/dev/mapper/VolGroup00-LogVol03
35G 221M 33G 1% /tmp
/dev/mapper/VolGroup00-LogVol02
256G 9.5G 234G 4% /usr
/dev/sda3 190M 15M 166M 9% /boot
tmpfs 7.9G 0 7.9G 0% /dev/shm
/dev/mapper/VolGroup00-LogVol05
510G 2.7G 492G 1% /home
###哈,kuo