4

ubuntu 14.04 installed on 128Gb ssd zfs pool ("zfshome") across 3x3TB disks, containing audio/video/tv etc.

I originally built this as a nas4free NAS serving my windows boxes around the house.I'm now tryin to turn it into a media server,and being always on,wanted the stabilty of ubuntu,(now that it's more user friendly, in terms of normal users...) Tt seems to me that putting /home/user on the zpool made sense,(being a newby I do frequent reinstalls), but after a week I cannot find clear instructions how to achieve it, and after so many attempts am thoroughly confused.

Any help appreciated, Ian

3 Answers 3

2
  1. YMMV. Make sure anything said below makes sense to you.

  2. Ensure that you can login, via at least one admin-enabled account (can manage ZFS), when the NAS is down.

  3. Copy, via tar or rsync (not cp) all of your old HOME directory (/home/you) to the new HOME directory, mounted some temporary place line /media/$USER/newhome.

  4. Backup, then edit /etc/fstab to NFS mount the appropriate NAS directory as /home/you. See man fstab about NFS mounts, man mount, too. Use the auto option. Do NOT mount it yet.

  5. Carefully delete most of the files/directories in your old HOME directory, just leaving enough of the structure so that you can login with the files here, in case the mount fails.

  6. logout and login to verify what you did in step 4.

  7. If all seems OK, mount the NAS HOME directory via:

    sudo mount /home/you

  8. sudo shutdown -r now to reboot your system, make all processes forget about your old $HOME, and start over with /home/you mounted.

2
  • thanks for responding , but I 'm confused,the zpool is on the same pc as the /home/user I want to move...and from all I've read zfs automounts on boot so fstab shouldnt be involved .I've been creating th new directory with.........sudo zfs create zfshome/newhomez.......and then,
    – nodsa
    Oct 8, 2015 at 9:45
  • ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
    – nodsa
    Oct 8, 2015 at 9:54
2

How to move /home directory into a ZFS pool on Linux Mint 19XFCE-64bit

Reference: https://freedompenguin.com/articles/how-to/move-linux-home-zfs/

This procedure has been tested on a guest Linux Mint 19XFCE 64bit inside VirtualBox V5.2.22

Host system Linux Mint 18 KDE 64 bit

  • Anything described below refers to the guest OS.

  • Procedure is not 100% step by step. Some steps are described giving their gobal meaning, not

going in deep details.

  • Every time it will be mentioned the word “user” it means YOUR user directory name (for example instead of /home/user/Documents put /home/jonathan/Documents where jonathan is an example name)

  • Following procedure is valid for one single user.

  • Last, but not less important, forgive my english. I am italian.

Procedure

installation of zfs utils by terminal

sudo apt install zfsutils-linux

By using G-Parted:

Reduce the only available partition to a reasonable value (let’s say 20-25 Gbyte).

On free space created by previous step, create a new partition NOT formatted.

By file browser, go to /dev/disk/by-id/ and take note of second partition name. Such partition is that one just created (NOT formatted) that will host ZFS pool dedicated to /home directory. In my case, second partition name was ata-VBOX_HARDDISK_VB49b2d698-41fa84b3-part2 You will see such name in the pool creation sintax here below.

Now we create the zhome pool using the partition 2 NOT formatted we just created.

By terminal

zp=zhome

sudo zpool create -o ashift=12 -o autoexpand=on -o autoreplace=on -O atime=off -O compression=lz4 $zp /dev/disk/by-id/ata-VBOX_HARDDISK_VB49b2d698-41fa84b3-part2

The detailed meaning of different parameters can be found in the reference article mentioned at the beginning.

Now we must backup directory /home/user/ into a temporary directory such as /tmp/user-bck/

By terminal

sudo rsync -avh /home/user/ /tmp/user-bck/

Now we must erase directory /home I don’t know why, but command must be given twice to succeed (first time it warns "directory is not empty"...)

By terminal

sudo rm -r -f /home
sudo rm -r -f /home

SOME NOTES

1) it is a good thing having ZFS Datasets instead of IMPORTANT directories. That because it will allow to take selective snapshots SPECIFIC for each directory. VERY useful, just to mention, in case of Each virtual machine directory...

2) Each dataset is seen by file browser as a NORMAL directory. So, inside of it, we can then create whatever subdirectories we want. BUT IT IS FORBIDDEN to create a ZFS Dataset in this way: pool/dataset1/directory/dataset2

3) Snapshots apply to datasets only, NOT to directories…

Now let’s create EVERY ZFS Datasets with EXACTLY the same name as /home/user directories (Documents, Music, etc.) Be carefull: I translated the names of directories from italian to english. Please, make sure of the sintax (Documents, Pictures, Music, etc.)

By terminal

sudo zfs create -o sharesmb=off $zp/home

sudo zfs create $zp/home/user

sudo zfs create $zp/home/user/Documents

sudo zfs create $zp/home/user/Pictures

sudo zfs create $zp/home/user/Music

sudo zfs create $zp/home/user/Video

sudo zfs create $zp/home/user/Models

sudo zfs create $zp/home/user/Download

sudo zfs create $zp/home/user/Desktop

Now we give (immediate and permanent) instruction to ZFS about mount point of the pool zhome/home. Mount is performed immediately and will be performed on every boot.

By terminal

sudo zfs set mountpoint=/home $zp/home

Now we must restore /home/user backup and place it into the new, EMPTY, just mounted, /home directory.

By terminal

cd /
sudo rsync -avh --ignore-existing /tmp/user-bck/ /home/user/

Option –ignore-existing is given to avoid overwriting of directories on the same-name ZFS Datasets (Documents, Music, etc.)

Now reboot system

By terminal

sudo reboot

Tested on 21 Novembre 2018 ore 22:30.

Regards

Michele

0

zstore is pool, ian is user1

logged in as user1 do;

  • create user2 with admin priveliges

  • create new folder: sudo mkdir /temphome

  • move user2's home: sudo usermod -m -d /temphome/user2 user2

  • reboot

  • login as user2

  • move user1's home: sudo usermod -m -d /temphome/user1 user1

  • create empty dataset: sudo zfs create zstore/zhome

  • as /home is now empty, mount new dataset in/home: sudo zfs set mountpoint=/home zstore/zhome

  • move user1's home back to /home : sudo usermod -m -d /home/user1 user1

  • reboot

  • login as user1

  • move user2's home from temp back to /home : sudo usermod -m -d /home/user2 user2

  • tidy up: sudo rmdir /tmphome

all done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .