gmirror: can't mirror a slice

I did a fresh install of freebsd 8 on one of my two identical 500gb sata hard disk. I want to setup raid1 using gmirror. I'm trying to mirror the first slice where freebsd is installed.
Right after install (before rebooting) I ran:
Code:
sysctl kern.geom.debugflags=17
gmirror label -vb round-robin gm0 /dev/ad0s1
and I get the following error:
Code:
gmirror: Can't store metadata on /dev/ad0s1: Operation not permitted.
Also I tried to set kern.geom.debugflags to 16 but I get the same error.

Can someone help?
 
presario said:
I'm trying to mirror the first slice where freebsd is installed.
Code:
gmirror label -vb round-robin gm0 /dev/ad0s1

Is /dev/ad0s1 your current root filesystem?

Which configuration do you want to have at the end? A mirror between two full disks or between slices on each disk?
 
Yes freebsd is installed /dev/ad0s1.
As I wrote I want to mirror between slices on each disk.
Thanks.
 
OK, in the handbook a mirror between full disks is described: http://www.freebsd.org/doc/handbook/geom-mirror.html

To mirror between slices you have to use an approach that's a little different.

Create the slices on the second disk (I presume ad1) and then create a mirror for the root filesystem:
# gmirror label -vb round-robin root /dev/ad1s1
(BTW, normally, this would be ad1s1a, but this depends on the "style" of partitioning/slicing)

Create a filesystem on it and mount it:
# newfs /dev/mirror/root
# mount /dev/mirror/root /mnt

Then move your installation over to the mirror:
# cd /mnt
# dump 0af - / | restore rf -

edit /mnt/etc/fstab to contain the new entries (/dev/mirror/root and turn of swap if it sohuld be mirrored, too)

Then boot thesystem from the second disk (you may need to install bootblocks on ot!) and add the slice on the first disk to the mirror.

This procedure has to be done for every filesystem on the first disk.
 
I have two questions.

1. Why wouldn't
Code:
gmirror label -vb round-robin gm0 /dev/ad0s1
work? Because it's already mounted? Then why does the following work?
Code:
gmirror label -vb round-robin gm0 /dev/ad0

2. Your method seems to be mirroring between partitions inside slices. Is it?

Thanks for help.
 
presario said:
Because it's already mounted?
Yes.

presario said:
Then why does the following work?
Probably because gmirror stores metadata in the last block of a device and in your situation the last block of ad0 doesn't collide with anything in ad0s1.

presario said:
Your method seems to be mirroring between partitions inside slices. Is it?
Not from what I can see...
 
Ok, I've finally managed to accomplish to create a mirror between two slices. It turned out to be quite easy.

1. Installed FreeBSD 8.0 on the first slice of ad0.
2. Rebooted using the install DVD and entered the Fixit mode.
3. Copied the slice table to the second disk.
Code:
dd if=/dev/ad0 of=/dev/ad2 bs=512 count=1
4. Created a mirror using the first slice of the disk where FreeBSD was installed.
Code:
sysctl kern.geom.debugflags=17
gmirror label -vb round-robin gm0 /dev/ad0s1
5. Mounted the root partition on /mnt.
6. Enabled loading of the GEOM module during boot.
Code:
echo ’geom_mirror_load="YES"’ >> /mnt/boot/loader.conf
7. Edited the fstab file replacing all 'ad0s1' instances with 'gm0'.
Code:
vi /mnt/etc/fstab
:%s/ad0s1/mirror\/gm0/g
:x
8. Rebooted into my installation.
9. Added the first slice on the second disk to the mirror.
Code:
gmirror insert -v gm0 /dev/ad2s1

Thanks to mmoll and aragon for help.
 
Back
Top