Wednesday, 11 May 2016

Performing fsck on a file system within a logical volume / LVM

I would usually use the debian live rescue CD for this kind of job - but since it is no longer around (and the standard version is missing LVM support I will be using the CentOS live cd from:

http://buildlogs.centos.org/rolling/7/isos/x86_64/CentOS-7-x86_64-LiveGNOME.iso

Boot into the live cd and grab a list of the logical volumes:

sudo lvdisplay

and to view the filesystem type of the unmounted disks we can run:

parted -l

Which should return all of your logical volumes, along with the filesystem type.

In my case it was xfs - so we should run a TEST with something like the following:

xfs_repair -n /dev/mapper/centos-root

The '-n' parameter instructs xfs_repair to only check (and not fix) any errors.

And then fix any problems with:

xfs_repair /dev/mapper/centos-root

Although I got the following message when attempting to do so:

'Error: The filesystem has valuable metadata changes in a log which needs to be replayed. Mount the filesystem to replay the log, and unmount it before re-running xfs_repair...'

So I simply mounted and then unmounted the system in order to get the logs to replay:

mkdir /mnt/tmp
mount /dev/mapper/centos-root /mnt/tmp
umount /mnt/tmp

and then re-run the command:

xfs_repair /dev/mapper/centos-root

IF you are UNABLE to replay the metadata log (this should only be used as a last resort - as you will likely lose some changes to the filesystem and potentially cause corruption of files!) - you can issue the xfs_repair command with the '-L' parameter.

xfs_repair -L /dev/mapper/centos-root

0 comments:

Post a Comment