CIT054 Index > Assignment: Adding Disks

Assignment: Adding Disks

Read everything before doing anything.

Part One

For a long time, Linux would not automatically detect when you inserted a new floppy or a USB drive. Instead, you had to mount and unmount them manually. We will return to those days to give you an idea of how it works. You’ll need a USB flash drive to do part of this assignment.

  1. Make sure your flash drive isn’t attached to the computer.

  2. Become root. On Ubuntu, get a root shell easily with sudo -s

  3. Start a script with script cit054_disks

  4. Turn off the HAL daemon (service) that auto-detects hardware. HAL, by the way, stands for “Hardware Abstraction Layer.” To kill this service, type ps aux | grep hald find the process number, and kill it. On SuSE, the daemon is named haldaemon; on Ubuntu, it’s hald.

  5. Plug in the flash drive. It won’t appear on your desktop.

  6. Create a mount point for the flash drive, and put a file into it, and check that it is really there:

    cd /media
    mkdir flashdrive
    date >> /media/flashdrive/today
    cat /media/flashdrive/today
  7. On most systems, the USB port is /dev/sda1. If you have some other USB devices plugged in, you may need to try /dev/sdb1.

    These names are formed as follows: sd means “SCSI disk” The first SCSI port is letter a, the second port is b, etc.

  8. Mount the drive:

    mount -t auto /dev/sda1 /media/flashdrive

    The -t auto option has the mount program figure out the type of filesystem on the USB drive.

  9. Now list some of the contents of the flash drive, and notice that the today file is “masked” by the newly mounted drive:

    ls -l /media/flashdrive | head
    cat /media/flashdrive/today
  10. Display the mounted devices table; it will tell you what kind of filesystem is on the device:

    cat /etc/mtab
  11. Unmount the flash drive, and look at the mounted devices table again:

    umount /media/flashdrive
    cat /etc/mtab
  12. The today file is still there:

    cat /media/flashdrive/today
  13. Remove the mount point (just to keep your system clean; if you were using this technique a lot, you’d keep the mount point directory around):

    rm /media/flashdrive/today
    rmdir /media/flashdrive
  14. Close the script file by typing exit

  15. You may exit from root status. The HAL daemon will restart the next time you restart the machine.

Part Two

Because of HAL, you don’t need to mount and unmount devices manually. However, you will want to use the mount command if you are making CD images or DVD images and want to test them before burning them to disc. In order to do this part of the assignment, you need to download cit054.iso and put it on your Linux machine. A .iso file is the “image” of a compact disc or DVD in ISO 9660 format.

  1. Become the root user again.

  2. Continue your script with:

    script -a cit054_disks
  3. Create a mount point:

    mkdir /media/iso
  4. Mount the image file as if it were a real disc by using the -o loop option.

    mount -t iso9660 -o loop cit054.iso /media/iso
  5. List the contents of the image with ls -l /media/iso

  6. If you wish, cat the files to see what they contain.

  7. Unmount the ISO image and remove the mount point directory:

    umount /media/iso
    rmdir /media/iso
  8. Close the script file by typing exit

When You Finish

Rename the script file cit054_disks in the form lastname_firstname_disks and email it to the instructor.