Cabrillo College

The purpose of this lab is to create a minimal, yet functional, root file system on a thumb drive.
This involves four steps:
  1. Partitioning the thumb drive (fdisk)
  2. Creating a Linux ext file system (mkfs)
  3. Creating a rudimentary directory hierarchy (mkdir)
  4. Populating the directories with required files (mknod, cp)

Step One

Fdisk the memory stick
The reason we have to partition the memory stick is to create a space for the root filesystem that will be seperate from the Master Boot Record.
  1. Log on as root.
  2. Insert your memory stick into a USB port.
  3. Run the command:
    fdisk -l
    to find out what device file your thumb drive is attached to. If it is not there, then assume /dev/sda when you are in the 2504 lab.
  4. Run the fdisk command using the USB device file as the argument:
    fdisk /dev/sd?
  5. Create a single partition that uses all the "cylinders".
    (You may have to delete any existing partitions on the device.)
    Be sure to save the partition by exiting with "w".

Step Two

Create an ext3 file system on the device.
  1. With the thumbdrive still in the USB port, use the following command to create an ext3 file system:
    mkfs -t ext3 /dev/sd?
  2. Record the following information about your file system:
    • Block Size -
    • Number of inodes -
    • Number of blocks -
    • Number of blocks reserved for super user
  3. Remake the file system using the following additional options:
    mkfs -t ext3 -m 0 -N 500 -L /usb /dev/sd?
  4. What does the -m 0 option do? The -N 500? The -N 500?

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/sd?1 /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:
    bin, dev, etc, lib, proc, sbin, sys, tmp
    Change the permissions of the tmp directory to 1777.
    Do you know why we do this?

Step Four

Populate the directories with the required files
  1. In order to create a device file for the console, let's look at a long listing of the console device file from your system's dev directory:
    ls -l /dev/console
  2. Now, change directories to your dev directory:
    cd /mnt/dev
    and use the mknod command to create the console device file.
    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 the file you just created.
    chmod 600 console
  3. Copy the bash shell to your bin directory.
  4. Make a symbolic link from the bash file to the file, sh.
    ln -s bash sh
  5. Use the ldd command to see what libraries bash requires.
  6. Copy these libraries to your lib directory. For example:
    cp /lib/libtermcap.so.2 /mnt/lib/
Congratulations, you have just made a rudimentary root file system with one program on it. How many files make up your file system?

To turn in

Take a "picture" of your work and save it to a file.
  1. ls -lR /mnt > /root/myfs
  2. Unmount the file system:
    umount /dev/sd?1
  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.
    (The password for the cis191 account is "Cabri11o" )
    If your file is successfully transfered to Opus, you may delete your myfs file.

Grading Rubric

5 points for:
submitting a file called, lab1.your-logname to opus which contains a recursive long listing of your file system.
5 points for:
having all 8 directories with their correct permissions
10 points for:
having the console device file with correct permissions, type and major/minor numbers
10 points for:
having the correct executable and library files in /bin, and /lib.