fsck a filesystem in a file

I created a filesystem like this:

dd if=/dev/zero of=disk-image count=40960

filesystem is created with this:

/sbin/mkfs -t ext3 -q disk-image

I then mounted and copied some test files and unmounted like this:

mount -o loop disk.image foo
cp "something" foo
sudo umount foo

I then run a e2fsck -c -c disk-image which returns

"Pass 1: Checking inodes, blocks, and sizes
Inode 185, i_size is 16384, should be 17408.  Fix<y>? yes 

My question, since this is a file and not a block device, is the above warning something that I should be worried about.

How does one go about doing an fsck on a filesystem that is in a file?


Solution 1:

You just run e2fsck and specify the image file, just like you would for a block device. I'm not sure why you're using the -c option (this checks for badblocks).

% e2fsck -f ext3.img
e2fsck 1.42 (29-Nov-2011)
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
ext3.img: 11/25688 files (0.0% non-contiguous), 8913/102400 blocks