# Post installation creation of a ZFS partition...



## ttsiod (Sep 5, 2011)

I have a machine with two 2GB drives, seen by FreeBSD as ad4 and ad6. At install time, I created a small (4GB) partition in ad4 (ad4s1), and installed FreeBSD inside it (so it has slices).


```
$ ls -l /dev/ad[46]*
crw-r-----  1 root  operator    0,  89 Sep  5 19:51 /dev/ad4
crw-r-----  1 root  operator    0,  90 Sep  5 19:51 /dev/ad4s1
crw-r-----  1 root  operator    0,  91 Sep  5 21:51 /dev/ad4s1a
crw-r-----  1 root  operator    0,  92 Sep  5 19:51 /dev/ad4s1b
crw-r-----  1 root  operator    0,  93 Sep  5 21:51 /dev/ad4s1d
crw-r-----  1 root  operator    0,  94 Sep  5 21:51 /dev/ad4s1e
crw-r-----  1 root  operator    0,  95 Sep  5 21:51 /dev/ad4s1f
crw-r-----  1 root  operator    0,  96 Sep  5 19:51 /dev/ad6
```

Now, I wanted to create a ZFS mirror, formed from the rest of ad4, and the complete ad6. I therefore booted my FreeBSD, invoked sysinstall, and 

1. sysinstall
2. Configure
3. Fdisk
4. selected ad4
5. selected the unused space
6. pressed C
7. pressed enter when asked about space 
8. pressed W
9. selected none when asked about boot manager.

FreeBSD complained about:


```
ERROR: unable to write data to disk ad4! 
    To edit the labels on a running system set sysctl kern.geom.debugflags=16 
    and try again.
```

So I did as it suggested, and this time, Fdisk responded with  
	
	



```
Write sucessful
```
All seemed to be OK.

I did the same process for ad6 (created a single huge partition, ad6s1).

And then tried to create a ZFS pool from the two (using mirroring):

`zpool create zroot mirror /dev/ad4s2 /dev/ad6s1`

But apparently, even though ad6s1 was there, ad4s2 ... was missing! I thought - maybe the kernel needs to see the partition table upon booting and can't tolerate changes during runtime - so I rebooted and got:  
	
	



```
Invalid partition table.
```

Boot failed :-(

What did I do wrong? And more importantly, how can I recover? 

Thanks in advance for any help,
Thanassis.


----------



## SirDice (Sep 5, 2011)

Your problems have started when you used sysinstall. Only use it for the initial install and never ever after that.

It's quite likely you've nuked your original slices/partitions. There may be a way to restore it but I would suggest a reinstall as it's usually quicker.


----------



## ttsiod (Sep 5, 2011)

Well, even if it is too late - can you show me the explicit commands with the arguments I should have used to create the two partitions without sysinstall?


----------



## SirDice (Sep 5, 2011)

Handbook: 18.3 Adding Disks


----------



## ttsiod (Sep 5, 2011)

Just a quick note: the link you pointed to does include "sysinstall" in the suggestions...


----------



## SirDice (Sep 5, 2011)

ttsiod said:
			
		

> Just a quick note: the link you pointed to does include "sysinstall" in the suggestions...



I know, just skip that bit 

Sysinstall is horrible and about to be surgically removed anyway (9.0-RELEASE will use a different installer).


----------

