# Root on ZFS, copy drive



## zzattack (Feb 16, 2011)

I have a FreeBSD install on a large disk that I wish to replace by an SSD. The disk has 3 gpt partitions (boot/swap/zfs) and I wish to fully copy the disk. So, I put the same GPT layout on the SSD, installed the bootcode, and then sent over the filesystem.


```
gpart create -s GPT ad10
# further gpart layout
..
zpool create tanknew ad10p3
zfs snapshot tank@now
zfs send -R tank@now | zfs receive -D -f tanknew
```

So far so good. Now I try booting from the zpool tanknew, which I expect to fail as it will try to mount root from zfs:tank. Indeed it fails, and gives me the option to mountroot from a different filesystem. I attempt zfs:tanknew, but this results in the same error.

So I went looking for solutions. I've mounted the tanknew fs in a different filesystem and attempted to rename it to tank. Now, this still doesn't work either. Next I tried getting a fresh /boot/zfs/zpool.cache in place, but it doesn't appear to make a difference either, so I'm stuck. 

Any ideas on what last piece of magic is required before I can boot again?


----------



## da1 (Feb 16, 2011)

No idea about your way, but when I had this problem, I simply created a mirror and then booted from the 2nd drive alone. Then, I simply "detach"-ed the first drive and voila ....

Of course, I created the GPT before


----------



## jem (Feb 16, 2011)

1. Set the bootfs property on the pool
2. Set vfs.root.mountfrom= in /boot/loader.conf


----------



## zzattack (Feb 16, 2011)

jem: I've done both.


----------



## nakal (Feb 16, 2011)

Did you set the pool mountpoint to "legacy"? You need to do it to mount zfs manually.

The wiki-pages are broken at the moment, but you can read about it here.

I'm booting from mirror, so I used this howto.


----------



## zzattack (Feb 16, 2011)

Yep, it's set to legacy.

Booting from my old disk up to the FreeBSD loader screen (where I can pick normal boot, single user etc), unplugging it, and letting it continue to boot from my SSD actually works. When I boot from just the SSD though, it gives the mountroot error.


----------



## da1 (Feb 16, 2011)

try setting

```
<pool_name>     /     zfs     rw      1 1
```
 to /etc/fstab


----------



## zzattack (Feb 16, 2011)

It seems my zpool.cache was bugged after all. I found out by setting 
	
	



```
vfs.zfs.debug=1
```
 in the grub loader. After that I used a LiveFS cd to import and export my pool in order to create a new zpool.cache. Mounting the zfs:tank for a minute, copying the zpool.cache into the /boot/zfs/ dir and setting the mountpoint back to legacy did the trick.


----------

