0

I have a partition /dev/sdb2 formatted as fd and that is mounted as /var. I need to make this partition ready to raid 1 ( for this example /dev/md1 ). I still don't have the second HD, but want to prepare it in a way that when the HD arrives, it's just a matter of plugging and adding to raid array.

As this partition is my /var, i rebooted system with a live cd and tried to create with the following command:

mdadm --create /dev/md1 --level=1 --raid-disks=2 /dev/sdc2 missing

It complains about this being a part on an array, but i accept and md1 is created. Them i use:

mdadm --examine --scan >> /mnt/sdc1/etc/mdadm.conf

To copy mdadm information to the / hd. Also, i change fstab, to use /dev/md1.

The issue is that when i reboot, i get an error because of differences between physical and filesystem size. The full error is:

The filesystem size (according to the superblock is 52428127 blocks
The physical size of the device is 52428096 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort(y)?

Any ideas of what causes this?

After that, the only way to get the system back is rebooting again to live cd, and running this on partition:

mdadm --zero-superblock /dev/sdc2

Thanks.

Fernando
  • 1,129
  • 6
  • 23
  • 32

1 Answers1

1

MD needs to store metadata about the RAID state in order to keep information consistent. With the default superblock version (0.90) and version 1.0, this data is stored at the end of the device. This reduces the amount of space the filesystem can use. To fix this, first shrink the filesystem to something well under the total size (I'd subtract 100 MB or so to be safe), add the metadata as you did, then resize it again to the actual new size. For example, if you have a 5 GB ext3 filesystem, then

resize2fs /dev/sdc2 4900M
mdadm --create, --examine as above
resize2fs /dev/md1 # This resizes the filesystem to the actual size of the device

When you're computing sizes, make sure you're consistently using base-2 or base-10 sizes.

Ben Jencks
  • 1,351
  • 8
  • 13
  • (Commenting here because I can't comment on the question) You say /dev/sdb2 at the top, and then use /dev/sdc2 everywhere else. My answer assumes you meant /dev/sdc2 consistently. – Ben Jencks Nov 06 '10 at 18:32