How do I move /home/user to a zfs pool?











up vote
3
down vote

favorite












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










share|improve this question


























    up vote
    3
    down vote

    favorite












    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










    share|improve this question
























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      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










      share|improve this question













      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







      home-directory zfs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 8 '15 at 3:29









      nodsa

      164




      164






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote














          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.







          share|improve this answer





















          • 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 '15 at 9:45










          • ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
            – nodsa
            Oct 8 '15 at 9:54


















          up vote
          1
          down vote













          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



          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






          share|improve this answer










          New contributor




          Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

























            up vote
            0
            down vote













            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,






            share|improve this answer





















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f682841%2fhow-do-i-move-home-user-to-a-zfs-pool%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote














              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.







              share|improve this answer





















              • 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 '15 at 9:45










              • ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
                – nodsa
                Oct 8 '15 at 9:54















              up vote
              2
              down vote














              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.







              share|improve this answer





















              • 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 '15 at 9:45










              • ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
                – nodsa
                Oct 8 '15 at 9:54













              up vote
              2
              down vote










              up vote
              2
              down vote










              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.







              share|improve this answer













              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.








              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Oct 8 '15 at 7:24









              waltinator

              21.6k74169




              21.6k74169












              • 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 '15 at 9:45










              • ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
                – nodsa
                Oct 8 '15 at 9:54


















              • 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 '15 at 9:45










              • ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
                – nodsa
                Oct 8 '15 at 9:54
















              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 '15 at 9:45




              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 '15 at 9:45












              ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
              – nodsa
              Oct 8 '15 at 9:54




              ..and then,...sudo zfs setmountpoint=/home zfshome/newhomez ......and then............sudo usermod -m -d /zfshome/newhomez user
              – nodsa
              Oct 8 '15 at 9:54












              up vote
              1
              down vote













              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



              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






              share|improve this answer










              New contributor




              Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                up vote
                1
                down vote













                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



                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






                share|improve this answer










                New contributor




                Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  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



                  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






                  share|improve this answer










                  New contributor




                  Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  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



                  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







                  share|improve this answer










                  New contributor




                  Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer








                  edited Nov 23 at 1:39









                  s1mmel

                  1,099515




                  1,099515






                  New contributor




                  Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Nov 22 at 19:44









                  Michele

                  113




                  113




                  New contributor




                  Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Michele is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






















                      up vote
                      0
                      down vote













                      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,






                      share|improve this answer

























                        up vote
                        0
                        down vote













                        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,






                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          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,






                          share|improve this answer












                          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,







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Oct 19 '15 at 13:50









                          nodsa

                          164




                          164






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f682841%2fhow-do-i-move-home-user-to-a-zfs-pool%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How did Captain America manage to do this?

                              迪纳利

                              南乌拉尔铁路局