\documentclass[11pt]{article}
%Gummi|065|=)
\title{\textbf{Expanding HDDs}}
\author{Steak Electronics}
\date{05/30/19}
\begin{document}

\textbf{Expanding HDDs}

%\maketitle

\section{Overview}
I occasionally expand hdds. When this is done, sometimes I have to move partitions around, for example, changing a 1,2,5 (2 and 5 being extended partitions) to a 1,2, which I did for my main documentation machine. When this occured, there were a few gotcha's which I will try to note here.

\section{Notes}
Here's a rough outline of what happened.

I had a 1,2,5 (the 2nd partition being an empty transition partition from primary to extended type) partition table. 1 was root, 5 was swap.

It was a 40GB HDD. I decided to expand it to an 80GB HDD.

First, I used clonezilla, and did a standard disk to disk. Everything went without a hitch.

Then I needed to resize the partitions
\subsection{resize partitions}
I've always done this with fsck. Apparently parted once\footnote{They removed this, and replaced it with something different. removing backwards compatibility is a sin in software. They have sinned.} had a command named resize and some guides online still talk of it, as if it will work. It doesn't. It was removed. Don't waste time with parted.

Fsck, essentially, you delete all the partitions, then add them as you want, IF you have a root partition that is 1, with everything. \footnote{If you split up the partitions, you will need to image the partitions and copy them differently.} I always use a single root partition. Simple. No need to complicate a desktop os. So for 1,2,5, I delete all partitions, then add 1, with an additional 40G in fsck.

+80G in this case is what I did.\footnote{Perhaps I should've done +70G to stay under the 80G of an actual 80GB hdd.}

Then add the swap after.

mkswap the swap. resize2fs the root partition (it may ask you to e2fsck -f first, so do that if necessary). That's easy.

However, here's the trap. You aren't done. You need to edit not only fstab, but also a few other places.


\subsection{Things to edit:}

\begin{itemize}
\item fstab
\item /etc/initramfs/conf.d/resume (may be optional if you don't suspend)
\item update-grub
\item update-initramfs -u -all
\item grub-install /dev/sda
\item grub-install /dev/sda1
\end{itemize}

You add the new blkid of the new swap (if it's new) to the conf.d resume. My grub-install /dev/sda1 errored out, but I think it was the /dev/sda one I needed to redo. Do both just in case. Also make sure to do an update-initramfs -u -all. And you probably already remembered about update-grub but that should probably be done as well.

It's easy to miss one of these, and if you do, you will be loaded into grub. If you load manually in grub with:

\emph{linux = /boot/vmlinuz...}

\emph{initrd = /boot/initrd...}

\emph{boot}

Then in my case, you will end up in an initramfs that can't find the fstab. So then chroot into the hdd, and run the steps above.
\end{document}
