# zfs create is silently destructive



## chancey (Aug 5, 2010)

After installing freebsd 8.1 64bit on a new server I soon worked out that "zfs create" will destroy directories when creating datasets, this is very bad, at least give me a warning.

Is there a way to create datasets on folders that already exist? For example I want to create a filesystem for /usr/local/pgsql/data to turn compression off, how do I create this without destroying everything in /usr?


----------



## graudeejs (Aug 5, 2010)

```
# zfs create zpool/usr2
# cp -Ra /usr* /usr2/
# rm -R /usr
# zfs rename zpool/usr2 zpool/usr
```

but this should be done in fixit mode (boot from DVD)

Usually such file systems you create before you install FreeBSD....


----------



## jem (Aug 5, 2010)

`# zfs create -o mountpoint=`


----------



## graudeejs (Aug 5, 2010)

ye, that too


----------



## vermaden (Aug 5, 2010)

chancey said:
			
		

> zfs create is silently destructive



_"UNIX was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things."_
*Doug Gwyn*​


----------



## phoenix (Aug 6, 2010)

It's not destructive.  It's perfectly normal behaviour, same as for any other filesystem.

When you mount a blank filesystem overtop of an existing directory, the new mount will "hide" the files in the directory.  They are still there, but "hidden" by the new filesystem mounted overtop.

You can do this with any filesystem.

Why it looks "destructive" is that *zfs create* automatically mounts the new filesystem.

Just unmount it (*zfs umount poolname/filesystem*) or change the mountpoint (*zfs set mountpoint=/new/path poolname/filesystem*), and the contents of the original directory will be made available again.


----------

