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.
- 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.
- 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.
- 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.
- Shut down your machine, if it is running.
- From the VirtualBox main window, open the settings for your virtual machine.
- Select the Storage category.
- Select the SATA Controller.
- 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.
- At the right of the SATA Controller, there is an icon with a + sign, for adding hard disks. Click it.
- Select Create.
- You are now in the new hard disk wizard, that you ran when you first created the virtual machine.
- Use the VDI type of drive.
- Choose a Dynamic drive.
- Browse to the buffalo drive and your folder within it.
- Do nothing with the existing disk.
- Choose a new name for the hard disk.
- Limit the size to 20MB.
- Follow the same steps to create a second, new drive.
- 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
.
- Perform the following steps on the first, new hard drive you created for Fedora.
- Use the p command after each step to see the size of each partition.
- 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.
- 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.
- Create an extended partition of size 8MiB, less 1KiB, that starts on the next mebibyte boundary.
- 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.
- 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.
- 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.
- List all the partitions on your new hard disk.
- 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
- You now have four partitions that need file systems.
- Put vfat in the first partition.
- Put ext2 in the second partition.
- Put ext3 in the third partition (first logical).
- Put ext4 in the fourth partion (second logical).
Mount partitions
- Create mount points for each of the four partitions in the /mnt directory.
- Use a command to list all the directories in the /mnt directory.
- Mount each of the four partitions with the appropriate file systems.
- 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
.
- Perform the following steps on the second, new hard drive you created for Fedora.
- Create a GPT partition table for this disk.
- Use the p command after each step to see the size of each partition.
- Issue the command unit MiB to set the default measurement to MiB.
- Create a primary partition of size 2.99 MiB. Start the partition at 1MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 4MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 7MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 10MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 13MiB.
- List all the partitions on your new hard disk.
- 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
- You now have five partitions that need file systems.
- Put vfat in the first partition.
- Put ext2 in the second partition.
- Put ext3 in the third partition.
- Put ext4 in the fourth partion.
- Put ntfs in the fifth partion.
Mount partitions
- Create mount points for each of the five partitions in the /mnt directory.
- Use a command to list all the directories in the /mnt directory.
- Mount each of the five partitions with the appropriate file systems.
- 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.
- Perform the following steps on the second hard drive you created for Fedora.
- Create a GPT partition table for this disk.
- Create a primary partition of size 2.99 MiB. Start the partition at 1MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 4MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 7MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 10MiB.
- Create another primary partition of size 2.99MiB. Start the partition at 13MiB.
- List all the partitions on your second hard disk. Set the output unit to MiB.
- 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.
- 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.
- If Disk Management has the option for creating a primary partition, then follow these steps.
- Create a primary partition of size 9M.
- Format the partition as NTFS. Provide an appropriate label.
- Mount the partition to one of the folders you created.
- Create an extended partition of size 9M.
- Create a logical partition of size 4M.
- Format the partition as NTFS. Provide an appropriate label.
- Mount the partition to the other folder you created.
- Create a logical partition of size 4M.
- Format the partition as FAT. Provide an appropriate label.
- Assign the partition a new drive letter. Use a letter towards the end of the alphabet.
- 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.
- Create a simple volume of size 3M.
- Format the partition as NTFS. Provide an appropriate label.
- Mount the partition to one of the folders you created.
- Create a simple volume of size 1M. Format it as FAT. Assign it a drive letter.
- Create a simple volume of size 1M. Format it as FAT. Assign it a drive letter.
- Create a simple volume of size 4M. This is actually the first logical partition. The partition has a different color bar.
- Format the partition as NTFS. Provide an appropriate label.
- Mount the partition to the other folder you created.
- Create a simple volume of size 4M. This is actually the second logical partition. The partition has a different color bar.
- Format the partition as FAT. Provide an appropriate label.
- 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.
- 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.
- 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.
- Create a primary partition of size 9M.
- Format the partition as NTFS. Provide an appropriate label.
- Mount the partition to one of the folders you created.
- Create an extended partition of size 9M.
- Create a logical partition of size 4M.
- Format the partition as NTFS. Provide an appropriate label.
- Mount the partition to the other folder you created.
- Create a logical partition of size 4M.
- Format the partition as FAT. Provide an appropriate label.
- Assign the partition a new drive letter. Use a letter towards the end of the alphabet.
- Use a command to list all the partition information for this disk.
- Select the disk that you partitioned with Disk Management and list all of its partitions.
- 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.
- 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.
-
fedora script
- fedora script output
- mount ouptut
- windows script
- 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.