UFS How to create a mirror with a GPT master and a blank disk

Hi everybody,

I have a Freebsd 11.0 system installed on a single GPT partitioned disk (ada0).
I would like to create a mirror using an identical blank disk (ada1). I read that mirroring a full GTP disk may lead to system instability but that I may try to create a mirror for each partition. I would like to apply the following procedure, do you see any error/danger in it?

1) Backup/Restore the partitions from ada0 to ada1 using gpart
gpart backup ada0 > table.ada0
gpart restore ada1 < table.ada0

2) Create a mirror for the boot partition adding ada0p1 first and then inserting ada1p1
gmirror label -v boot ada0p1
gmirror insert boot ada1p1

3) Create a mirror for the swap partition adding ada0p3 first and then inserting ada1p3
gmirror label -v swap ada0p3
gmirror insert swap ada1p3

4) Create a mirror for the root partition adding ada1p2 first
gmirror label -v root ada1p2

4.1) Create a new filesystem on mirror/root
newfs -U /dev/mirror/root

4.2) reboot in single user mode

4.3) rsync / from ada0p1 to the newly created mirror
mount /dev/mirror/root /mnt/bkup
rsync -av --exclude={"/dev/*","/proc/*","/tmp/*","/mnt/*"} / /mnt/bkup

4.4) modify /etc/fstab to mount the mirrored root and swap, reboot

4.5) check that everything works!

4.6) insert ada0p2 into the root mirror
gmirror insert root ada0p2

Thanks for your advices!
Francesco
 
  • Thanks
Reactions: sdf
Why do the rsync to the new disk? Just create the mirror using the existing disk partition, then add the blank disk partition, and let gmirror sync the contents behind the scenes.

Or, are you trying to make it sync faster?
 
Hello Phoenix, thanks for your reply!
The reason is that I read somewhere that when creating a mirror on an existing partition some information is written at the end of the partition erasing any data stored there. Since I don't know whether these sectors are used I thought that doing the rsync would prevent that risk. Am I wrong? May I use the same logic I will use for the boot and swap partitions?
 
Mirroring works on a block level, rsync at the file level. This is simply not going to work. Using rsync a file on one disk may be on inode 1 (for example) and on the other disk at inode 100. When you create the mirror the existing data on the second disk is simply going to be overwritten with the data of the first disk. So the rsync is useless.
 
If there is no risk in creating the mirror using an existing partition then I would just create the mirror. But if there is the risk to overwrite any sector at the end of the partition then my idea was the following:
1) Create the mirror on the blank partition of the new disk
2) Rsync the content from the old disk (thus preventing the risk of overwriting sectors)
3) Add the original partition to the mirror (thus overwriting it, but the content should be the same)
 
The best way forward is just to dump(8) the partitions, save it somewhere safe and start setting up the mirror from scratch. Once the mirror has been set up restore(8) the data. There are so many things that can go wrong, risking it all is just not worth all the hassle.
 
Ok, I started the mirroring setup but whenever I issue the command

gmirror label -v swap ada0p3

though I get a successful answer:

Metadata value stored on ada0p3.
Done.


the mirror does not show up in the mirror list:

Code:
myserver# gmirror status
       Name    Status  Components
mirror/boot  COMPLETE  ada0p1 (ACTIVE)
                       ada1p1 (ACTIVE)


Any idea about what may be happening here?
Thanks!

EDIT: After loading gmirror in loader.conf and rebooting the swap mirror showed up in the list.
 
Back
Top