由于采用KS安装了系统,不小心把一个挂载点设置的1000G,太大,决定缩小LVM的空间。如下:
[root@localhost ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/vg_root-lv_www
1000G 200M 948G 1% /www
cd /www
[root@localhost www]# ll
总计 16K
drwx—— 2 root root 16K 2010-07-03 lost+found
#######顺便测试一下缩小时会不会破会数据,简单的一个测试。有数据还是要小心,最好先备份。
[root@localhost www]# mkdir test
[root@localhost www]# vi log.log
dfakfl;aksdflakldfaklfa
[root@localhost /]# umount /www
[root@localhost /]# e2fsck -f /dev/vg_root/lv_www ###强迫检查文件系统正确性
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/vg_root/lv_www: 13/270499840 files (7.7% non-contiguous), 8521916/270475264 blocks
[root@localhost /]# resize2fs /dev/vg_root/lv_www 100G ###首先缩小文件系统
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg_root/lv_www to 26214400 (4k) blocks.
The filesystem on /dev/vg_root/lv_www is now 26214400 blocks long.
[root@localhost /]# lvresize -L 100G /dev/vg_root/lv_www ####其次缩小lv 大小
WARNING: Reducing active logical volume to 100.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_www? [y/n]: y
Reducing logical volume lv_www to 100.00 GB
Logical volume lv_www successfully resized
[root@localhost /]# mount -a
[root@localhost /]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/vg_root-lv_www
97G 188M 93G 1% /www
[root@localhost /]# cd /www
[root@localhost www]# ll
总计 32K
-rw-r–r– 1 root root 24 07-03 14:14 log.log
drwx—— 2 root root 16K 2010-07-03 lost+found
drwxr-xr-x 2 root root 4.0K 07-03 14:14 test
[root@localhost www]# cat log.log
dfakfl;aksdflakldfaklfa
数据没有被破会。
pvdisplay
— Physical volume —
PV Name /dev/sda3
VG Name vg_root
PV Size 1.09 TB / not usable 25.21 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 35577
Free PE 29817 ###多出来的
Allocated PE 5760
PV UUID Wtf68r-1aMo-If26-IlfD-1HB9-eaq8-6yj2Mb
vgdisplay
— Volume group —
VG Name vg_root
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 5
Open LV 5
Max PV 0
Cur PV 1
Act PV 1
VG Size 1.09 TB
PE Size 32.00 MB
Total PE 35577
Alloc PE / Size 5760 / 180.00 GB
Free PE / Size 29817 / 931.78 GB ##同样VG也是多出来了
VG UUID MoTja0-figK-HMSR-7566-FR2f-00kq-UL6CQx
RedHat 5.5 无损 缩小 LVM 空间
转载请注明出处:服务器评测 » RedHat 5.5 无损 缩小 LVM 空间