[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:zfs_home [2020/06/06 01:48 (UTC)] – [Create & Start ZFS] dchmelikhowtos:zfs_home [2024/02/12 14:12 (UTC)] (current) dchmelik
Line 1: Line 1:
 <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->
 ====== ZFS /home Partition/Drive ====== ====== ZFS /home Partition/Drive ======
-This tutorial/HOWTO is about installing/setup/using ZFS (file system) such as for your /home, for advanced/large storage or shared with a Unix operating system (OS) distribution (distro.)  Feel free to expand.+This tutorial/HOWTO is about installing/setup/using ZFS (file system, fs) such as for your /home partition/drive, for advanced/large storage or shared with a Unix operating system (OS) distribution (distro) Feel free to expand.
  
 ===== ZFS Introduction ===== ===== ZFS Introduction =====
-ZFS is a journalling filesystem (fscreated on Solaris Unix, then made Free/Libre/Opensource Software ([[http://fsf.org|FLS]], [[http://opensource.org/|OSS]], FOSS, FLOSS) as OpenSolaris' [[http://openzfs.org|OpenZFS]].  ZFS was ported to classic/most *BSD Unix (NetBSD, FreeBSD, OpenBSD, ...,) Slackware & other GNU/Linux distros, as [[http://zfsonlinux.org|ZFSonLinux]], and has more features than EXT*.  ZFS is more a fs & RAID manager than just fs.  If you have large amount of storage, you may want ZFS for that (and helpful features) or may want to use it for a /home partition (also possible to share with a real Unix, but some things, such as more complex X window managers (WM) & desktop environments (DE,) and some/many their programs, almost certainly won't work well between them... and there's a real chance some shells & command-line programs might not either, if different configurations/versions/variants.+ZFS is a journalling fs created on Solaris Unix, then made Free/Libre/Opensource Software ([[http://fsf.org|FLS]], [[http://opensource.org/|OSS]], FOSS, FLOSS) as OpenSolaris' [[http://openzfs.org|OpenZFS]].  ZFS was ported to classic/most *BSD Unix (NetBSD, FreeBSD, OpenBSD, ...)Slackware & other GNU/Linux distros, as [[http://zfsonlinux.org|OpenZFS]], and has more features than EXT*.  ZFS is more a fs & RAID manager than just fs.  If you have large amount of storage, you may want ZFS for that (and helpful features, such as compression, snapshots) or may want to use it for a /home partition (also possible to share with a real Unix, but some things, such as more complex X window managers (WM) & desktop environments (DE)and some/many their programs, almost certainly won't work well between them... arecordednd there's a real chance some shells & command-line programs might not either, if different configurations/versions/variants.
  
 If you just want multi-/dual-boot OS (including Unix) with same /home, ZFS is the only realistic solution... another maybe being NTFS, but has certain problems, such as maybe no to use Unix-like, rather than Windows-like, file-names so also utilities, and ZFS is safer.  ZFS may be the only journalling fs Unix and GNU/Linux can both write to safely. If you just want multi-/dual-boot OS (including Unix) with same /home, ZFS is the only realistic solution... another maybe being NTFS, but has certain problems, such as maybe no to use Unix-like, rather than Windows-like, file-names so also utilities, and ZFS is safer.  ZFS may be the only journalling fs Unix and GNU/Linux can both write to safely.
  
-Of course, Xen (a hypervisor virtual machine) is another excellent option for multiple native-on-hardware OS, including Unix, but you might just have to copy between fs and not all OS write well... so you could even try Xen with ZFS storage...)+Of course, Xen (a hypervisor virtual machine) is another excellent option for multiple native-on-hardware OS, including Unix, but you might just have to copy between fs and not all OS write well... so you could even try Xen with ZFS storage...).
  
-===== Always Backup /home Regularly=====+===== Always Backup /home Regularly.  Make the ZFS package=====
  
 Here's how you can prepare to create a ZFS /home. Here's how you can prepare to create a ZFS /home.
  
-If you have a current /home with files you'll use, //make a backup// (preferably more than one!)+If you have a current /home with files you'll use, //make a backup// (preferably more than one)!
  
-Build/install zfs-on-linux from [[http://slackbuilds.org|SlackBuilds.org]] (SBo, such as with sbopkg, available on [[http://sbopkg.org|SBopkg.org]]. If you update Linux (kernel) //you must build zfs-on-linux again//! (before you can access ZFS.)+Build/install openzfs from [[http://slackbuilds.org|SlackBuilds.org]] (SBo, such as with sbopkg, available on [[http://sbopkg.org|SBopkg.org]]).  If you update Linux (kernel) //you must build openzfs again//! (before you can access ZFS).
  
-If you created any new /home/user initial/‘skeleton’ directory on the root filesystem partition, you can move it to /root temporarily, because it's just going to get mounted over (not seen) but still take space (inaccessible until unmounting.)  One might have a new /home if using a Unix and Slackware, so later you'll want any skeleton directory (default user files like .*shrc, .profile, etc. for that OS distro.)+If you created any new /home/user initial/‘skeleton’ directory on the root filesystem partition, you can move it to /root temporarily, because it's just going to get mounted over (not seen) but still take space (inaccessible until unmounting) One might have a new /home if using a Unix and Slackware, so later you'll want any skeleton directory (default user files like .*shrc, .profile, etc. for that OS distro.)
  
 ===== Research/read At Least A Little ===== ===== Research/read At Least A Little =====
-Before first actual ZFS commands, you may want to view  /usr/doc/zfs-on-linux-* , cat or more (or less, most) /var/log/packages/zfs-on-linux-* , ‘man zpool,’ ‘man zfs.’  A zpool holds and manages one or more zfs and has many options, which for advanced/large storage, you will want some/all (maybe depending on compatibility with other systems accessing)... that case would be for new sections or advanced storage HOWTO... here it's assumed one may not use most/any extra options because might not be a data-centre (but one feature will be mentioned) rather than wanting to share /home with a Unix, which many may not have all options (as OpenSolaris' ZFS and zfs-on-linux are slightly different--at different stages of overall ZFS design, so some versions have things older ones don't, and won't even be readable with... you should check/view those project sites (linked here sooner or later,even though zfs-on-linux people didn't bother to address the most long-time/influential GNU/Linux--Slackware--some/many command/option examples for others--even if not Unix-like--will be similar/same.)+Before first actual ZFS commands, you may want to view  /usr/doc/openzfs-* , cat or more (or less, most) /var/log/packages/openzfs-* , ‘man zpool,’ ‘man zfs.’  A zpool holds and manages one or more zfs and has many options, which for advanced/large storage, you will want some/all (maybe depending on compatibility with other systems accessing)... that case would be for new sections or advanced storage HOWTO... here it's assumed one may not use most/any extra options because might not be a data-centre (but one feature will be mentioned) rather than wanting to share /home with a Unix, which many may not have all options (as OpenSolaris/IllumOS' ZFS and OpenZFS are slightly different--at different stages of overall ZFS design, so some versions have things older ones don't, and won't even be readable with... you should check/view those project sites (linked here sooner or later), even though OpenZFS people didn't bother to address the most long-time/influential GNU/Linux--Slackware--some/many command/option examples for others--even if not Unix-like--will be similar/same).
  
 ===== Create & Start ZFS ===== ===== Create & Start ZFS =====
-Once you installed ZFS and all various /home files are backed up, start ZFS with rc script (run it or reboot)... login root (or su -) or use sudo for those commands below.  Remember, this will be with no extra options (-d option is ‘no options’ unless specified) other than use a ‘modern’ sector size (unless you have a drive so old it should probably be replaced if even still working, this size should be reasonable)... ‘-o ashift=12’ option creates 2<sup>12</sup>, i.e., 4KB sectors (you shouldn't actually use larger/8KB unless using //older// SSD designed 8KB.)  You can read zpool & zfs manpages to find/add more options.  If you do and share a /home, install ZFS on both OSes, dump zpool option list sets on each to see what's usable (only the [[http://mathworld.wolfram.com/Intersection.html|set intersection]].)+Once you installed ZFS and all various /home files are backed up, start ZFS with rc script (run it or reboot)... login root (or su -) or use sudo for those commands below.  Remember, this will be with no extra options (-d option is ‘no options’ unless specified) other than use a ‘modern’ sector size (unless you have a drive so old it should probably be replaced if even still working, this size should be reasonable)... ‘-o ashift=12’ option creates 2<sup>12</sup>, i.e., 4KB sectors (you shouldn't actually use larger/8KB unless using //older// solid state drive, SSD designed 8KB) You can read zpool & zfs manpages to find/add more options.  If you do and share a /home, install ZFS on both OSes, dump zpool option list sets on each to see what's usable (only the [[http://mathworld.wolfram.com/Intersection.html|set intersection]]).  Most likely both will have compression and snapshots, so if you want those, read examples/manpages.
  
-Below is to create a ZFS drive (replace L with drive block device letter,number you want.+Below is to create a ZFS drive (replace L with drive block device letter you want). 
-<code> +<code>zpool create -d -o ashift=12 home /dev/sdL</code>
-zpool create -d -o ashift=12 home /dev/sdL +
-</code>+
  
-If //not using an entire drive//below is to create a ZFS partition (replace L,N with drive partition block device letter,number you want.+//Alternatively//, if //not using an entire drive// (but normally a Solaris GPT partition) below is to create a ZFS partition (replace L,N with drive partition block device letter,number you want). 
-<code> +<code>zpool create -d -o ashift=12 home /dev/sdLN</code>
-zpool create -d -o ashift=12 home /dev/sdLN +
-</code>+
  
 Start/mount zpool/ZFS. Start/mount zpool/ZFS.
-<code> +<code>/etc/rc.d/rc.zfs start 
-/etc/rc.d/rc.zfs start +zpool import home</code>
-zpool import home +
-</code>+
  
-Your ZFS should now be ready.  However, you can create multiple ZFS (even levels/hierarchies, called datasets) in each zpool, such as for swap, each user, other/server purposes (SBo'zfs-on-linux maintainer could explain datasets if you ask, and documented by Oracle, OpenZFS, ZFSonLinux for various distros, usually similar/same commands.Move back any Slackware & Unix/etc. initial/skeleton user directories and/or (maybe after installing/testing ZFS on other/optional OS sharing it, first, just to make sure it'll work, before a potentially hours-long copy/restore/rysnc/etc. back) your /home from the backups.  You will probably want something such as the following.+Your ZFS should now be ready.  However, you can create multiple ZFS (even levels/hierarchies, datasets) in each zpool, such as for swap, each user, other/server purposes (SBo'openzfs maintainer could explain datasets if you ask, and documented by Oracle, OpenZFS for various distros, usually similar/same commands). Move back any Slackware & Unix/etc. initial/skeleton user directories and/or (maybe after installing/testing ZFS on other/optional OS sharing it, first, just to make sure it'll work, before a potentially hours-long copy/restore/rysnc/etc. back) your /home from the backups.  You will probably want something such as the following.
  
-<code> +<code>#!/bin/sh
-#!/bin/sh+
 #/etc/rc.d/rc.local #/etc/rc.d/rc.local
 #... (your other lines) #... (your other lines)
  
-#Activate zpool & its zfs+#Activate zpool & its zfs.
 #If only using on one OS, you shouldn't need the ‘-f.’ #If only using on one OS, you shouldn't need the ‘-f.’
 zpool import -f home zpool import -f home
 # ON LINES BELOW, YOU CAN START ALL PROCESSES ACCESSING THAT FS. # ON LINES BELOW, YOU CAN START ALL PROCESSES ACCESSING THAT FS.
  
-#... (your other lines) +#... (your other lines)</code> 
-</code>+ 
 +===== Speed Up ZFS ===== 
 + 
 +If you don't need access time (atime) logged for files, disable atime to speed up ZFS. 
 + 
 +<code>zfs set atime=off home</code> 
 + 
 +===== How to Stop ZFS ======
  
 <code> <code>
Line 62: Line 62:
 #... (your other lines) #... (your other lines)
  
-# Unmount/stop ZFS.  may not actually need this if rc.zfs is stopped automatically and does it, but be safe or find out.+# Unmount/stop ZFS.  may not actually need this if rc.zfs iss stopped automatically and does it, but be safe or find out.
 # ON LINES ABOVE, STOP ALL PROCESSES ACCESSING THIS FS. # ON LINES ABOVE, STOP ALL PROCESSES ACCESSING THIS FS.
-#can be either unmount or umount+Can be either unmount or umount.
 zfs unmount home zfs unmount home
  
Line 70: Line 70:
 </code> </code>
  
-If after Slackware, you initially managed to read & write to a ZFS on a Unix, then copied your /home back on Slackware, you may think it's not going to mount on one or the other, but as rc.local above, you will probably actually have to 'zpool -f homeon both OS.  Some Unixes do '-fautomatically if you enable to merely use ZFS software as an option in a configuration file.+If after Slackware, you initially managed to read & write to a ZFS on a Unix, then copied your /home back on Slackware, you may soon see messages and think it's not going to mount on one or the other, but as rc.local above, you will probably actually have to zpool -f home’ on both OS.  Some Unixes do -f’ automatically if you enable to merely use ZFS software as an option in a configuration file. 
 + 
 +====== Repairs/restarts ====== 
 + 
 +If you mess up making a ZFS or want to delete one, it can be hard.  If you want to delete one, you can't just delete and overwrite, but must wipefs, or just dd 4MB at beginning & end to zero and remove its zpool cache... those can take a long time, but on a SSD, you can also just use the tool like the Unix trim, that is blkdiscard. 
 ====== Sources ====== ====== Sources ======
 <!-- If you are copying information from another source, then specify that source --> <!-- If you are copying information from another source, then specify that source -->
 howtos:zfs_home ()