DRBD on a disk with existing file system that takes all the place
I'm currently trying to simulate the environment via XEN. I have installed two debian systems with such FS layout:
cltest1:/etc# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda2 6.0G 417M 5.2G 8% / tmpfs 257M 0 257M 0% /lib/init/rw udev 10M 16K 10M 1% /dev tmpfs 257M 4.0K 257M 1% /dev/shm
Host cltest2 is identical.
Here's my drbd.conf
global { minor-count 1; } resource mysql { protocol C; syncer { rate 10M; # 10 Megabytes } on cltest1 { device /dev/drbd0; disk /dev/xvda2; address 192.168.1.186:7789; meta-disk internal; } on cltest2 { device /dev/drbd0; disk /dev/xvda2; address 192.168.1.187:7789; meta-disk internal; } }
I have not created filesystem on drbd0
Starting DRBD via init.d script errors out with:
Starting DRBD resources: [ d(mysql) /dev/drbd0: Failure: (114) Lower device is already claimed. This usually means it is mounted. [mysql] cmd /sbin/drbdsetup /dev/drbd0 disk /dev/xvda2 /dev/xvda2 internal --set-defaults --create-device failed - continuing!
Running: drbdadm create-md mysql gives:
cltest1:/etc# drbdadm create-md mysql md_offset 6442446848 al_offset 6442414080 bm_offset 6442217472 Found ext3 filesystem which uses 6291456 kB current configuration leaves usable 6291228 kB Device size would be truncated, which would corrupt data and result in 'access beyond end of device' errors. You need to either * use external meta data (recommended) * shrink that filesystem first * zero out the device (destroy the filesystem) Operation refused. Command 'drbdmeta /dev/drbd0 v08 /dev/xvda2 internal create-md' terminated with exit code 40 drbdadm aborting
As I understand, all of my problems are because I don't have unallocated disk space on xvda2.
What are my options besides shrinking FS and connecting a separate physical disk? Can't the meta-data be stored on a file in the local filesystem?
Solution 1:
drbd can sometimes pickup 'existing' filesystems even without one being on the sytem. You could of dd if=/dev/zero of=/dev/xvda2
(and control-C after a few secs) and it will clear the partition that could of held a filesystem before.
Solution 2:
You are not suppose to mount the disk with any filesystem format; In Ubuntu, using gparted I specified the /dev/xvda2 to "Cleared" partition. and running the same command removes the above error.