COMP 3000 Lab 4 2012: Difference between revisions
No edit summary |
|||
Line 4: | Line 4: | ||
* Show all your work. Short answers are not sufficient; you should list any websites or individuals you consult and should document any experiments you conducted. For any question that you could just answer without any external reference or experiment, write "(no work required)" after your answer. | * Show all your work. Short answers are not sufficient; you should list any websites or individuals you consult and should document any experiments you conducted. For any question that you could just answer without any external reference or experiment, write "(no work required)" after your answer. | ||
* All submitted code and commands should compile and run. Partial code fragments or explanations may not be given credit. While code may use standard C and UNIX/Linux libraries, no code should rely on external binaries. | * All submitted code and commands should compile and run. Partial code fragments or explanations may not be given credit. While code may use standard C and UNIX/Linux libraries, no code should rely on external binaries. | ||
* '''The exercises in this lab require root access on a Linux system.''' | * '''The exercises in this lab require root access on a Linux system.''' In the labs, you can use the COMP2401-2404 VM with the admin account (password "nimda1234!"). To get a root shell (rather than having to type sudo for each command, run <tt>sudo su </tt>. | ||
==Part A== | ==Part A== |
Revision as of 17:42, 15 October 2012
A few guidelines:
- Submit your solutions for both Part A and Part B via cuLearn by Friday, October 19th at 11:55 pm. There are 32 points.
- Please answer using a single text file (with a .txt extension). Do not submit doc, docx, pdf, or other formats. Also, please do not submit an archive (zip, tarball, rar) of multiple text files, just upload one. Anything other than a single text file will receive no credit.
- Show all your work. Short answers are not sufficient; you should list any websites or individuals you consult and should document any experiments you conducted. For any question that you could just answer without any external reference or experiment, write "(no work required)" after your answer.
- All submitted code and commands should compile and run. Partial code fragments or explanations may not be given credit. While code may use standard C and UNIX/Linux libraries, no code should rely on external binaries.
- The exercises in this lab require root access on a Linux system. In the labs, you can use the COMP2401-2404 VM with the admin account (password "nimda1234!"). To get a root shell (rather than having to type sudo for each command, run sudo su .
Part A
Be sure to do the following questions in order.
- [2] Run the command truncate -s 1G foo. What is the logical size of foo, and how much space does it consume on disk?
- [2] Run mkfs.ext4 foo. (Say "yes" to operating on a regular file.) What is the logical size of foo now, and how much space does it now consume on disk?
- [1] What command do you run to check the filesystem in foo for errors?
- [1] Run mount foo /mnt. What does this command do?
- [2] Run df. What device is mounted on /mnt? What is this device?
- [2] Run rsync -a -v /etc /mnt. What does this command do? Explain the arguments as well.
- [2] Run umount /mnt. What files can you still access, and what have gone away?
- [1] Run dd if=/dev/zero of=foo conv=notrunc count=10 bs=512. What does this command do?
- [1] Run mount -o loop foo /mnt. What error do you get?
- [2] What command can you run to make foo mountable again? What characteristic of the file system enables this command to work?
Part B
- [6] Create a simple C program to generate a file consisting of the word "Hello", one thousand bytes of blank space (null bytes), and then "world\n", and then another thousand null bytes, such that the file produced consumes the maximum amount of space given its contents.
- [6] Create a C program "mycopy-blocks.c" that takes three arguments: a block size and two filenames A and B as command line arguments. This program should copy the contents of A to B, making B a byte-for-byte copy of A, except that the length of B should be evenly divisible by the block size. The file should be padded with nulls as necessary. Zero bytes in A should consume little to no space in B, however, including the padding.
- [4] How could loopback mounts be useful when working with virtual machines? What conditions must the VM software meet for this to work?