\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{nhatlong0605} \pdfinfo{ /Title (lfcs-module5-storagemanagement.pdf) /Creator (Cheatography) /Author (nhatlong0605) /Subject (LFCS\_Module5\_StorageManagement 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}{CE28D4} \definecolor{LightBackground}{HTML}{FBF1FC} \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{LFCS\_Module5\_StorageManagement Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{nhatlong0605} via \textcolor{DarkBackground}{\uline{cheatography.com/68292/cs/17228/}}} \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}nhatlong0605 \\ \uline{cheatography.com/nhatlong0605} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 27th September, 2018.\\ Updated 27th September, 2018.\\ 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{multicols*}{3} \begin{tabularx}{5.377cm}{x{3.28482 cm} x{1.69218 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{MBR vs GPT}} \tn % Row 0 \SetRowColor{LightBackground} BIOS & UEFI \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}2TB & \textgreater{}2TB \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} max 4 partitions & max 128 partitions \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} Beyond 4: extended, logical partition & All 128 are Primary \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} fdisk utility & gdisk utility \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.9908 cm} x{2.9862 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Creating partition}} \tn % Row 0 \SetRowColor{LightBackground} cat \seqsplit{/proc/partitiions} & List current partitions \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} fdisk /dev/sdb & Create MBR partition on /dev/sdb \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} gdisk /dev/sdb & Create GPT partition on /dev/sdc \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Create File Systems}} \tn % Row 0 \SetRowColor{LightBackground} mkfs.ext4 -b 1024 -L myfs /dev/sdb1 & Create ext4 file system w/ myfs label (-L) and 1024Mb size (-b) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} mount /dev/sdb1 /mnt; umount /mnt & Mount /dev/sdb1 on /mnt; unmount \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} mkfs.xfs -L XFSFS /dev/sdb5 & Create xfs file system \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} mount LABEL=XFSFS /mnt & Mount \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} mkfs.btrfs -L butter /dev/sdc1 & Create btrfs file system \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.19448 cm} x{3.78252 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Mount partitions w/ etc fstab}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{vim /etc/fstab} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{/dev/sdb1 /ext4 ext4 defaults 0 0} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{LABEL=XFSFS} & Mount by label \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} mount -a & Mount everything specified in fstab \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Create RAID}} \tn % Row 0 \SetRowColor{LightBackground} gdisk {\emph{disk}}; fd00; partprobe & Create RAID disks \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} mdadm -{}-create /dev/md0 -{}-level=1 -{}-raid-disks=2 /dev/sdd2 /dev/sde1 & Create RAID level 1 from 2 RAID disk \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} mffs.ext4 /dev/md0 & Create file system on RAID \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} mdadm -{}-detail -{}-scan \textgreater{}\textgreater{} /etc/mdadm.conf & Write the RAID config \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} mkdir /raid; mount /dev/md0 /raid & Mount RAID to /raid \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} vim /etc/fstab; & Mount persistently \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} cat /proc/mdstat & Check the RAID if operational \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} mdadm -{}-detail /dev/md0 & More info about the RAID \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Swap Partition}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{partprobe} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} mkswap /dev/sdb6 & Create swap file system on /dev/sdb6 \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} free -m & Show current swap \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} swapon /dev/sdb6 & Turn swap on \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} /etc/fstab & Mounting automatically \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{swapon -a} \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Configure Encrypted Partitions}} \tn % Row 0 \SetRowColor{LightBackground} fdisk /dev/sdb; n; l; w; partprobe & Create the partition \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cryptsetup luksFormat /dev/sdb7; YES; pass; & Create encrypted device \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} cryptsetup luksOpen /dev/sdb7 secret & Open the encrypted partiton to create file system \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} mffs.ext4 /dev/mapper/secret & Create file system on encrypted device \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} mount /dev/mapper/secret /mnt & Mount the device \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{vim /etc/crypttab; secret /dev/sdb8} \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{/dev/mapper/secret /secret ext4 noauto 0 0} \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.53827 cm} x{2.43873 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Create LVM}} \tn % Row 0 \SetRowColor{LightBackground} gdisk /dev/sdc; 8e00; w; y; partprobe & Create partition for LVM \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} pvcreate /dev/sdc4 & Create physical volume \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} vgcreate vgdata /dev/sdc4 & Put physical volume in volume group \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} lvcreate -L 1G -n lvdata vgdata & Create logical volume \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} lvs & Show current LV \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} vgs & Show current volume group \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} pvs & Show current physical volume \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{LVM volume naming}} \tn % Row 0 \SetRowColor{LightBackground} /dev/mapper; ls -l & List device mapper \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} /dev/vgdata; ls -l & // \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.68298 cm} x{1.29402 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Mount LVM persistently}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{/dev/mapper/vgdata-lvdata} /lvmountpoint ext4 defaults 0 0 & Mount in fstab \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} dmesg | tail & See errors \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{File System Label \& UUID}} \tn % Row 0 \SetRowColor{LightBackground} tune2fs -L lvdata /dev/vdgata/lvdata & Change volume label \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} blkid & Show UUID for all current file system \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} etc/fstab/; UUID="...." & Mount it \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{LVM Resize}} \tn % Row 0 \SetRowColor{LightBackground} df -h & Show file system info \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} gdisk /dev/sdc; partprobe /dev/sdc & Create another partition \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} vgextend *volumne group name /dev/sdc5 & Extend the volume group \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} lvextend -l +100\%FREE -r /dev/vgdata/lvdata & Resize LVM to take 100\% free storage \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Recover after disk failure}} \tn % Row 0 \SetRowColor{LightBackground} mdadm -{}-create /dev/md0 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde & Create RAID md0 level 5 w/ 1 hot spare (-x) \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} mdadm -{}-fail /dev/md0 /dev/sdb & Fail a device \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} mdadm -{}-remove /dev/md0 /dev/sdb & Remove the device from RAID array \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} mdadm -{}- /dev/md0 /dev/sde & Add new device to RAID array \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}