CGS3767 Homework 3

Due Thursday, 4/4 (not late until 8am, 4/5)

Questions from the text book

Create a text file and answer the following list of questions from Chapter 5 of the text book. In addition to writing the answer, include the page in the book where the answer can be found. You must inlcude the answer and the page number for each question.

1, 3, 4, 5, 8, 9, 10, 11, 13, 16, 17, 18, 20

Answer the following questions

Refer to the lecture on modes for these questions.

  1. Write the command that will set the permissions in Fedora for a file named exampleFile so that the user can read and write it, the group has no access to it and all others can read the file.
  2. Write the command that will set the permissions in Fedora for a directory named exampleDir so that the user can read it, write it and make it the current directory; the group has no access to it and all others can read it and make it the current directory.
  3. What does a mode of 501 mean?

Place all of the above answers in a text file (not a word processor document). This is one of the files to submit.

Adding a hard drive in Virtual Box

Follow these instructions to add a new hard disk to a virtual machine. Add two hard disks in Fedora and two in Windows.

  1. Shut down your machine, if it is running.
  2. From the VirtualBox main window, open the settings for your virtual machine.
  3. Select the Storage category.
  4. Select the SATA Controller.
    1. You should see your current hard drive listed, do not change or delete it. Leave it alone, unless you feel like starting all over again.
    2. At the right of the SATA Controller, there is an icon with a + sign, for adding hard disks. Click it.
    3. Select Create.
  5. You are now in the new hard disk wizard, that you ran when you first created the virtual machine.
    1. Use the VDI type of drive.
    2. Choose a Dynamic drive.
    3. Browse to the buffalo drive and your folder within it.
    4. Do nothing with the existing disk.
    5. Choose a new name for the hard disk.
    6. Limit the size to 20MB.
  6. Follow the same steps to create a second, new drive.
  7. Start your virtual machine. You will now have two, new hard disks.

View a video for creating a new drive in Virtual Box. This is a general video, it does not implement the complete homework.

Working with file systems

Partition programs use many units to indicate the starting address and size of a partion.

Sector
A sector is usually 512 bytes.
Kilobyte
Kilobyte is abbreviated KB and is 1000 bytes.
Kibibyte
Kibibyte is abbreviated KiB and is 1024 bytes.
Megabyte
Megabyte is abbreviated MB and is 1000 kilobytes.
Mebibyte
Mebibyte is abbreviated MiB and is 1024 kibibytes.
Gigabyte
Gigabyte is abbreviated GB and is 1000 megabytes.
Gibibyte
Gibibyte is abbreviated GiB and is 1024 mebibytes.

The fdisk program uses sectors by default. Kibibytes, Mebibytes and Gigibytes can be specified with the symbols K, M and G, respectively.

The parted program uses KB by default. All of the above measurements can be specified, as well sectors with s and bytes with b.

Fedora

Create two new, virtual hard drives for Fedora.

Partition a hard drive with fdisk

Use the fdisk program to perform the following steps. I have created a simple information page for fdisk.

  1. Perform the following steps on the first, new hard drive you created for Fedora.
    1. Use the p command after each step to see the size of each partition.
    2. Create a primary partition of size 3071K (3 MiB, less 1KiB). When specifying the size in the partition program, use +3071K. Use the default starting location, since 1MiB is needed for disk overhead.
    3. Create another primary partition of size 3 MiB, less 1KiB. Start the partition on the next mebibyte boundary. A mebibyte boundary is a multiple of 2048 sectors. This one will start at 1MiB + 3MiB = 4MiB boundary, which is 2048 * 4 = 8192 sectors.
    4. Create an extended partition of size 8MiB, less 1KiB, that starts on the next mebibyte boundary.
    5. Create a logical partition of size 3MB, less 1KiB. Each logical partition needs 1 MiB for overhead, so the this logical partition must start on the second mebibyte boundary after the end of the last partition.
    6. Create a logical partition that uses all the remaining space in the extended partition. Each logical partition needs 1 MiB for overhead, so the this logical partition must start on the second mebibyte boundary after the end of the last partition.
    7. Be sure to save changes before exiting fdisk. You will not be warned about unsaved changes. But even if you forget to save your changes, remember that practice makes perfect.
  2. List all the partitions on your new hard disk.
  3. Why was /dev/sdb4 skipped?

View a video on partitioning with fdisk. This is a general video, it does not implement the complete homework.

