\begin{exe} {Partitioning a Disk Image File}

   \begin{lfbox}
      The next level of complication is to divide the
      container file into multiple partitions, each of which
      can be used to hold a filesystem, or a swap area.

      You can reuse the image file created in the previous
      exercise or create a new one.
   \end{lfbox}

   \begin{enumerate}

      \item
      Run \textbf{fdisk} on your imagefile:
      \begin{cmd}
$ sudo fdisk -C 130 imagefile
      \end{cmd}
      \begin{response}
Device does not contain a recognized partition table
Building a new DOS disk label with disk identifier 0x6280ced3.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help):
      \end{response}

      The \verb?-C 130? sets the number of phony
      cylinders in the drive, and is only necessary in old
      versions of \textbf{fdisk}, which unfortunately you
      will find on \textbf{RHEL 6}.  However, it will do
      no harm on other distributions.
      \item
      Type \verb?m? to get a list of commands:
      \begin{cmd}
m
      \end{cmd}
      \begin{response}
Command (m for help): m
Command action
a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
g   create a new empty GPT partition table
G   create an IRIX (SGI) partition table
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition's system id
u   change display/entry units
v   verify the partition table
w   write table to disk and exit
x   extra functionality (experts only)

Command (m for help):
      \end{response}
      \item
      Create a new primary partition and make it 256 MB (or
      whatever size you would like:
      \begin{cmd}
Command (m for help): n
      \end{cmd}
      \begin{response}
Partition type:
p   primary (0 primary, 0 extended, 4 free)
e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +256M
Partition 1 of type Linux and of size 256 MiB is set
      \end{response}
      \item Add a second primary partition also of 256 MB in size:
      \begin{cmd}
Command (m for help): n
      \end{cmd}
      \begin{response}
Partition type:
p   primary (1 primary, 0 extended, 3 free)
e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (526336-2097151, default 526336):
Using default value 526336
Last sector, +sectors or +size{K,M,G} (526336-2097151, default 2097151): +256M
Partition 2 of type Linux and of size 256 MiB is set

Command (m for help): p

Disk imagefile: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x6280ced3

Device Boot      StartEnd      Blocks   Id  System
imagefile1          2048      526335      262144   83  Linux
imagefile2          526336     1050623      262144   83  Linux
      \end{response}

      \item
      Write the partition table to disk and exit:
      \begin{cmd}
Command (m for help): w
      \end{cmd}
      \begin{response}
The partition table has been altered!

Syncing disks.
      \end{response}
   \end{enumerate}
   While this has given us some good practice, we haven't yet
   seen a way to use the two partitions we just created.
   We'll start over in the next exercise with a method
   that lets us do so.
\end{exe}



