zfs create is silently destructive

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?
 
Code:
# 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....
 
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

:p
 
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. :)
 
Back
Top