现在的位置: 首页 > 综合 > 正文

linux缩小lv发生文件系统错误

2012年04月22日 综合 ⁄ 共 2251字 ⁄ 字号 暂无评论
孙国栋广告

众所周知,linux lvm 扩大lv是先扩大lv,然后再扩大文件系统,所以有的人就认为缩小lv也是先缩小lv,再缩小文件系统,当然博主刚开始也那么认为,导致lvresize 以后,lv的大小小于文件系统大小而无法挂载,以下分享下解决办法。

案例:

缩小/opt from 8.46G to 4G.

HostA:~ # lvresize -L 4G /dev/vg00/lv_opt
WARNING: Reducing active logical volume to 4.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_opt? [y/n]: y
Reducing logical volume lv_opt to 4.00 GB
Logical volume lv_opt successfully resized
HostA:~ # lvs
lv_opt vg00 -wi-a- 4.00G

HostA:~ # e2fsck -f /dev/vg00/lv_opt
e2fsck 1.41.9 (22-Aug-2009)
Error reading block 1049100 (Invalid argument). Ignore error? no

Error reading block 1050125 (Invalid argument). Ignore error? no

Error reading block 1049100 (Invalid argument). Ignore error? no

Error reading block 1050125 (Invalid argument). Ignore error? no

Superblock has an invalid journal (inode 8).
Clear? yes

*** ext3 journal has been deleted - filesystem is now ext2 only ***

The filesystem size (according to the superblock) is 2217984 blocks
The physical size of the device is 1048576 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? no

Pass 1: Checking inodes, blocks, and sizes
Journal inode is not in use, but contains data. Clear? yes

Error reading block 1048578 (Invalid argument) while getting next inode from scan. Ignore error? yes

HostA:~ # resize2fs /dev/vg00/lv_opt
resize2fs 1.41.9 (22-Aug-2009)
Please run 'e2fsck -f /dev/vg00/lv_opt' first.

会发生以上文件系统大于lv大小导致无法通过e2fsck

网上找了很多方法如何修复系统,其实方法很简单,只要先把lv扩大至原来大小,再重新用正确的方法缩小lv即可

HostA:~ # lvresize -L 8.46G /dev/vg00/lv_opt
HostA:~ # e2fsck -f /dev/vg00/lv_opt
e2fsck 1.41.9 (22-Aug-2009)
Pass 1: Checking inodes, blocks, and sizes
Inode 8, i_blocks is 0, should be 262408. Fix? yes

Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/vg00/lv_opt: ***** FILE SYSTEM WAS MODIFIED *****
/dev/vg00/lv_opt: 12703/554880 files (0.3% non-contiguous), 246796/2217984 blocks
HostA:~ # resize2fs /dev/vg00/lv_opt 4G
resize2fs 1.41.9 (22-Aug-2009)
Resizing the filesystem on /dev/vg00/lv_opt to 1048576 (4k) blocks.
The filesystem on /dev/vg00/lv_opt is now 1048576 blocks long.
HostA:~ # lvresize -L 4G /dev/vg00/lv_opt
WARNING: Reducing active logical volume to 4.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_opt? [y/n]: y
Reducing logical volume lv_opt to 4.00 GB
Logical volume lv_opt successfully resized
HostA:~ # mount /opt/
HostA:~ # df -h /opt/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lv_opt
4.0G 826M 3.0G 22% /opt
HostA:~ #

给我留言

留言无头像?