Lab 1: Creating a Root File System

The purpose of this lab is to create a minimal root file system on a floppy disk.
This involves four steps:
  1. Formatting the floppy disk (fdformat)
  2. Creating a Linux ext file system (mkfs)
  3. Creating a rudimentary directory hierarchy (mkdir)
  4. Populating the dev directory with required device files (mknod)
  5. Adding a statically linked shell, /bin/ash.static, as the initial program (cp, ln)

Step One

Format the floppy disk.
The reason we have to format the floppy is to remove the vfat file system with which most new floppies are sold, and to verify that the floppy has no bad tracks.
  1. Log on as root.
  2. Insert your floppy disk into the floppy drive.
  3. Run the fdformat command naming the floppy device file as the argument:
    fdformat /dev/fd0
  4. Make sure that it verifies without errors.

Step Two

Create an ext2 file system on the floppy.
  1. With the floppy still in the drive, use the following command to create an ext2 file system:
    mkfs -t ext2 /dev/fd0
  2. Record the following information about your file system:
  3. Remake the file system using the following additional options:
    mkfs -t ext2 -m 0 -N 104 /dev/fd0
  4. What does the -m 0 option do? The -N 104?
  5. Why aren't we making an ext3 file system?

Step Three

Mount the file system and create the directory structure of the root file system on it.
  1. Mount your new file system to the /mnt directory:
    mount /dev/fd0 /mnt
  2. Use the ls command to list the contents of your file system.
    ls -l /mnt
  3. Is anything there?
    You might want to change your current working directory to /mnt.
  4. Add the following directories on your new file system:
    dev, bin, sbin

Step Four

Create the device files needed in the /dev directory.
  1. Now create the important device files in the dev directory using the mknod command. Do a long listing of the following device files from your system's dev directory:
    ls -l /dev/{console,kmem,mem,fd0}
  2. Now, change directories to your dev directory:
    cd /mnt/dev
    and use the mknod command to create each of the above listed device files.
    The syntax is: mknod   <name>   c|b   major#   minor#
    For example: mknod console c 5 1
    Be sure to set the correct permissions, ownership and group for each file. e.g.
    chmod 600 console
    This sets up the console device file, the other three are left for you to do.

Step Five

The final step is to copy a simple shell program to the bin directory and make a symbolic link to it called /sbin/init. This is the file the kernel invokes after it boots.
Remember, the shell is one of the most important parts of the operating system!
  1. Copy the ash.static shell to your bin directory and rename it to just sh.
    cp /bin/ash.static /mnt/bin/sh
    Verify that it is executable.
  2. Now change directory to your sbin directory and create a symbolic link to the shell we just copied, and call the link init.
    ln -s ../bin/sh init

To turn in

Take a "picture" of your work and save it in a file.
  1. ls -lR /mnt > /root/myfs
  2. Unmount the file system:
    umount /dev/fd0
  3. Change your current working directory back to /root
    Turn in the "picture" you took of your file system to the CIS191 account on the machine, opus.cabrillo.edu using the following command:
    scp myfs cis191@opus.cabrillo.edu:lab1.logname
    Note: logname is your last name, all lowercase. e.g. my logname = griffin
    (The password for the cis191 account is "ci$191" )

Grading Rubric

5 points for:
submitting a file called, lab1.your-log-name to opus which contains a recursive long listing of your file system.
5 points for:
having all 4 directories with their correct permissions
5 points for:
having all 4 device files with correct permissions, type and major/minor numbers
5 points for:
having the correct executable file, /bin/sh and a symbolic link, /sbin/init.