\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[a4paper, margin=0.75in]{geometry}

% set up hyperlink coloring
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan
}

\setlength{\parindent}{0pt} % no indentation

% checkbox list: https://tex.stackexchange.com/questions/247681/how-to-create-checkbox-todo-list
\usepackage{enumitem,amssymb}
\newlist{boxlist}{itemize}{2}
\setlist[boxlist]{label=$\square$}

% code support: listings and fancy verbatim
\usepackage{listings}
\lstset{basicstyle=\ttfamily\footnotesize}
\usepackage{fancyvrb}

\renewcommand{\familydefault}{\sfdefault} % default to sans serif

\usepackage{xcolor}
\newcommand{\code}[1]{\colorbox{lightgray}{\texttt{#1}}}
\newcommand{\sh}[1]{\code{\$ #1}}

%%%%%%%%%%%%%%%
\begin{document}

\title{Advanced Exercises Set 1\\Setting Up a Highly Customizable Linux Distro}
\author{EECS 201 Fall 2020}
\date{}
\maketitle

\section*{Submission Instructions}
This assignment is an ``online assignment'' on \href{https://gradescope.com}{Gradescope},
where you fill out your answers directly.
These questions are reflected in the ``Questions'' section of each section.


\section*{Preface}
This advanced assignment is not for the faint of heart. This may require additional reading
on the Arch wiki and other research. I will record a supplemental lecture explaining the more general concepts.

\section{Set Up an Arch Linux Virtual Machine (7 pts)}
Arch Linux is a GNU/Linux distribution with a rolling-release model,
where its package repository keeps up with the latest stable updates.
Unlike many distributions which try to be user-friendly,
Arch strives to be simple and minimalist upon installation,
allowing the user to pick and choose exactly what packages they want.
For example, after a typical Ubuntu installation you will have a graphical environment,
office software, and other utilities,
whereas after a baseline Arch installation you will be greeted with a non-graphical command line and a
handful of core \*nix utilities, notwithstanding the highly involved installation process.
With this minimal install process, however, comes a great deal of customizability.
You can read more about the Arch Linux philosophy on its \href{https://wiki.archlinux.org/index.php/Arch_Linux}{ArchWiki}.
\\\\
For this advanced assignment, I want you to install Arch Linux on another VirtualBox VM.
The idea behind this is to introduce you to all the bits and pieces that go into Linux systems
that most people take for granted when using more user-friendly distributions.
\\\\
Follow the \href{https://wiki.archlinux.org/index.php/Installation_guide}{Installation Guide}.
\textbf{Do not follow online tutorials for this as they tend to be outdated. The ArchWiki's installation guide is the canonical way to install Arch.}
When you go through the installation process, be mindful of times the guide offers suggestions:
you will have to answer questions about certain decisions you made.
When in doubt, follow the links in the installation guide and \textbf{read}.
\\\\
\emph{For Windows hosts, in my testing, it seems that Hyper-V does indeed run into issues here and there with Arch, namely with
      PGP signature checking for packages, resulting in package installations failing. If you do run into issues, try turning
      off Hyper-V as was described in Basic 1.}

\begin{enumerate}
    \item Create a new VirtualBox VM (you could use another hypervisor or even dual boot if you wish).
          Arch Linux has lower baseline system requirements than Ubuntu,
          but you can still go with the guidelines from Basic 1.
    \item By default VirtualBox VMs use a typical BIOS (i.e. they aren't UEFI).
          When you encounter instructions that differ based on BIOS vs UEFI,
          go with the BIOS instructions (if you do choose to go UEFI, follow the UEFI instructions).\\
          {\footnotesize{}I personally use UEFI on VMs as UEFI has superseded BIOS on recent computers}
    \item As with most operating systems, you'll need to get the ISO and then insert it into your VM's
          CD drive to boot and run the installer. Only this time, the installer is completely command line :)
    \item You don't have to really bother with checking the signature of the ISO or setting the keyboard layout
    \item With VirtualBox, the internet should work out of the box; configuring the network connection
          \emph{for the installer} should not be necessary.
    \item Partitioning a disk involves dividing a disk into independent sections.
          A disk is exposed as a device such as \code{/dev/sda},
          with its partitions being exposed as \code{/dev/sda1}, \code{/dev/sda2}, etc.
          There are two partition table layouts which hold the partitioning information on a disk.
          MBR is the older table used by MS-DOS with several quirks (such as having a max of 4 partitions)
          while GPT is a newer table. For more details see \url{https://wiki.archlinux.org/index.php/Partitioning}.
          Note that "MBR" is also referred to as "DOS" when it comes to partition tables.
          For this assignment, MBR is probably the easier to work with BIOS while GPT is easier to work with UEFI.
    \item As for partitioning scheme, you can set aside partitons to be for directories such as \code{/var}.
          \emph{However a ``single root partition'' can suffice.}
          See \url{https://wiki.archlinux.org/index.php/Partitioning#Partition\_scheme} for advice.
          %I would advise against having a \code{swap} partitions as you can use a \code{swapfile} instead.
    \item After partitioning the disk, you'll have to \textit{format} the partitions.
          Partitioning splits a disk into independent sections, but we still need a system to perform book-keeping
          for files. This is where a \textit{file system} comes into play. Formatting a disk sets up all the structures
          and metadata needed to track files and directories. Windows uses NTFS, mac OS uses APFS, while Linux has many options,
          with ext4 often being the "default".
          If you're interested, you can look at \url{https://wiki.archlinux.org/index.php/File\_systems}
          for other file systems to use.
    \item Mounting a partition puts it into the directory tree, allowing it to be accessed via \code{cd} and the like.
    %\item When selecting mirrors by editing a file, \code{nano} and \code{vim} are available editors.
    \item After all this disk business, you are ready to perform the installation proper.
          I suggest adding \code{base-devel} (for tools like \code{gcc}, \code{make}, and \code{sudo})
          and your preferred text editor (\code{nano}, \code{vim}, etc.), and \code{dhcpcd} for networking
          to the \code{pacstrap} invocation. You can also add whatever other packages you want to be installed from the get-go.
    \item Once you're chroot-ed into the system, you are effectively ``logged-in'' as the root user on your installation, having used
          the installer as a launching point. Note that the package manager is called \code{pacman} (how quaint) in case you need
          to install any packages that you've forgotten.
    \item The next several steps are fairly straightforward. When it comes to the timezone, our region is "America",
          and our closest city is "Detroit".
          \textbf{Make sure to configure your network connectivity, lest you be unable to connect to the internet after you reboot.
          \code{dhcpcd} (which will have to be installed via \code{pacman} if not included with \code{pacstrap})
          is a decent choice on VirtualBox. You can enable \code{dhcpcd} with \sh{systemctl enable dhcpcd}}.
    \item The boot loader step offers a bunch of choices depending on whether you're using BIOS or UEFI.
          If you are using BIOS, I recommend GRUB.
          Do note that GRUB has different instructions depending on whether you're using BIOS or UEFI and MBR or GPT.
          If you are using UEFI, \code{systemd-boot} can suffice.\\
          {\footnotesize{}I've taken to rEFInd on my dual-boot setups.}
    \item Once you've reached post-installation, you should create a user for yourself,
          as logging in only as root is rather insecure.
          If you don't have any users created, you can log in as "root", using the root password set during installation,
          to perform this step. \textbf{The user you create should have sudo privileges.}
          For info on user administration see \url{https://wiki.archlinux.org/index.php/Users\_and\_groups#User\_management}.
    \item A note on \code{visudo}: by default it will try to use \code{vi}, which may or may not be installed.
          You can change it by setting the \code{\$EDITOR} environment variable to \code{nano} or your preferred editor:
          \sh{EDITOR=nano visudo}.
    \item When you're done doing your setup and user management, exit the chroot, and shut down your VM.
          Remove the installation ISO.
    \item Start your VM. If you have successfully performed the installation as well as set up the bootloader, you should
          see Arch booting up and then presenting you with a login prompt.
          \begin{enumerate}
            \item If things don't seem to be right, you can always get back into that nice chroot environment from earlier.
                  This is the beauty of those installer ISOs: besides installation duties,
                  they provide a live environment for you to perform repairs with. All you have to do is the mounting steps
                  and then chroot, then you can try to fix things up.\\
                  {\footnotesize{}(I have had to do this a few times on real machines).}
          \end{enumerate}
    \item Hooray! You now have a bare-bones, highly customizable Linux distro! Hope you enjoy staring at that blinking cursor!
\end{enumerate}

\subsection*{Questions:}
\begin{boxlist}
    \item What sort of partitioning scheme did you use and why?
    \item What filesystem did you use and why?
    \item Log into your user. What is the output of \sh{whoami}?
    \item What is the output of \sh{uname -r}?
    \item How did you like the installation process compared to Ubuntu's?
\end{boxlist}


\section{Let There Be Light (3 pts)}
Being stuck in a purely command line environment is a bit of a drag.
Let's make the installation more home-y by getting a graphical user interface (GUI) going.

\begin{enumerate}
    \item You can find some info about this in \href{https://wiki.archlinux.org/index.php/General\_recommendations\#Graphical\_user\_interface}{General Recommendations}.
    \item The backbone of graphics on *nix systems is a display server.
          X11 is probably the most popular one, though Wayland is also an option.
          In either case, you'll have to install a display server before anything else,
          though often-times the GUI you install already has this as a dependency that
          \code{pacman} will resolve.
    \item Install your preferred GUI, be it a full on desktop environment or minimalist window manager.
          GNOME and KDE Plasma are popular fully featured options, but are relatively heavyweight.
          If you prefer something a bit lighter, LXQt might be of interest.
          \\{\footnotesize{}I showcased KDE Plasma in Lecture 1.}
          \\{\footnotesize{}By the way, I used to use KDE Plasma but have since moved onto i3 window manager.}
    \item There's various different ways to access the GUI.
          Choose and set up an option that suits your fancy (e.g. display manager, xinit, etc.).
    \item Install a terminal emulator, which is a graphical program that presents a terminal.
          One might have been already installed if you went for a fully featured desktop environment.
          Here is a list of terminal emulators: \url{https://wiki.archlinux.org/index.php/List\_of\_applications/Utilities#Terminal\_emulators}
          \\{\footnotesize{}My daily driver is \code{urxvt}.}
    \item You can also install the \href{https://wiki.archlinux.org/index.php/VirtualBox/Install\_Arch\_Linux\_as\_a\_guest#Install\_the\_Guest\_Additions}{VirtualBox Guest Additions} if you want.
          (You may want to \href{https://wiki.archlinux.org/index.php/VirtualBox/Install\_Arch\_Linux\_as\_a\_guest#Launch\_the\_VirtualBox\_guest\_services}{enable the Guest Services} if you do...)
\end{enumerate}
\subsection*{Questions:}
\begin{boxlist}
    \item What graphical user interface did you pick and why?
    \item Upload a screenshot of your graphical environment, showcasing the taskbars and various GUI elements.
    \item Open your preferred terminal emulator. Install \code{archey3}. Run \code{archey3} inside the terminal emulator
          and upload a screenshot of it.
\end{boxlist}

If you've completed this assignment, pat yourself on the back! Installing Arch is no easy feat!

\end{document}
