\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{Leszek T (leszekt)} \pdfinfo{ /Title (linux-logical-volume-manager-lvm.pdf) /Creator (Cheatography) /Author (Leszek T (leszekt)) /Subject (Linux - Logical Volume Manager (LVM) 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}{34495E} \definecolor{LightBackground}{HTML}{F2F3F4} \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{Linux - Logical Volume Manager (LVM) Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Leszek T (leszekt)} via \textcolor{DarkBackground}{\uline{cheatography.com/170902/cs/35825/}}} \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}Leszek T (leszekt) \\ \uline{cheatography.com/leszekt} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 1st December, 2022.\\ Updated 1st December, 2022.\\ 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*}{4} \begin{tabularx}{3.833cm}{x{1.30454 cm} x{2.12846 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - terminology}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{PE - physical extents}} & The smallest unit of disk space that can be managed by LVM. It's set when you create a volume group. It determines the "granularity" of of disk space allocation.All physical volumes in a volume group will use the same extent size. \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} {\bf{LE - logical extents}} & The same as PE but for Logical Volumes \tn % Row Count 12 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{PV - physical volume}} & Disks, partitions, RAID volumes \tn % Row Count 14 (+ 2) % Row 3 \SetRowColor{white} {\bf{VG - volume group}} & Group of one or more physical volumes \tn % Row Count 16 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{LV - logical volume}} & Entity that contains information, store on physical volumes, grouped within a volume group \tn % Row Count 20 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{0.92691 cm} x{2.50609 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - commands and components}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{lvm}} & pseudo shell for LVM \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{lvmconfig}} & prints LVM configuration from /etc/lvm/lvm.conf \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{lvmdiskscan}} & prints devices that could be used as physical volumes \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} {\bf{lvmdump}} & dumps LVM configuration to tar file \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{lvmetad}} & caching service for LVM metadata \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.44186 cm} x{1.99114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - important files}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{/etc/lvm/}} & LVM configuration directory \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{/etc/lvm/lvm.conf}} & LVM configuration file \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{/etc/lvm/\{archive|backup\}}} & Backup and archive of LVM configuration \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{/etc/lvm/profile}} & Aa set of selected customizable configuration settings that can be used to achieve certain characteristics in various environments or uses. Normally, the name of the profile should reflect that environment or use. An LVM profile overrides existing configuration. \tn % Row Count 18 (+ 12) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.0299 cm} x{2.4031 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - Physical Volume}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{pvcreate}} & create PV \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{pvchange}} & change attributes of PV \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{pvs|pvdisplay}} & display information about PV \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} {\bf{pvmove}} & moves extents from one PV to another \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{pvremove}} & removes a PV \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} {\bf{pvresize}} & resizes a PV \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{pvscan}} & scans for changes in PV configuration and size \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.0299 cm} x{2.4031 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - Volume Group}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{vgs|vgdisplay}} & displays VG information \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{vgmknodes}} & create the special files for VG devices in /dev \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{vgck}} & check VG consistency \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} {\bf{vgcfgbackup}} & make a backup of VG metadata \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{vgcfgrestore}} & restore VG metadata from backup \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} {\bf{vgrename}} & rename a VG \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{vgsplit}} & move PVs to a new or existing VG \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} {\bf{vgconvert}} & change VG metadata format \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{vgimport}} & register exported VG in the system \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} {\bf{vgexport}} & unregister VG from the system \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{vgimportclone}} & import a VG from cloned PVs \tn % Row Count 20 (+ 2) % Row 11 \SetRowColor{white} {\bf{vgcreate}} & create VG from one or more PVs \tn % Row Count 22 (+ 2) % Row 12 \SetRowColor{LightBackground} {\bf{vgremove}} & remove VG \tn % Row Count 23 (+ 1) % Row 13 \SetRowColor{white} {\bf{vgreduce}} & remove PVs from VG \tn % Row Count 24 (+ 1) % Row 14 \SetRowColor{LightBackground} {\bf{vgchange}} & change VG attributes \tn % Row Count 25 (+ 1) % Row 15 \SetRowColor{white} {\bf{vgextend}} & extend VG with one or more PVs \tn % Row Count 27 (+ 2) % Row 16 \SetRowColor{LightBackground} {\bf{vgmerge}} & merge VGs \tn % Row Count 28 (+ 1) % Row 17 \SetRowColor{white} {\bf{vgscan}} & scan VGs for changes in metadata and size \tn % Row Count 30 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.06423 cm} x{2.36877 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - Logical Volume}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{lvs|lvdisplay}} & print LV metadata \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{lvchange}} & change attributes of LV \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{lvcreate}} & create a new LV \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} {\bf{lvextend}} & extend size of LV \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{lvreduce}} & reduce size of LV (offline!) \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} {\bf{lvresize}} & change size of LV \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{lvrename}} & rename a LV \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} {\bf{lvconvert}} & change layout of LVM \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{lvscan}} & scan LVs for metadata changes and size \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} {\bf{lvremove}} & remove LV \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{LVM - schema}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{3.833cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/leszekt_1669906975_01-linux-lvm-logical-volume-manager.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{Example of an LVM layout.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.81949 cm} x{1.61351 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - create PV}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{pvcreate /dev/\textless{}disk\_device\textgreater{}}} & create a new PV from device \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{pvcreate /dev/sdb}}} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{To create a PV you need a usable storage device. \newline Try {\bf{lvmdiskscan}} command.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.3732 cm} x{2.0598 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - create VG}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{vgcreate \textless{}VG\textgreater{} \textless{}PV\textgreater{} \textless{}PV\textgreater{}}} & create a volume groups that consists of one or more PVs \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{vgcreate data\_vg /dev/sdb /dev/sdc}}} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{To create a VG you need one or more PVs.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - create LV}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{lvcreate -n \textless{}LV\_NAME\textgreater{} -L \textless{}SIZE\textgreater{} \textless{}VG\textgreater{}}} & create a LV of a given size in a VG \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvcreate -n data\_lv -L 100G data\_vg}}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{lvcreate -n \textless{}LV\_NAME\textgreater{} -l 100\%FREE \textless{}VG\textgreater{}}} & create a LV that fills 100\% of free space in VG \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvcreate -n data\_lv -l 100\%FREE data\_vg}}} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{To create an LV you need a volume group.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - Snapshots}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{lvcreate -L \textless{}SIZE\textgreater{} -s -n \textless{}NAME\_OF\_SNAPSHOT\textgreater{} \textless{}PATH\_TO\_LV\textgreater{}}} & Create a snapshot of an LV \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvcreate -L 4G -s -n data\_lv-snapshot /dev/mapper/data--vg\_data-{}-lv}}} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{lvremove \textless{}PATH\_TO\_SNAPSHOT\textgreater{}}} & Remove snapshot \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvremove /dev/mapper/data--vg\_data-{}-lv}}} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{lvextend -L \textless{}SIZE\textgreater{} \textless{}PATH\_TO\_LV\textgreater{}}} & Extend snapshot \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvextend -L +10G /dev/mapper/data--vg\_data-{}-lv}}} \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{lvconvert -{}-merge \textless{}PATH\_TO\_SNAPSHOT\textgreater{}}} & Restore data from snapshot \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvconvert -{}-merge /dev/mapper/data--vg\_data-{}-lv}}} \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} modify {\bf{snapshot\_autoextend\_treshold}} and {\bf{snapshot\_autoextend\_percent}} in lvm.conf & Enable automatic extension of snapshots by adjusting the values \tn % Row Count 23 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Snapshots contain differences from the point a given LV has been created - not the real data. \newline If the size of a snapshot is exceeded it becomes useless and there is no way to restore data from it. \newline Old state of an LV can be restored from a snapshot, but please remember to unmount the filesystem first.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Useful storage commands (Bonus)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{lsblk -o name,mountpoint,label,size,uuid}} & List block devices with useful information \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{multipathd show maps status}} & Print path status of multipath devices \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{lvs -o +devices}} & Print LVs, VGs and device paths \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} {\bf{vgs -o +lv\_size,lv\_name}} & Print information about LVs, VGs, sizes and attributes \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} {\bf{mkfs.ext4 \textless{}FS\textgreater{}}} & Format a filesystem for EXT4 \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} {\bf{mkfs.xfs \textless{}FS\textgreater{}}} & Format a filesystem for XFS \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{mount \textless{}PATH\_TO\_LV\textgreater{} \textless{}MOUNTPOINT\textgreater{}}} & Mount a filesystem in a given location \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} {\bf{mount -a}} & Mount all filesystems listed in /etc/fstab \tn % Row Count 19 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Useful in many situations when you need to manipulate storage devices and layout.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - extend PV}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{rescan-scsi-bus.sh|echo 1 \textgreater{} /sys/block/\textless{}DEVICE\textgreater{}/device/rescan}} & Rescan underlying storage to detect change in disk size \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{rescan-scsi-bus.sh|echo 1 \textgreater{} /sys/block/sdb/device/rescan}}} \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{partprobe}} & Detect changes in partition size (if necessary) \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} {\bf{pvresize \textless{}PV\textgreater{}}} & Resize PV to the maximum possible size of partition or disk/LUN \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{{\emph{pvresize /dev/sdb}}} \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{To resize a PV you'll need to know the underlying storage and know how to rescan its size. \newline All steps can be performed online.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.40753 cm} x{2.02547 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - Extend VG}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{vgextend \textless{}VG\textgreater{} \textless{}PV\textgreater{} \textless{}PV\textgreater{}}} & Extend existing VG with one or more PVs \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{vgextend data\_vg /dev/sdb /dev/sdc}}} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{To extend a VG you need a VG and one or more PVs that are not assigned to any PVs yet.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{LVM - extend LV}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{lvextend -L \textless{}SIZE\textgreater{} /dev/mapper\textless{}PATH\_TO\_LV\textgreater{}}} & extend logical volume by given size (add 10GB to existing size) \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvextend -L +10G /dev/mapper/data-{}-vg\_data-{}-lv}}} \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{lvextend -r -L \textless{}SIZE\textgreater{} /dev/mapper\textless{}PATH\_TO\_LV\textgreater{}}} & extend logical volume and its filesystem by given size (add 10GB to existing size) \tn % Row Count 10 (+ 5) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvextend -r -L +10G /dev/mapper/data-{}-vg\_data-{}-lv}}} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{To extend an LV you need its path. Use {\bf{df}} command. \newline In most cases you'll also want to extend the underlying filesystem, so use {\bf{-r}} option to do it.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.85382 cm} x{1.57918 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Extend filesystem (bonus)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{umount \textless{}FS\textgreater{}}} & Unmount filesystem \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{umount /data}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{e2fsck -f \textless{}PATH\_TO\_LV\textgreater{}}} & Check and fix potential errors \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{e2fsck -f /dev/mapper/data-{}-vg\_data-{}-lv}}} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{resize2fs \textless{}PATH\_TO\_LV\textgreater{} \textless{}SIZE\textgreater{}}} & Reduce size of filesystem \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{resize2fs /dev/mapper/data-{}-vg\_data-{}-lv 10G}}} \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{lvreduce -L \textless{}SIZE\textgreater{} \textless{}PATH\_TO\_LV\textgreater{}}} & Reduce size of LV \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{lvreduce -L 10G /dev/mapper/data-{}-vg\_data-{}-lv}}} \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{e2fsck -f \textless{}PATH\_TO\_LV\textgreater{}}} & Check for errors once more \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{e2fsck -f /dev/mapper/data-{}-vg\_data-{}-lv}}} \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{mount \textless{}FS\textgreater{}}} & Mount filesystem \tn % Row Count 19 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\emph{mount /data}}} \tn % Row Count 20 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Remember to make sure the size of both: FS (filesystem) and LV (logical volume) are the same and there are no errors. Reducing the size can ONLY be done OFFLINE. The filesystem must be unmounted. Not all filesystems can be reduced at all.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}