Page 1 of 1

xfs Filesystem corruption using rawdisk partitions

Posted: 3. Apr 2009, 22:03
by EddieA
Let me preface this by saying I have the same issue running under VMWare, although it doesn't seem as prevalent in VirtualBox.

I'm trying to build a new "root" partition on an existing disk. I've tried a number of times now, and every time I've ended up with a corrupt filesystem. I'm trying to do it this way because I can't shut the server down in order to create the new system.

My existing disk is /dev/hda, which has the following partions: /dev/hda1 is an active xfs filesystem. /dev/hda2 is unused. /dev/hda4 is a Linux swap.

In my VM I added a hard disk, as "rawdisk" and then included "partitions 2". I also added 2 Virtual disks as well.

The following sequence nearly always results in a corrupted filesystem on /dev/hda2.

Boot the VM from a Slackware DVD image.
Install Slackware on /dev/hda2, which includes formatting /dev/hda2 as xfs.
poweroff the VM.
Run xfs_check /dev/hda2, which doesn't find any errors.
Mount /dev/hda2 on existing system, and copy 2 directory trees from /dev/hda1 to /dev/hda2.
Unmount /dev/hda2.
Run xfs_check /dev/hda2, which again doesn't find any errors.
Boot the VM, again from the Slackware DVD image, but add the kernel parameters "root=/dev/hda2 rdinit= ro".
poweroff the VM.
Run xfs_check, which now complains that there are errors on the filesystem. If the corruption hasn't happened here, it will almost certainly occur the next time I boot, and poweroff.

The partition is never mounted to the host and the VM at the same time. It is always unmounted from the host before starting the VM. The VM is always powered down before mounting the partition on the host. Both are running the same kernel version, and xfs version

Does anyone have any idea why this could be happening. I'm running VirtualBox 2.1.4.

Cheers,

Eddie

Re: xfs Filesystem corruption using rawdisk partitions

Posted: 4. Apr 2009, 00:12
by Sasquatch
It shouldn't matter, but have you tried a different file system? And what did you use to create the RAW VMDK image?

Re: xfs Filesystem corruption using rawdisk partitions

Posted: 4. Apr 2009, 01:43
by EddieA
No, I haven't tried another filesystem, as I was trying to mirror my current root filesystem. Let me try a couple of others for grins and giggles.

I tried both using a vmdk created by VMWare and also one created with "VBoxManage internalcommands createrawvmdk -filename /..path../hda2.vmdk -rawdisk /dev/hda -partitions 2".

Cheers,
Eddie

Re: xfs Filesystem corruption using rawdisk partitions

Posted: 4. Apr 2009, 03:56
by EddieA
Well, reiserfs is very unhappy as well. After the 2nd re-boot, it would even finish booting any more. Modules not found, programs not executable, directories missing, etc.

Strange thing is though, fsck.reiserfs doesn't report any problems with the partition, and if I mount it on the host, everything looks good. Hmmmmm.

Cheers,
Eddie

Re: xfs Filesystem corruption using rawdisk partitions

Posted: 7. Apr 2009, 21:27
by EddieA
Not sure if this is relevant, or not. I noticed that if I power down the VM, and then immediately after the power down I run an xfs_check on the host, I get this:

Code: Select all

ERROR: The filesystem has valuable metadata changes in a logwhich needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_check.  If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.
It's only a few seconds after the VM is powered off does xfs_check come back clean. I'm guessing that this is the hard disk cache being flushed.

I still can't see how this could affect what I'm doing, because if this data wasn't flushed out, when the disk is next mounted, the log would be replayed, and the data synced up. Plus, I'm running an xfs_check between each step, and only continuing when that comes back "clean".

Or, am I missing something to do with how the buffers are written to the the disk, and how the cache works, under both a "power down" situation for the VM, and a mount/write/umount sequence on the host, as I only seen to get the corruption, in the VM, following a mount/write/umount on the host.

Cheers,
Eddie