Make file systems

  1. You now have four partitions that need file systems.
  2. Put vfat in the first partition.
  3. Put ext2 in the second partition.
  4. Put ext3 in the third partition (first logical).
  5. Put ext4 in the fourth partion (second logical).

Mount partitions

  1. Create mount points for each of the four partitions in the /mnt directory.
  2. Use a command to list all the directories in the /mnt directory.
  3. Mount each of the four partitions with the appropriate file systems.
  4. Use a command to display all the mounted file systems.

Partition a hard drive with parted

Use the parted program to perform the following steps. I have created a simple information page for parted.

  1. Perform the following steps on the second, new hard drive you created for Fedora.
    1. Create a GPT partition table for this disk.
    2. Use the p command after each step to see the size of each partition.
    3. Issue the command unit MiB to set the default measurement to MiB.
    4. Create a primary partition of size 2.99 MiB. Start the partition at 1MiB.
    5. Create another primary partition of size 2.99MiB. Start the partition at 4MiB.
    6. Create another primary partition of size 2.99MiB. Start the partition at 7MiB.
    7. Create another primary partition of size 2.99MiB. Start the partition at 10MiB.
    8. Create another primary partition of size 2.99MiB. Start the partition at 13MiB.
  2. List all the partitions on your new hard disk.
  3. Are you limited to four partitions?

View a video on partitioning with parted. This is a general video, it does not implement the complete homework.

Make file systems

  1. You now have five partitions that need file systems.
  2. Put vfat in the first partition.
  3. Put ext2 in the second partition.
  4. Put ext3 in the third partition.
  5. Put ext4 in the fourth partion.
  6. Put ntfs in the fifth partion.

Mount partitions

  1. Create mount points for each of the five partitions in the /mnt directory.
  2. Use a command to list all the directories in the /mnt directory.
  3. Mount each of the five partitions with the appropriate file systems.
  4. Use a command to display all the mounted file systems.

After you have mounted all the systems and can change to each mount point, copy the output of the mount command to a text file. This is one of the files you will submit for the homework.

Partition a hard drive from the command line

parted can also be called from a command-line script.

Create a script file that contains commands for parted that will perform the same steps that were done interactively parted. Run this script from a command window.

Create two empty folders that will be used as mount points.

Add the parted commands to a script file to perform the following steps on the second, new hard drive you created for Fedora.

  1. Perform the following steps on the second hard drive you created for Fedora.
    1. Create a GPT partition table for this disk.
    2. Create a primary partition of size 2.99 MiB. Start the partition at 1MiB.
    3. Create another primary partition of size 2.99MiB. Start the partition at 4MiB.
    4. Create another primary partition of size 2.99MiB. Start the partition at 7MiB.
    5. Create another primary partition of size 2.99MiB. Start the partition at 10MiB.
    6. Create another primary partition of size 2.99MiB. Start the partition at 13MiB.
  2. List all the partitions on your second hard disk. Set the output unit to MiB.
  3. List all the partitions on your first hard disk. Set the output unit to sectors.

Run the script and redirect its output to a text file. This is one of the files you will submit for the homework. You will also submit the script file.

(Optional) Edit /etc/fstab at your own risk

The mounted file systems will not be remounted automatically after reboot. In order to mount these partitions automatically, you must edit the /etc/fstab file. Be very careful. If you mess up the /etc/fstab file, your system will not boot. You do not need to complete this section for the homework. This is not for extra credit, either.

If you want to do this, I suggest you complete the homework and submit it before you edit the /etc/fstab file.

The file /etc/fstab is read during the boot process. Partitions can be mounted automatically by placing a reference to the file system in the file. Check http://www.tuxfiles.org/linuxhelp/fstab.html for good information about the format of the file.

Edit the file and add entries for each partition. You can use a format that looks like:

  device-name     mount-point    fs-type    defaults    1    n

Where device-name is the partition name, like /dev/sdb2; mount-point is a folder name, like /mnt/sdb2; fs-type is the file system type, like ext2; always use the word 'defaults', to indicate that this partition has the usual attributes; the 1 means that it can be backed up; the n is a number that indicates the order in which the file systems will be checked.

For example, the entry for /dev/sdb2 would be as follows.

  /dev/sdb2    /mnt/sdb2    ext2    default    1    3

Add an entry for each partition that you created. The next time you boot the virtual machine, all the partitions will be loaded automatically. Be very careful with the syntax. If there is an error, you will not be able to boot your machine.

