How to perform fsck on a ploop container
Original Publishing Date:
2022-04-13
Symptoms
From time to time it is necessary to check the filesystem of a container in ploop format.
Cause
Due to various reasons, mainly because of a system crash or an incorrect replication level, the filesystem can became corrupted. As the result, the number of minor filesystem errors grows with time.
It can become necessary to check the filesystem in a ploop image for consistency to avoid data loss.
Resolution
To run fsck
, follow the following steps:
-
Ensure the container is stopped:
~# vzctl stop 101
~# vzlist 101
CTID NPROC STATUS IP_ADDR HOSTNAME
101 - stopped 10.10.10.11 fsck.test
Note: Do not perform fsck
when the container is running or mounted.
-
Mount the container's ploop image. This allocates a ploop device on the host:
~# ploop mount /vz/private/101/root.hdd/DiskDescriptor.xml
add delta dev=/dev/ploop12345 img=/vz/private/101/root.hdd/root.hds (rw)
-
Run fdisk -l
for the /dev/ploopX
device reported by the previous command. You will need to let the system fetch a list of partitions on /dev/ploopX
:
~# fdisk -l /dev/ploop12345
WARNING: GPT (GUID Partition Table) detected on '/dev/ploop12345'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/ploop12345: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/ploop12345p1 1 1306 10485759+ ee GPT
-
Perform a file system check for the partition reported in the previous command's output (note p1 at the end):
~# e2fsck /dev/ploop12345p1
e2fsck 1.41.12 (17-May-2010)
/dev/ploop12345p1: clean, 22404/655360 files, 238012/2620923 blocks
Note: You may add more options to e2fsck
, check the manual pages if needed.
-
Unmount the ploop image:
~# ploop umount -d /dev/ploop12345
Unmounting device /dev/ploop12345
-
Start the container:
~# vzctl start 101
Internal content