Updated: 2013-05-08 21:04 EDT

1 Due Date and DeliverablesIndexup to index

WARNING: Some inattentive students upload Assignment #7 into the Assignment #6 upload area. Don’t make that mistake! Be exact.

2 Purpose of this AssignmentIndexup to index

This assignment is based on your weekly Class Notes.

  1. To understand and work with hard links, du, find, and disk quotas.
    1. An Easy task
    2. A Medium task
    3. A Hard task

Remember to READ ALL THE WORDS to work effectively and not waste time.

3 Introduction and OverviewIndexup to index

This is an overview of how you are expected to complete this assignment. Read all the words before you start working.

Complete the Tasks listed below on the Course Linux Server (CLS). Check your work using the given examples. Run a Checking Program to verify your work after you have run your own tests. Submit the output of the checking script to Blackboard before the due date.

You must understand hard links and know how to use the find and du commands to do this assignment. See the Class Notes, especially all the notes dealing with the File System, Inodes and Links, and Disk Usage.

Non-empty files occupy disk space. Hard links to files only occupy a little extra space in a directory for the extra file name; they don’t create new disk file space. To remove a file, you must remove all the names a file has. (The link count must go to zero.)

Your job is to remove all the files in a directory and reduce the disk space used. You will be given a series of directories containing linked files. You have to remove all the names for some files so that the system actually frees up the disk space.

Recall that the rm command does not remove files; it only removes names. Your job is to make the system remove the disk blocks occupied by the files, to make more disk space, which means you need to find and remove all the names for the files so that the link counts go to zero.

There are three levels of difficulty. Do the easy one first.

3.1 The Source DirectoryIndexup to index

All references to the “Source Directory” below are to the directory ~idallen/cst8207/13w/assignment07/ and that name starts with a tilde character “~” followed by a userid with no intervening slash. The leading tilde indicates to the shell that the pathname starts with the HOME directory of the account idallen.

4 TasksIndexup to index

4.1 Set UpIndexup to index

  1. Create the following directory structure in your CLS HOME directory and record (for study purposes) the series of Unix commands you used to create it. Spelling and capitalization must be exactly as shown:

    CST8207-13W/
    `-- Assignments
        `-- assignment07
  2. Execute the Checking Program located in the Source Directory. The command will create a directory named blocks in your assignment07 directory that will contain some sub-directories and files.

If you make errors in this assignment, you can remove or rename the blocks directory and re-execute the above Checking Program to re-create the blocks directory for you and start over.

If you remove the blocks directory, you will need to redo the whole assignment. If you rename the directory, you can salvage from the saved directory the parts of the assignment you have already done successfully.

4.2 The first level of difficulty is “easy”Indexup to index

There is a directory named blocks/easy. This easy subdirectory contains 236 blocks (recursive total for everything) and a foo subdirectory that contains 84 blocks of those 236 blocks.

$ cd blocks/easy
$ du -s .
236 .
$ du -s foo
84  foo

Read this section all the way through before you delete anything.

YOUR JOB: Remove all the files in the foo subdirectory (but keep the directory), so that the total disk use in the easy directory drops to 236-80=156 blocks. Don’t try to do this until you’ve read this whole section through, including the Hints below.

Hints: Some of the files in the foo subdirectory have more than one name. Those other names are located somewhere else under easy. (You don’t have to search the whole disk partition to find them.) The disk blocks for these files in foo will not be freed until you find and remove all their names. Do not remove any names from foo until you also know how to find and remove all the other names for these files. You will need to look at inode numbers to know which files in directory foo are also named in the other directories.

If you succeed in the easy directory you will see this:

$ du -s .  ;  du -s foo  ;  find . | wc
156 .
4 foo
39 39 431

If you don’t get the right answer, you can start over using the Set Up steps, above.

4.3 The next level of difficulty is “medium”Indexup to index

There are two hidden directory under blocks. One name contains the string medium as part of its name. This medium subdirectory contains 368 disk blocks (recursive total for everything) and a foo subdirectory that contains 132 of those 368 blocks.

YOUR JOB: Remove all the files in the foo subdirectory (but keep the directory), so that the total disk use in the medium directory drops to 368-128=240 blocks.

Hints: See the previous question for hints on finding all the file names.

