Difference between revisions of "OPS235 Lab 1 - Fedora17"

From CDOT Wiki
Jump to: navigation, search
(Investigation 2: How do you create a vfat or ext2 filesystem?)
Line 2: Line 2:
 
[[Category:OPS235]][[Category:OPS235 Labs]]
 
[[Category:OPS235]][[Category:OPS235 Labs]]
 
== Objectives ==
 
== Objectives ==
* Format, mount, use, and unmount ext2, ext3, and vfat filesystems on USB flash drives.
+
* Format, mount, use, and unmount ext3, ext4, and vfat filesystems on USB flash drives.
 
* Create filesystems on various storage devices
 
* Create filesystems on various storage devices
 +
* Create hard disk partitions
 +
* Backup filesystems and images
 +
* Mount a filesystem stored within a a regular file
  
 
== Reference ==
 
== Reference ==
* [http://linuxmanpages.com/ man pages] for cp, mount, umount, fdisk, mkdir, file, mke2fs, mkfs, dumpe2fs
+
* [http://linuxmanpages.com/ man pages] for cp, mount, umount, fdisk, mkdir, file, mkfs, dumpe2fs, grep, dd
 
* Online reading material for weeks 1 and 2.
 
* Online reading material for weeks 1 and 2.
  
 
== Required materials ==
 
== Required materials ==
 
* [http://fedoraproject.org/get-fedora Fedora 12] Live CD
 
* [http://fedoraproject.org/get-fedora Fedora 12] Live CD
* USB flash drive, 1 GB or more in size (Warning: the contents of this drive will be erased)
+
* USB flash drive, 64 MB or more in size (Warning: the contents of this drive will be erased)
 +
* One SATA hard disk in a removable drive tray (minimum 80GB)  
  
 
== Instructions ==
 
== Instructions ==
Line 54: Line 58:
 
Answer the Investigation 1 question: How does Linux enable you to access two different drives without using a drive designator? (Write the answer in your lab log book).
 
Answer the Investigation 1 question: How does Linux enable you to access two different drives without using a drive designator? (Write the answer in your lab log book).
  
=== Investigation 2: How do you create a vfat or ext2 filesystem? ===
+
=== Investigation 2: How do you create a vfat or ext3 filesystem? ===
  
 
{{Admon/tip | Flash drives with no partition table | If your device name ends in a letter (for example, it is <code>/dev/sdb</code> instead of <code>/dev/sdb1</code>), add <code>-I</code> to the <code>mkfs</code> commands in this section. This is because your USB flash drive does not have a partition table, which normally causes an error; the <code>-I</code> option tells mkfs to proceed anyways.}}
 
{{Admon/tip | Flash drives with no partition table | If your device name ends in a letter (for example, it is <code>/dev/sdb</code> instead of <code>/dev/sdb1</code>), add <code>-I</code> to the <code>mkfs</code> commands in this section. This is because your USB flash drive does not have a partition table, which normally causes an error; the <code>-I</code> option tells mkfs to proceed anyways.}}
  
 
# Unmount your USB flash drive.
 
# Unmount your USB flash drive.
# Enter the command: <code>mkfs -t ext2 /dev/sda1</code>
+
# Enter the command: <code>mkfs -t ext3 /dev/sdb1</code>
 
#* What is the purpose of this command? Use the man page for mkfs to research what you did with this command.
 
#* What is the purpose of this command? Use the man page for mkfs to research what you did with this command.
 
#* Did we execute the command on the device name or the mount point?
 
#* Did we execute the command on the device name or the mount point?
Line 66: Line 70:
 
# Once the device is mounted do a long directory listing of the mount point. What has changed?
 
# Once the device is mounted do a long directory listing of the mount point. What has changed?
 
# Do an internet search to find out what the <code>lost+found</code> directory is for. Record your findings in your notes.
 
# Do an internet search to find out what the <code>lost+found</code> directory is for. Record your findings in your notes.
# Create a new file on the device using the same technique used in step 16.
+
# Create a new file on the device using the same technique used in Investigation 1.
 
# Unmount the device and remount it on the original mount point. Is the new file there?
 
# Unmount the device and remount it on the original mount point. Is the new file there?
# Type the command mount and observe the type value for the USB flash drive filesystem. Compare this value to the type found in step 14.
+
# Type the command mount and observe the type value for the USB flash drive filesystem. Compare this value to the type found in Investigation 1.
 
# Change your current working directory to where the device is mounted.
 
# Change your current working directory to where the device is mounted.
 
# Attempt to unmount the USB flash drive. What was the result? Why? Record your findings in your notes.
 
# Attempt to unmount the USB flash drive. What was the result? Why? Record your findings in your notes.
Line 74: Line 78:
 
# Consult the man pages for <code>mkfs</code> and <code>mkfs.ext3</code> to see how to reformat the device to a ext3 file system with a volume label that is the same as your learn ID.
 
# Consult the man pages for <code>mkfs</code> and <code>mkfs.ext3</code> to see how to reformat the device to a ext3 file system with a volume label that is the same as your learn ID.
 
# Enter the command to reformat the device.
 
# Enter the command to reformat the device.
# The <code>dumpe2fs /dev/sdb1</code> command will allow us to see detailed information about ext2/ext3 filesystems. Use it to confirm your volume label is correct and record the size of your journal.
+
# The <code>dumpe2fs /dev/sdb1</code> command will allow us to see detailed information about ext3 filesystems. Use it to confirm your volume label is correct and record the size of your journal.
 
# Mount the device again as an ext3 filesystem.
 
# Mount the device again as an ext3 filesystem.
 
# While the device is still mounted reformat the device as a vfat filesystem. What error message did you receive? Why? Record your conclusions in your notes.
 
# While the device is still mounted reformat the device as a vfat filesystem. What error message did you receive? Why? Record your conclusions in your notes.
 
# Unmount the device and format it as vfat.
 
# Unmount the device and format it as vfat.
# Now you will investigate what happens when you copy files to the device name rather than the mount point. Issue the command cp /etc/hosts /dev/sda1
+
# Now you will investigate what happens when you copy files to the device name rather than the mount point. Issue the command cp /etc/hosts /dev/sdb1
# Now mount your device. Was it successfull? Try mounting it as ext2. Was it successfull? What has happened to the filesystem on the device?
+
# Now mount your device. Was it successful? Try mounting it as ext3. Was it successful? What has happened to the filesystem on the device?
 
# Reformat it as vfat and mount it.
 
# Reformat it as vfat and mount it.
 
# Unmount the device.
 
# Unmount the device.
Line 87: Line 91:
 
=== Final Task - Copy some files from your system to a USB flash drive in Fedora Linux ===
 
=== Final Task - Copy some files from your system to a USB flash drive in Fedora Linux ===
  
Task: Reformat your USB flash drive as an ext2 filesystem with a volume label of "LAB1" and copy the files /etc/services, /etc/issue and /etc/networks to it. Mount your flash drive on /media/lab-one and show it to your Professor along with your detailed lab notes.
+
Task: Reformat your USB flash drive as an ext3 filesystem with a volume label of "LAB1" and copy the files /etc/services, /etc/issue and /etc/networks to it. Mount your flash drive on /media/lab-one and show it to your Professor along with your detailed lab notes.
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
  
 
=== Completing the Lab ===
 
=== Completing the Lab ===

Revision as of 15:01, 8 January 2010

Using Linux to Access Block Devices and Filesystems

Objectives

  • Format, mount, use, and unmount ext3, ext4, and vfat filesystems on USB flash drives.
  • Create filesystems on various storage devices
  • Create hard disk partitions
  • Backup filesystems and images
  • Mount a filesystem stored within a a regular file

Reference

  • man pages for cp, mount, umount, fdisk, mkdir, file, mkfs, dumpe2fs, grep, dd
  • Online reading material for weeks 1 and 2.

Required materials

  • Fedora 12 Live CD
  • USB flash drive, 64 MB or more in size (Warning: the contents of this drive will be erased)
  • One SATA hard disk in a removable drive tray (minimum 80GB)

Instructions

  1. Set your computer's drive selector switch to external, then power up the computer.
  2. Insert the Fedora Live CD into the CD/DVD drive.
  3. Reboot the system.
  4. The boot process is completed when you see the GDM Login Screen. Click on "Automatic Login" to login as the "Live System User".
  5. We are going to start by opening a terminal window to access our shell environment. Click on Applications --> System Tools --> Terminal to start the terminal.
  6. At the top of the terminal window, you should see the command prompt similar to [liveuser@localhost ~]$ This prompt indicates that it is ready to take your command. The program that is running is called a shell.
  7. At the command prompt, enter the command whoami (all in one word) and press return. This command shows the so-called User Name. Make notes of this user name.
  8. At the command prompt, enter the command pwd and press return. This command shows the so-called present working directory or current working directory. Record the present working directory of the shell running on the terminal window. As we have not yet changed directories this should also be your users home directory. (Also indicated by the ~ character in the prompt)
Important.png
Using Superuser Privilege
Throughout this course, you may need to execute commands using the privileges of the the administrative user (username "root", also called the "superuser"). To switch from your account to the root account, type the command: su -

After switching user notice and make note of the change in your shell prompt. Also note the difference in output for the whoami and pwd commands.

Whenever this is required, make a note of it, and determine why superuser privilege is required.

When you are finished using the root account type exit to return to your previous account. Avoid using the superuser account unless absolutely necessary, because the superuser account has unlimited privilege and a typo can destroy your system.

Note.png
Disabling the Auto-mounting of Devices
At this point we need to disable the ability for our linux system to automatically detect and mount removeable media. This would interfere with the learning objectives of the rest of the lab. To do this enter the command: pkill hald. You will need to do this again if you reboot during this lab.

Investigation 1: How does Linux enable you to access two different drives without using a drive designator?

  1. Type the command mount. Describe the output of the command in your lab log. What do the fields of data represent? Use the man page for the mount command and google searches to find this information
  2. Insert your USB flash drive into a USB port on the computer.
  3. Because we have turned off the automatic mounting feature nothing will happen. In order to access the file system on this storage device we must mount it on to our existing file/directory structure.
  4. To mount a device we must first create a mount point to mount it on. Create a new directory called /media/usb (These steps should be done as "root")
  5. Next we need to use the mount command to mount the device. Try typing the following command: mount -t vfat /dev/sdb1 /media/usb. This command contains 3 important pieces of information (command arguments):
    • -t vfat tells the mount command to mount it as a FAT filesystem. (Most likely choice for a USB flash drive)
    • /dev/sdb1 tells the mount command which device to mount. (If this didn't work try /dev/sdc1 or /dev/sda1)
    • /media/usb tells the mount command where to mount the device (the "mount point")
  6. Type the command mount and compare the output with the output from step 9. Record what has changed.
  7. What file system type is the USB device mounted as? Where was it mounted? What is the device name?
  8. Create a file in the directory /media/usb/ by redirecing the output of the cal command: cal >/media/usb/month
  9. Display a detailed listing of the directory where the device is mounted and record the output: ls -l /media/usb
  10. Type the command umount /media/usb -- What happened to the contents of the /media/usb directory? Compare results with step 17.
  11. Type the command mount and observe the output. What is different from step 14? Why?
  12. Make a new mount point called /media/usb2 Mount your usb flash drive on the new mount point.
  13. Display a detailed listing of the new mount point again. Is your file there?

Answer the Investigation 1 question: How does Linux enable you to access two different drives without using a drive designator? (Write the answer in your lab log book).

Investigation 2: How do you create a vfat or ext3 filesystem?

Idea.png
Flash drives with no partition table
If your device name ends in a letter (for example, it is /dev/sdb instead of /dev/sdb1), add -I to the mkfs commands in this section. This is because your USB flash drive does not have a partition table, which normally causes an error; the -I option tells mkfs to proceed anyways.
  1. Unmount your USB flash drive.
  2. Enter the command: mkfs -t ext3 /dev/sdb1
    • What is the purpose of this command? Use the man page for mkfs to research what you did with this command.
    • Did we execute the command on the device name or the mount point?
  3. Attempt to mount the USB flash drive using the command you used in Investigation 1. What was the result?
  4. Check the man page for the mount command to see how to change your command to mount the device correctly, and issue that command.
  5. Once the device is mounted do a long directory listing of the mount point. What has changed?
  6. Do an internet search to find out what the lost+found directory is for. Record your findings in your notes.
  7. Create a new file on the device using the same technique used in Investigation 1.
  8. Unmount the device and remount it on the original mount point. Is the new file there?
  9. Type the command mount and observe the type value for the USB flash drive filesystem. Compare this value to the type found in Investigation 1.
  10. Change your current working directory to where the device is mounted.
  11. Attempt to unmount the USB flash drive. What was the result? Why? Record your findings in your notes.
  12. Solve the error and unmount the device.
  13. Consult the man pages for mkfs and mkfs.ext3 to see how to reformat the device to a ext3 file system with a volume label that is the same as your learn ID.
  14. Enter the command to reformat the device.
  15. The dumpe2fs /dev/sdb1 command will allow us to see detailed information about ext3 filesystems. Use it to confirm your volume label is correct and record the size of your journal.
  16. Mount the device again as an ext3 filesystem.
  17. While the device is still mounted reformat the device as a vfat filesystem. What error message did you receive? Why? Record your conclusions in your notes.
  18. Unmount the device and format it as vfat.
  19. Now you will investigate what happens when you copy files to the device name rather than the mount point. Issue the command cp /etc/hosts /dev/sdb1
  20. Now mount your device. Was it successful? Try mounting it as ext3. Was it successful? What has happened to the filesystem on the device?
  21. Reformat it as vfat and mount it.
  22. Unmount the device.

Answer the Investigation 2 question.

Final Task - Copy some files from your system to a USB flash drive in Fedora Linux

Task: Reformat your USB flash drive as an ext3 filesystem with a volume label of "LAB1" and copy the files /etc/services, /etc/issue and /etc/networks to it. Mount your flash drive on /media/lab-one and show it to your Professor along with your detailed lab notes.





Completing the Lab

Arrange evidence of each of the following items on the screen, and then ask your professor or lab monitor to check them:

  1. USB Formatted as ext2 ( )
  2. Volume Label is "LAB1" ( )
  3. USB Mounted on /media/lab-one ( )
  4. Following files on USB services, issue, networks ( )
  5. Instructor satisfied with complete and detailed lab notes ( )

Preparing for the Quizzes

The online readings linked on the course web page contain some useful information about Free and Open Source Software. Use them and Internet searches to answer the following questions to help you prepare for the quizzes:

  1. Who is Linus Torvalds?
  2. Name 3 open source software projects widely used today?
  3. What license agreement does GNU/Linux use?
  4. What are the 4 basic software freedoms that define "Free Software"?
  5. Who makes up the Fedora Community?
  6. Name 4 other significant Linux "Distros"