Proper way to create a zfs off an existing directory?

11,364

Solution 1

It isn't supported to turn /etc into its own zfs file system.

The reason is that /etc is needed during the early stages of boot, before (Open)Solaris starts to mount zfs file systems, so it would be empty if you change it.

My guess is that you want to take snapshots of /etc, but you can just take snapshots of the root file system instead:

zfs snapshot rpool/ROOT/opensolaris

You may have to replace opensolaris with the name of the current boot environment (run beadm list to find out which)

Solution 2

There isn't a built-in or automated way to create a new DataSet and migrate existing data to it. To get it done you'll need to create the dataset and manually (e.g. rsync) the data to it.

Let's say you have a dataset named tank\set with a directory in it named folder. You want to 'promote' the folder to be a child dataset named tank\set\folder:

mv /mnt/tank/set/folder /mnt/tank/set/folder-backup # move this out of the way so the new dataset doesn't mount on top of it
zfs create tank/set/folder
rsync -aAX /mnt/tank/set/folder-backup/ /mnt/tank/set/folder # bring over all the old data including acls and attributes

Then review that the data looks good; take a snapshot of the parent dataset just in case, and delete the folder-backup directory.

Share:
11,364

Related videos on Youtube

Yurii Rashkovskii
Author by

Yurii Rashkovskii

Updated on September 17, 2022

Comments

  • Yurii Rashkovskii
    Yurii Rashkovskii over 1 year

    Lets say I have an rpool with etc/ as a regular directory within it and now I want to create a separate zfs rpool/etc, obviously inheriting all the data I had in original /etc.

    What would be the most proper and safe way to do so?

  • Yurii Rashkovskii
    Yurii Rashkovskii almost 15 years
    ok, what about any other directory, then? say, rpool/zones/myzone/export/home/git? :)
  • Martin
    Martin almost 15 years
    If you want to turn your git directory into a zfs filesystem, you just need to make tar archive of the current contents, then "rm -rf" the git dir, after that run "zfs create -o mountpoint=/path/to/git rpool/path/to/whatever/git" and finally untar the saved files.
  • Yurii Rashkovskii
    Yurii Rashkovskii almost 15 years
    oh, ok, that's what I thought... but secretly hoped there was a transparent way to split zfs :)