If you succeed in the medium directory you will see this:

$ du -s .  ;  du -s foo  ;  find . | wc
240 .
4 foo
60 60 744

If you don’t get the right answer, you can start over using the Set Up steps, above.

4.4 The next level of difficulty is “hard”Indexup to index

There are two hidden directory under blocks. One name contains the string hard as part of its name. This hard subdirectory contains 304 disk blocks (recursive total for everything) and a foo subdirectory that contains 132 of those 304 disk blocks.

YOUR JOB: Remove all the files in the foo subdirectory (but keep the directory), so that the total disk use in the hard directory drops to 304-128=176 blocks.

Hints: An option to ls to display nongraphic (unprintable) characters will be needed. Many file names will need to be quoted to protect shell metacharacters. See the previous question for hints on finding all the file names.

If you succeed in the hard directory you will see this:

$ du -s .  ;  du -s foo  ;  find . | wc
176 .
4 foo
60 165 864

If you don’t get the right answer, you can start over using the Set Up steps, above.

4.5 When you are doneIndexup to index

That is all the tasks you need to do. Verify your disk usage for each section and then mark your work by running the Checking Program.

5 Checking, Marking, and Submitting your WorkIndexup to index

Summary: Do some tasks, then run the checking program to verify your work as you go. You can run the checking program as often as you want. When you have the best mark, upload the marks file to Blackboard.

  1. There is a Checking Program named assignment07check in the Source Directory on the CLS. You can execute this program by typing its (long) pathname into the shell:

    $ ~idallen/cst8207/13w/assignment07/assignment07check

  2. Execute the above “check” program. This program will check your work, assign you a mark, and display the output on your screen. (You may want to paginate the long output so you can read all of it.)

    You may run the “check” program as many times as you wish, to correct mistakes and get the best mark. Some tasks sections require you to finish the whole section before running the checking program at the end; you may not always be able to run the checking program successfully after every single task step.

  3. When you are done with checking this assignment, and you like what you see on your screen, redirect the output of the Checking Program into the text file assignment07.txt under your assignment07 directory. Use the exact name assignment07.txt in your assignment07 directory. You only get one chance to get the name correct. Case (upper/lower case letters) matters. Be absolutely accurate, as if your marks depended on it. Do not edit the file.

  4. Transfer the above assignment07.txt file from the CLS to your local computer and verify its contents. Do not edit this file! No empty files, please! Edited or damaged files will not be marked. You may want to refer to your File Transfer notes.

  5. Submit the assignment07.txt file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the assignment07 “Upload Assignment” facility in Blackboard: click on the underlined assignment07 link in Blackboard. Use “Attach File” and “Submit” to upload your plain text file.

    No word-processor documents. Do not send email. Use only “Attach File”. Do not enter any text into the Submission or Comments boxes on Blackboard; I do not read them. Use only the “Attach File” section followed by the Submit button. (If you want to send me comments about your assignment, use email.)

  6. Your instructor may also mark the assignment07 directory in your CLS account after the due date. Leave everything there on the CLS. Do not delete any assignment work from the CLS until after the term is over!

Use the exact file name given above. Upload only one single file of plain text, not HTML, not MSWord. No fonts, no word-processing. Plain text only.

Did I mention that the format is plain text (suitable for VIM/Nano/Pico/Gedit or Notepad)?

NO EMAIL, WORD PROCESSOR, PDF, RTF, or HTML DOCUMENTS ACCEPTED.

No marks are awarded for submitting under the wrong assignment number or for using the wrong file name. Use the exact name given above.

WARNING: Some inattentive students don’t read all these words. Don’t make that mistake! Be exact.

READ ALL THE WORDS. OH PLEASE, PLEASE, PLEASE READ ALL THE WORDS!

Author: 
| Ian! D. Allen  -  idallen@idallen.ca  -  Ottawa, Ontario, Canada
| Home Page: http://idallen.com/   Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom:  http://eff.org/  and have fun:  http://fools.ca/

Plain Text - plain text version of this page in Pandoc Markdown format

Campaign for non-browser-specific HTML   Valid XHTML 1.0 Transitional   Valid CSS!   Creative Commons by nc sa 3.0   Hacker Ideals Emblem   Author Ian! D. Allen