\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{tim (The IceMan Blog)} \pdfinfo{ /Title (zfs-command-line-reference.pdf) /Creator (Cheatography) /Author (tim (The IceMan Blog)) /Subject (ZFS command line reference Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{651394} \definecolor{LightBackground}{HTML}{F5F0F8} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{ZFS command line reference Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{tim (The IceMan Blog)} via \textcolor{DarkBackground}{\uline{cheatography.com/1411/cs/20047/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}tim (The IceMan Blog) \\ \uline{cheatography.com/the-iceman-blog} \\ \uline{\seqsplit{blog}.rabin.io/} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 16th July, 2019.\\ Updated 5th August, 2019.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Pool Related Commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zpool create datapool c0t0d0` & Create a basic pool named datapool \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zpool create -f datapool c0t0d0` & Force the creation of a pool \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `\# zpool create -m /data datapool c0t0d0` & Create a pool with a different mount point than the default. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `\# zpool create datapool raidz c3t0d0 c3t1d0 c3t2d0` & Create RAID-Z vdev pool \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} `\# zpool add datapool raidz c4t0d0 c4t1d0 c4t2d0` & Add RAID-Z vdev to pool datapool \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} `\# zpool create datapool raidz1 c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0` & Create RAID-Z1 pool \tn % Row Count 17 (+ 4) % Row 6 \SetRowColor{LightBackground} `\# zpool create datapool raidz2 c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0` & Create RAID-Z2 pool \tn % Row Count 21 (+ 4) % Row 7 \SetRowColor{white} `\# zpool create datapool mirror c0t0d0 c0t5d0` & Mirror c0t0d0 to c0t5d0 \tn % Row Count 24 (+ 3) % Row 8 \SetRowColor{LightBackground} `\# zpool create datapool mirror c0t0d0 c0t5d0 mirror c0t2d0 c0t4d0` & disk c0t0d0 is mirrored with c0t5d0 and disk c0t2d0 is mirrored withc0t4d0 \tn % Row Count 28 (+ 4) % Row 9 \SetRowColor{white} `\# zpool add datapool mirror c3t0d0 c3t1d0` & Add new mirrored vdev to datapool \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Pool Related Commands (cont)}} \tn % Row 10 \SetRowColor{LightBackground} `\# zpool add datapool spare c1t3d0` & Add spare device c1t3d0 to the datapool \tn % Row Count 2 (+ 2) % Row 11 \SetRowColor{white} `\# zpool create -n geekpool c1t3d0` & Do a dry run on pool creation \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{6.5626 cm} x{10.7074 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Show file system info}} \tn % Row 0 \SetRowColor{LightBackground} `\# zfs list` & List all ZFS file system \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `\# zfs get all datapool` & List all properties of a ZFS file system \tn % Row Count 3 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Mount/Umount Related Commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zfs set mountpoint=/data datapool/fs1` & Set the mount-point of file system fs1 to /data \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `\# zfs mount datapool/fs1` & Mount fs1 file system \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} `\# zfs umount datapool/fs1` & Umount ZFS file system fs1 \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} `\# zfs mount -a` & Mount all ZFS file systems \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} `\# zfs umount -a` & Umount all ZFS file systems \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.7715 cm} x{9.4985 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Import/Export Commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zpool import` & List pools available for import \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zpool import -a ` & Imports all pools found in the search directories \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `\# zpool import -d` & To search for pools with block devices not located in /dev/dsk \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} `\# zpool import -d /zfs datapool` & Search for a pool with block devices created in /zfs \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} `\# zpool import oldpool newpool` & Import a pool originally named oldpool under new name newpool \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} `\# zpool import 3987837483` & Import pool using pool ID \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} `\# zpool export datapool` & Deport a ZFS pool named datapool \tn % Row Count 18 (+ 2) % Row 7 \SetRowColor{white} `\# zpool export -f datapool` & Force the unmount and deport of a ZFS pool \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{10.5347 cm} x{6.7353 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Clone Commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zfs clone datapool/fs1@10jan2014 /clones/fs1` & Clone an existing snapshot \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zfs destroy datapool/fs1@10jan2014` & Destroy clone \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.0807 cm} x{10.1893 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Show Pool Information}} \tn % Row 0 \SetRowColor{LightBackground} `\# zpool status -x` & Show pool status \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zpool status -v datapool` & Show individual pool status in verbose mode \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `\# zpool list` & Show all the pools \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} `\# zpool list -o name,size` & Show particular properties of all the pools (here, name and size) \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} `\# zpool list -Ho name` & Show all pools without headers and columns \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.1169 cm} x{9.1531 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{File-system/Volume related commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zfs create datapool/fs1` & Create file-system fs1 under datapool \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zfs create -V 1gb datapool/vol01` & Create 1 GB volume (Block device) in datapool \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `\# zfs destroy -r datapool` & destroy datapool and all datasets under it \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} `\# zfs destroy -fr datapool/data` & destroy file-system or volume (data) and all related snapshots \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Set ZFS file system properties}} \tn % Row 0 \SetRowColor{LightBackground} `\# zfs set quota=1G datapool/fs1` & Set quota of 1 GB on filesystem fs1 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zfs set reservation=1G datapool/fs1` & Set Reservation of 1 GB on filesystem fs1 \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `\# zfs set mountpoint=legacy datapool/fs1` & Disable ZFS auto mounting and enable mounting through /etc/vfstab. \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} `\# zfs set sharenfs=on datapool/fs1` & Share fs1 as NFS \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} `\# zfs set compression=on datapool/fs1` & Enable compression on fs1 \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} `zfs set recordsize={[}size{]} pool/dataset/name` & Set Dataset Record Size (Size should be a value like 16k, 128k, or 1M etc.) \tn % Row Count 17 (+ 4) % Row 6 \SetRowColor{LightBackground} `zfs get recordsize pool/dataset/name` & Get Dataset Record Size \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.8718 cm} x{11.3982 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{ZFS I/O performance}} \tn % Row 0 \SetRowColor{LightBackground} `\# zpool iostat 2` & Display ZFS I/O Statistics every 2 seconds \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\# zpool iostat -v 2` & Display detailed ZFS I/O statistics every 2 seconds \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.1169 cm} x{9.1531 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{ZFS maintenance commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zpool scrub datapool` & Run scrub on all file systems under data pool \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `\# zpool offline -t datapool c0t0d0` & Temporarily offline a disk (until next reboot) \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} `\# zpool online` & Online a disk to clear error count \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} \# zpool clear & Clear error count without a need to the disk \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Snapshot Commands}} \tn % Row 0 \SetRowColor{LightBackground} `\# zfs snapshot \seqsplit{datapool/fs1@12jan2014`} & Create a snapshot named 12jan2014 of the fs1 filesystem \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `\# zfs list -t snapshot` & List snapshots \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} `\# zfs rollback -r \seqsplit{datapool/fs1@10jan2014`} & Roll back to 10jan2014 (recursively destroy intermediate snapshots) \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} `\# zfs rollback -rf \seqsplit{datapool/fs1@10jan2014`} & Roll back must and force unmount and remount \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} `\# zfs destroy \seqsplit{datapool/fs1@10jan2014`} & Destroy snapshot created earlier \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} `\# zfs send \seqsplit{datapool/fs1@oct2013} \textgreater{} \seqsplit{/geekpool/fs1/oct2013}.bak` & Take a backup of ZFS snapshot locally \tn % Row Count 18 (+ 4) % Row 6 \SetRowColor{LightBackground} `\# zfs receive anotherpool/fs1 \textless{} \seqsplit{/geekpool/fs1/oct2013}.bak` & Restore from the snapshot backup backup taken \tn % Row Count 21 (+ 3) % Row 7 \SetRowColor{white} `\# zfs send \seqsplit{datapool/fs1@oct2013} | zfs receive anotherpool/fs1` & Combine the send and receive operation \tn % Row Count 25 (+ 4) % Row 8 \SetRowColor{LightBackground} `\# zfs send \seqsplit{datapool/fs1@oct2013} | ssh node02 "zfs receive testpool/testfs"` & Send the snapshot to a remote system node02 \tn % Row Count 29 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}