# Setting up gmirror to add existing system disk



## frysco (Apr 23, 2013)

I am trying to set up gmirror on my recently updated FreeBSD 9.1 system according to the documentation in part 20.4.3 of the FreeBSD Handbook, but I am having problems when I attempt to restore the partition table to the second drive (ada1).

My partition table on ada0 looks as follows:

```
: 2/root@cornix:~# gpart show ada0
=>        63  1465149105  ada0  MBR  (698G)
          63  1465149105     1  freebsd  [active]  (698G)

: 2/root@cornix:~# gpart backup ada0 > table.ada0

: 2/root@cornix:~# gpart backup ada0s1 > table.ada0s1

: 2/root@cornix:~# cat table.ada0
MBR 4
1 freebsd         63 1465149105   [active]

: 2/root@cornix:~# cat table.ada0s1
BSD 8
1  freebsd-ufs          0    4194304
2 freebsd-swap    4194304   50331648
4  freebsd-ufs   54525952    4194304
5  freebsd-ufs   58720256   67108864
6  freebsd-ufs  125829120   67108864
7  freebsd-ufs  192937984 1272211121
```

As there is no free space at the end of ada0, I do what the documentation says, and reduce the size of the slice and last partition by one. 


```
: 2/root@cornix:~# cat table.ada0
MBR 4
1 freebsd         63 1465149105   [active]

: 2/root@cornix:~# cat table.ada0s1
BSD 8
1  freebsd-ufs          0    4194304
2 freebsd-swap    4194304   50331648
4  freebsd-ufs   54525952    4194304
5  freebsd-ufs   58720256   67108864
6  freebsd-ufs  125829120   67108864
7  freebsd-ufs  192937984 1272211121
```

The problem is with restoring the slice information. The partition table restores fine, but I get 'Invalid argument' when restoring the slice:


```
: 2/root@cornix:~# gpart restore mirror/gm0 < table.ada0

: 2/root@cornix:~# gpart restore mirror/gm0s1 < table.ada0s1
gpart: size '1272211120': Invalid argument
```

I'm pretty much stuck at this point, and could use some pointer as to which way to go. I've tried reducing the values by more than 1, but I still get the Invalid argument message.

Thanks in advance.


----------



## wblock@ (Apr 23, 2013)

Please show `diskinfo -v` output for both drives.

If a previous disklabel is present at the start of the slice, that can interfere with creating the new one.  Using `gpart restore -F` should help if that is the problem.


----------



## frysco (Apr 23, 2013)

Hi, thanks for the reply. 

Here's the output:


```
: 2/root@cornix:/# diskinfo -v ada0
ada0
	512         	# sectorsize
	750156374016	# mediasize in bytes (698G)
	1465149168  	# mediasize in sectors
	0           	# stripesize
	0           	# stripeoffset
	1453521     	# Cylinders according to firmware.
	16          	# Heads according to firmware.
	63          	# Sectors according to firmware.
	S13UJ1NQ917606	# Disk ident.

: 2/root@cornix:/# diskinfo -v ada1
ada1
	512         	# sectorsize
	750156374016	# mediasize in bytes (698G)
	1465149168  	# mediasize in sectors
	0           	# stripesize
	0           	# stripeoffset
	1453521     	# Cylinders according to firmware.
	16          	# Heads according to firmware.
	63          	# Sectors according to firmware.
	9VP3PYCF    	# Disk ident.
```


----------

