0

I'm experiencing a weird situation on RHEL-7. I create a device mapper (crypt) over a disk partition and then copy data (bytes) from disk partition to mapper. The blkid output has two entries for the UUID - one for disk partition and other for mapper. The UUID under /dev/disk/by-uuid points to mapper as it was overwritten.

blkid output:

/dev/sdc1: UUID="1e762c4a-0b12-40fc-9f53-a825016211a0" TYPE="ext4"

/dev/mapper/my_mapper: UUID="1e762c4a-0b12-40fc-9f53-a825016211a0" TYPE="ext4"

/dev/disk/by-uuid output:

lrwxrwxrwx 1 root root 10 Jan 31 10:24 1e762c4a-0b12-40fc-9f53-a825016211a0 -> ../../dm-4

Now, I again copy data (bytes) from mapper to disk partition and close the mapper. The UUID under /dev/disk/by-uuid points to disk partition and blkid output shows UUID for the disk partition.

blkid output:

/dev/sdc1: UUID="1e762c4a-0b12-40fc-9f53-a825016211a0" TYPE="ext4"

/dev/disk/by-uuid output:

lrwxrwxrwx 1 root root 10 Jan 31 10:24 1e762c4a-0b12-40fc-9f53-a825016211a0 -> ../../sdc1

but, once I try to mount the disk partition, I get the error:

mount -t ext4 -o rw /dev/sdc1 /mnt/plainDisk
mount: wrong fs type, bad option, bad superblock on /dev/sdc1.

and then the disk disappears from blkid output. The /dev/disk/by-uuid is still present with correct UUID and lsblk shows the disk.

I'm using blockdev --getsize64 to get the size of disk in bytes and then copying all these bytes.

Any inputs or pointers are appreciated. I'm not facing this issue on RHEL-6 though.

Additional Info:

  1. I use fsync over /dev/sdc1 file descriptor once all data is copied.
  2. I verified the dumpe2fs output when /dev/sdc1 was present after second copy. It matched the original values. However, once the entry was removed, the dumpe2fs gives the error:

dumpe2fs 1.42.9 (28-Dec-2013)

dumpe2fs: Bad magic number in super-block while trying to open /dev/sdc1

Couldn't find valid filesystem superblock.

3
  • What does dmesg say?
    – Attie
    Commented Mar 6, 2018 at 11:28
  • There was no error in dmesg other than "wrong fs type". Commented Mar 6, 2018 at 11:29
  • VFS: Can't find ext4 filesystem Commented Mar 6, 2018 at 11:34

1 Answer 1

1

The issue was that while copying data back from my_mapper to sdc1, my_mapper was still mounted. This somehow affected the superblock on the device. I ran dumpe2fs and checked that there are some entries related to mount in the superblock.

unmounting the mapper before copying the data resolved the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .