Solved Moving files into a new dataset on the same path

How do I move existing files into a new dataset on the same file path, without using the copy command?

Example:

Code:
# zfs list | grep -i tmp
zroot/tmp  4.01M  2.23T  4.01M  /tmp
zroot/var/tmp  104K  2.23T  104K  /var/tmp
# mkdir test
# echo something >test/file
# cat test/file
something
# zfs create zroot/tmp/test
# zfs list | grep -i tmp
zroot/tmp  4.11M  2.24T  4.02M  /tmp
zroot/tmp/test  96K  2.24T  96K  /tmp/test
zroot/var/tmp  104K  2.24T  104K  /var/tmp
# cat test/file
cat: test/file: No such file or directory
# zfs destroy zroot/tmp/test
# cat test/file
something

I'm not claiming this behaviour is abnormal, I'm just wondering how can I create a new dataset that keeps it's files, ... basically, what I want is work in an existing filesys and add new settings for that specific path.
 
I'm not aware of a way to create a new dataset and automatically import existing data into it (please, someone correct me if I'm wrong). You will have to move the existing data out of the way. If you don't want to use the cp command you could use mv or a safer option net/rsync.
 
Hmm, I wonder if I use snapshot if I could re-import the data faster or export and import...

See I have a jailed system, which has a pool but I want the MySQL database to have different block size then the regular system, and reserve some space for specific directories such as /var/tmp, so when the filesystem is full it can still serve webpages.

I wonder if I make a snapshot mount create ZFS datasets and then do a rollback if the system would just copy all the data to the pools, that or use import/export in the same way.
 
It looks like you are basically mounting a new filesystem in an already used directory. This shadows the old content, so you can no longer see it. You would need to first rename the directory, create the file system in that place, and then move the data from the directory you had there to the new one. That new one would then be the new file system. When done, remove the renamed directory.

You would get the same behaviour with other file systems also, by the way. So this is not a ZFS problem.
 
I'm not claiming it is a problem. What I'm asking is:

How can I keep the files without having to copy or move them to the new dataset and still create a new data set under that same directory?
 
You can't.

The new file system which is mounted covers the directory below, the old contents becomes invisible and inaccessible. The new file system mounted on that place may be made of other discs, may even be some network resource. The kernel can not move the data for you to a place it has no control over, so it is not done even for local places where it might be possible. That is your job as the administrator.
 
I know it is. However maybe there is/was some command/setting I didn't know/think of.
 
Back
Top