# gmirror: can't mirror a slice



## presario (Apr 13, 2010)

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:

```
sysctl kern.geom.debugflags=17
gmirror label -vb round-robin gm0 /dev/ad0s1
```
and I get the following error:

```
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?


----------



## mmoll (Apr 13, 2010)

presario said:
			
		

> I'm trying to mirror the first slice where freebsd is installed.
> 
> ```
> 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?


----------



## presario (Apr 13, 2010)

Yes freebsd is installed /dev/ad0s1.
As I wrote I want to mirror between slices on each disk.
Thanks.


----------



## mmoll (Apr 13, 2010)

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.


----------



## presario (Apr 13, 2010)

I have two questions.

1. Why wouldn't

```
gmirror label -vb round-robin gm0 /dev/ad0s1
```
work? Because it's already mounted? Then why does the following work?

```
gmirror label -vb round-robin gm0 /dev/ad0
```

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

Thanks for help.


----------



## aragon (Apr 13, 2010)

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...


----------



## presario (Apr 20, 2010)

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.

```
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.

```
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.

```
echo â€™geom_mirror_load="YES"â€™ >> /mnt/boot/loader.conf
```
7. Edited the fstab file replacing all 'ad0s1' instances with 'gm0'.

```
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.

```
gmirror insert -v gm0 /dev/ad2s1
```

Thanks to mmoll and aragon for help.


----------



## _martin (Oct 18, 2010)

recently Recently i I bumped [in]to this problem too .. i I didn't have an access to the installation media, though there is yet another way to do it - from the single in In single i I ran:

[cmd=]# gmirror label vg00 /dev/da0s1[/cmd]

i I had to reboot it immediately as I've lost all commands (probably due to / issues), again i I went to single mode, adapted the /etc/fstab and /boot/loader.conf and rebooted again - all ok.

not Not sure if this is 'kosher', but it worded for me../"> mode i I ran:

[cmd=]# gmirror label vg00 /dev/da0s1[/cmd]

i I had to reboot it immediately as I've lost all commands (probably due to / issues), again i I went to single mode, adapted the /etc/fstab and /boot/loader.conf and rebooted again - all ok.

not Not sure if this is 'kosher', but it worded for me../"> mode.

in In single i I ran:

[cmd=]# gmirror label vg00 /dev/da0s1[/cmd]

i I had to reboot it immediately as I've lost all commands (probably due to / issues), again i I went to single mode, adapted the /etc/fstab and /boot/loader.conf and rebooted again - all ok.

not Not sure if this is 'kosher', but it worded for me../"> mode i I ran:

[cmd=]# gmirror label vg00 /dev/da0s1[/cmd]

i I had to reboot it immediately as I've lost all commands (probably due to / issues), again i I went to single mode, adapted the /etc/fstab and /boot/loader.conf and rebooted again - all ok.

not Not sure if this is 'kosher', but it worded for me.


----------

