# ZFS: adding filesystem over existing directory



## hedgehog (Sep 29, 2011)

Greetings.
I'd like to use zfs snapshots for making backups of third-party software before the huge port upgrades. Unfortunately, I didn't create the separate /var/db/pkg and /usr/local filesystems. I have the following FS on my PC:

```
$ zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
zroot             344G   108G  10,7G  legacy
zroot/media       223G   108G   223G  /media
zroot/tmp        1,45G   108G  1,45G  /tmp
zroot/usr         108G   108G  24,6G  /usr
zroot/usr/home   83,1G   108G  83,1G  /usr/home
zroot/usr/src     309M   108G   309M  /usr/src
zroot/var        1,57G   108G  1,12G  /var
zroot/var/empty    20K   108G    20K  /var/empty
zroot/var/log     103M   108G   103M  /var/log
zroot/var/tmp     358M   108G   358M  /var/tmp
```

Is there any way to safely add /usr/local to my zpool? Should I boot in single-user mode, rename /usr/local, create FS and get the data back? Or maybe there is much better solution?


----------



## phoenix (Sep 30, 2011)

That's pretty much the process:

boot into single-user mode or off a LiveCD like Frenzy
*mv* /usr/local to somewhere else
create the ZFS filesystem for /usr/local
*mv* all the data from old directory to /usr/local
boot into multi-user


----------



## hedgehog (Sep 30, 2011)

phoenix said:
			
		

> That's pretty much the process:
> 
> boot into single-user mode or off a LiveCD like Frenzy
> *mv* /usr/local to somewhere else
> ...


Thanks a lot. Really silly question: moving /usr/local to another destination and back using the mv() command shouldn't break symlinks, right?


----------



## hedgehog (Sep 30, 2011)

Okay, it's worked. Everything went fine except that I used the cp() insead of mv() to get the data back. In this case you really want to use -p flag to preserve permissions and suid flags.


----------

