User Tools

Site Tools


quickreference:zfs

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
quickreference:zfs [2022/12/17 13:54] – [iSCSI considerations] rodolicoquickreference:zfs [2025/01/06 23:05] (current) – [Create a zpool] rodolico
Line 22: Line 22:
 zpool create -f storage raidz2 /dev/da[01234567] zpool create -f storage raidz2 /dev/da[01234567]
 </code> </code>
 +
 +You can add extra functionality by creating //intent//, //dedup// and //cache// vdev's at the same time. Following example shows adding a vdev (mirror) to a pool.
 +<code bash>
 +zpool create -f -m /storage storage raidz2 da4 da5 da6 da7 da8 da9 dedup mirror da2 da3
 +</code>
 +
 +This will create a pool named storage, mounted (-m) at /storage, forced to ignore most drive errors. The pool will be a raidz2 (aka RAID 6) with 6 drives (4-9), and have a dedup vdev consisting of a mirror from da2 and 3.
  
 ===== Create a Dataset ===== ===== Create a Dataset =====
Line 56: Line 63:
 # turn swap back on (could also use swapon /dev/zvol/storage/swap, but I'm lazy) # turn swap back on (could also use swapon /dev/zvol/storage/swap, but I'm lazy)
 swapon -aL swapon -aL
 +</code>
 +
 +===== Using a file for swap space =====
 +
 +Instead of using a swap partition or zvol, we can simply use a file. In this case, we can add swap space by deleting/recreating the swap file (after turning swap off), but a simpler way if you need more swap space is to simply add a second swap file.
 +
 +Following code creates an 8G swap file. Note that after reading https://www.cyberciti.biz/faq/create-a-freebsd-swap-file/, I modified my old way of doing this.
 +
 +<code bash>
 +# create an 8G swap file
 +dd if=/dev/zero of=/swap bs=1G count=8
 +# set permissions
 +chmod 0600 /swap
 +# look for an unused md device (ie, not listed)
 +mdconfig -lv 
 +cp /etc/fstab /etc/fstab.save
 +# edit /etc/fstab and add the following line, using the correct md##
 +joe /etc/fstab
 +md42 none swap sw,file=/swap 0 0
 +# save your file
 +# turn on swap
 +swapon -aq
 +# look at swap information
 +swapinfo -k
 </code> </code>
  
 ===== iSCSI considerations ===== ===== iSCSI considerations =====
 +
 +On FreeBSD, the iSCSI config is /etc/ctl.conf, and the service is ctld <code bash>service ctld reload # reread iscsi exports on FreeBSD</code>
  
 iSCSI generally uses volumes which are then exported by the target. I have found that it is useful, from a management perspective, to place them under a dataset strictly for them, since I back up iSCSI volumes on a different timeline than I do other stuff. iSCSI generally uses volumes which are then exported by the target. I have found that it is useful, from a management perspective, to place them under a dataset strictly for them, since I back up iSCSI volumes on a different timeline than I do other stuff.
Line 68: Line 101:
 <code bash> <code bash>
 zfs create storage/iscsi zfs create storage/iscsi
-zfs -V 10G storage/iscsi/server1.disk0 +zfs create -V 10G storage/iscsi/server1.disk0 
-zfs -V 10G storage/iscsi/server1.disk1+zfs create -V 10G storage/iscsi/server1.disk1
 </code> </code>
  
Line 86: Line 119:
   - On iSCSI target   - On iSCSI target
     - Rename the volume <code bash> zfs rename storage/volumename storage/iscsi/volumename</code>     - Rename the volume <code bash> zfs rename storage/volumename storage/iscsi/volumename</code>
-    - Edit the config to point to new location +    - Edit the config to point to new location (**/etc/ctl.conf** on FreeBSD) 
-    - reload iscsi service+    - reload iscsi service <code bash>service ctld reload # on FreeBSD</code>
   - On initiator   - On initiator
     - rescan target     - rescan target
     - allow access to volume     - allow access to volume
  
-I have **NOT** done this yet. This is based on some research I have done, and a little testing, so use at your own risk.+
  
 ===== Getting and setting properties ===== ===== Getting and setting properties =====
Line 156: Line 189:
    * https://wordpress.morningside.edu/meyersh/2009/11/30/zfs-deduplication/    * https://wordpress.morningside.edu/meyersh/2009/11/30/zfs-deduplication/
    * https://linuxhint.com/zfs-deduplication/    * https://linuxhint.com/zfs-deduplication/
 +   * https://www.cyberciti.biz/faq/create-a-freebsd-swap-file/
  
  
quickreference/zfs.1671306876.txt.gz · Last modified: 2022/12/17 13:54 by rodolico