\begin{exe} {Logical Volumes}

   We are going to create a logical volume using two 250 MB
   partitions.  We are going to assume you have real
   partitionable disk space available.
   \begin{enumerate}
      \item
      Create two 250 MB partitions of type logical
      volume (\verb?8e?).
      \item

      Convert the partitions to physical volumes.

      \item

      Create a volume group named \texttt{myvg} and add
      the two physical volumes to it. Use the default
      extent size.

      \item

      Allocate a 300 MB logical volume named \texttt{mylvm}
      from volume group \texttt{myvg}.

      \item

      Format and mount the logical volume \texttt{mylvm}
      at \filelink{/mylvm}

      \item

      Use \textbf{lvdisplay} to view information about
      the logical volume.

      \item

      Grow the logical volume and corresponding
      filesystem to 350 MB.
   \end{enumerate}

   \begin{sol}

      \begin{enumerate}
         \item
         Execute:
         \begin{cmd}
$ sudo fdisk /dev/sda
         \end{cmd}
         using whatever hard disk is appropriate, and create the
         two partitions.  While in \textbf{fdisk}, typing \verb?t?
         will let you set the partition type to \verb?8e?.  While it
         doesn't matter if you don't set the type, it is a good idea
         to lessen confusion.  Use \verb?w? to rewrite the partition
         table and exit, and then
         \begin{cmd}
$ sudo partprobe -s
         \end{cmd}
         or reboot to make sure the new partitions take effect.

         \item
         Assuming the new partitions are \filelink{/dev/sdaX}
         and \filelink{/dev/sdaY}:
         \begin{cmd}
$ sudo pvcreate /dev/sdaX
$ sudo pvcreate /dev/sdaY
$ sudo pvdisplay
         \end{cmd}
         \item
         \begin{cmd}
$ sudo vgcreate myvg /dev/sdaX /dev/sdaY
$ sudo vgdisplay
         \end{cmd}
         \item
         \begin{cmd}
$ sudo lvcreate -L 300M -n mylvm myvg
$ sudo lvdisplay
         \end{cmd}
         \item
         \begin{cmd}
$ sudo mkfs.ext4 /dev/myvg/mylvm
$ sudo mkdir /mylvm
$ sudo mount /dev/myvg/mylvm /mylvm
         \end{cmd}
         If you want the mount to be persistent, edit
         \filelink{/etc/fstab} to include the line:
         \begin{configlst}[in \texttt{/etc/fstab}]
/dev/myvg/mylvm /mylvm ext4 defaults 0 0
         \end{configlst}
         \item
         \begin{cmd}
$ sudo lvdisplay
         \end{cmd}
         \item
         \begin{cmd}
$ df -h
$ sudo lvresize -r -L 350M /dev/myvg/mylvm
$ df -h
         \end{cmd}
         or
         \begin{cmd}
$ sudo lvresize -r -L +50M /dev/myvg/mylvm
         \end{cmd}
         or with older methods you can do:
         \begin{cmd}
$ df -h
$ sudo lvextend -L 350M /dev/myvg/mylvm
$ sudo resize2fs /dev/myvg/mylvm
$ df -h
         \end{cmd}

      \end{enumerate}
   \end{sol}
\end{exe}

