Wednesday, January 16, 2013

Error reading block 2851259 (Invalid argument) while doing inode scan. Ignore error? yes Force rewrite? yes

If you are facing following error while shrink LVM using lvreduce command.


Error reading block 2851259 (Invalid argument) while doing inode scan.  Ignore error? yes
Force rewrite? yes

It  means  if you trying to reduce the lvm partition the partition may be corrupt.
So you can do this step by step. 


[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/data--vg-data    14G  154M   13G   2% /data

## If you reduceing the LVM 4GB you using.
 lvreduce -L -4G /dev/data-vg/data



[root@localhost ~]# e2fsck -f /dev/data-vg/data
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
The filesystem size (according to the superblock) is 3670016 blocks
The physical size of the device is 2621440 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? yes

## Extend LVM with the original size.
lvextend -L+4G /dev/mapper/data--vg-data

## Recheck the Partition.
e2fsck -f /dev/data-vg/data
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/data-vg/data: 18/1835008 files (5.6% non-contiguous), 96794/3670016 blocks

### Try to resize again.
[root@localhost ~]# resize2fs -p /dev/mapper/data--vg-data
resize2fs 1.39 (29-May-2006)
The filesystem is already 3670016 blocks long.  Nothing to do!

## mount that filesystem.
[root@localhost ~]# mount /dev/data-vg/data /data/

### check again.
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/data--vg-data    14G  154M   13G   2% /data

### Take a backup of data with snapshot (create snapshot with minimum size of data.) and mount to
##  system.


[root@localhost /]# lvcreate -L9G  -s  -n snap-data /dev/data-vg/data
  Logical volume "snap-data" created
[root@localhost /]# mount /dev/data-vg/snap-data /snap/
[root@localhost /]# df /snap/
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/data--vg-snap--data          14449712    156824  13558888   2% /snap
[root@localhost /]# cd /snap/
[root@localhost snap]# ls -la
total 60
drwxr-xr-x  4 root root  4096 Jan 16 16:38 .
drwxr-xr-x 34 root root  4096 Jan  7 18:22 ..
-rw-r--r--  1 root root    21 Jan 16 16:37 file
-rw-r--r--  1 root root    21 Jan 16 16:38 file1
-rw-r--r--  1 root root    21 Jan 16 16:38 file2
drwx------  2 root root 16384 Jan 16 16:34 lost+found
drwxr-xr-x  2 root root  4096 Jan 16 16:39 yo

### Now you can umount data partition and reduce the original  "data" partition, remount the /data and move the snapshot backup to /data partition.

Guys, any query please let me know.

1 comments:

digital certificate said...

Excellent! Thanks for this - I've been looking at this feature for ages. Followed your instructions and it works a treat!