Windows

Create two new, virtual hard drives for Windows.

Partition a hard drive with Disk Management

Create two empty folders that will be used as mount points.

Use the Disk Management program to perform the following steps on the first, new hard drive you created for Windows.

  1. Initialize the new disk with MBR. It is also possible to intialize as GPT for large disks. The disks for this assignment are not large enough to format as GPT.
  2. If Disk Management has the option for creating a primary partition, then follow these steps.
    1. Create a primary partition of size 9M.
      1. Format the partition as NTFS. Provide an appropriate label.
      2. Mount the partition to one of the folders you created.
    2. Create an extended partition of size 9M.
    3. Create a logical partition of size 4M.
      1. Format the partition as NTFS. Provide an appropriate label.
      2. Mount the partition to the other folder you created.
    4. Create a logical partition of size 4M.
      1. Format the partition as FAT. Provide an appropriate label.
      2. Assign the partition a new drive letter. Use a letter towards the end of the alphabet.
  3. If Disk Management only allows the option to create a Simple Volume, then follow these steps. If Disk Management only allows a minimum partition size of 8M, then shut down, delete the hard disk for this part and recreate it as 60MB. In this case, create each partition for this section as 8M.
    1. Create a simple volume of size 3M.
      1. Format the partition as NTFS. Provide an appropriate label.
      2. Mount the partition to one of the folders you created.
    2. Create a simple volume of size 1M. Format it as FAT. Assign it a drive letter.
    3. Create a simple volume of size 1M. Format it as FAT. Assign it a drive letter.
    4. Create a simple volume of size 4M. This is actually the first logical partition. The partition has a different color bar.
      1. Format the partition as NTFS. Provide an appropriate label.
      2. Mount the partition to the other folder you created.
    5. Create a simple volume of size 4M. This is actually the second logical partition. The partition has a different color bar.
      1. Format the partition as FAT. Provide an appropriate label.
      2. Assign the partition a new drive letter. Use a letter towards the end of the alphabet.

    Partition a hard drive from the command line

    DISKPART is a command line program that replaces the older FDISK program. I have created an information page for DISKPART.

    View a video on partitioning with diskpart in interactive mode. This is a general video, it does not implement the complete homework.

    Create a text file (not a bat file) that contains commands for DISKPART that will perform the same steps that were done in Disk Management. Run this text file through DISKPART on the second, new hard disk that was created for Windows. I recommend that you perform these steps interactively before creating the script file.

    Create two empty folders that will be used as mount points.

    Add the DISKPART commands to a text file toUse the Disk Management program to perform the following steps on the second, new hard drive you created for Windows.

    1. Select the disk and erase the partition table and all existing partitions. Be sure to select the correct disk before doing this. If you perform this task on the boot disk, you will have to recreate your virtual machine.
    2. Initialize the new disk with MBR. It is also possible to intialize as GPT for large disks. The disks for this assignment are not large enough to format as GPT.
    3. Create a primary partition of size 9M.
      1. Format the partition as NTFS. Provide an appropriate label.
      2. Mount the partition to one of the folders you created.
    4. Create an extended partition of size 9M.
    5. Create a logical partition of size 4M.
      1. Format the partition as NTFS. Provide an appropriate label.
      2. Mount the partition to the other folder you created.
    6. Create a logical partition of size 4M.
      1. Format the partition as FAT. Provide an appropriate label.
      2. Assign the partition a new drive letter. Use a letter towards the end of the alphabet.
    7. Use a command to list all the partition information for this disk.
    8. Select the disk that you partitioned with Disk Management and list all of its partitions.
    9. Use a command to list the information about all the volumes on the system.

    Run the script and redirect the output to a text file. This is one of the files you will submit for the homework. you will also submit the text file that has the DISKPART commands in it.

    Hand In Homework

    You should have the following text files.

    1. one text file that contains the answers (with page numbers) to the questions from the book and the answers to the questions about Linux permissions.
    2. fedora script
    3. fedora script output
    4. mount ouptut
    5. windows script
    6. windows script output.

    Copying files from your virtual machine to ocelot

    To copy files from your virtual machine to ocelot, use scp in Linux and WinSCP in Windows. I have an information page for using secure copy.

    Copy the files to ocelot and zip them into one zip file.

    Uploading ZIP file

    Submitting Homework Online. When you are asked for a username and password, use your webmail username with the password that I sent to you.