CT320 DiskFull Lab                

The Disk is Full                
System administrators frequently have to deal with running out of disk space. The users can’t create files, and they want it fixed, now!                 
(Of course, the files in this lab are much too small to worry about. This is just practice. Multiply all the sizes by a million if that works better for you.)                 
Part 1: Setup                
Do this command, as user ct320.
Note that “-qO-” contains a capital letter “O”, not a zero:
                
wget -qO- https://www.cs.colostate.edu/~ct320/pub/disk-full-lab | sh
Normally, it would be foolish to trust a script that you downloaded from the internet. These are special circumstances.                 
That command will:
- Clean up any files left by an earlier students.
- Create a directory
/tmp/full, and populate it with many files. - Say “
/tmp/full contains 1000 files.” when done.- If it doesn’t say exactly that, get help.
Part 2: Throw more disk space at the problem                
The correct answer is sometimes quite simple: buy another, larger, disk, and move some files to that new disk. Let’s do that:                 
- Create a mount point:
mkdir /tmp/large
- Buy a larger disk, and mount it onto
/tmp/large:- just pretend
- Copy the data (type carefully):
rsync -aH /tmp/full/ /tmp/large/- We use
rsyncrather thancpbecausersynchandles hard links correctly.
- Verify that this file got copied:
ls -l /tmp/full/a/l/e/relax.txt /tmp/large/a/l/e/relax.txt
- Verify that the access and modification times were properly copied:
stat /tmp/full/a/l/e/relax.txt /tmp/large/a/l/e/relax.txt
- Why don’t the change times match?
- Write down the answer to show to the TA.
- Verify that the data in
/tmp/full/w/o/r/crowd.perlgot copied properly.- How did you do this? Write down the answer to show to the TA.
- Verify that
/tmp/full/symlink, a symlink, got copied properly.- How did you do this? Write down the answer to show to the TA.
- Verify that
/tmp/full/hardlink, a hard link, got copied properly.- How did you do this? Write down the answer to show to the TA.
Part 3: Find big files                
New approach. We can’t afford to buy another disk, but perhaps we could still fit if we removed some large files. But, which ones?                 
- Look for files bigger than five kilobytes:
find /tmp/full -type f -size +5k
- How big are they? Let’s improve that command:
find /tmp/full -type f -size +5k -exec ls -ld {} \;
- The columns don’t line up, because
lsis executed many times. Modify the command to executelsonly once:find /tmp/full -type f -size +5k -exec ls -ld {} +
- Add the
-hoption tolsto print human-readable file sizes:find /tmp/full -type f -size +5k -exec ls -ldh {} +
- Now, modify the
-size +5kto get the list down to a dozen files. - Record the command to show to the TA later.
Part 4: Find recent files                
Perhaps we could remove some recently-created files. But, which ones are they?                 
- Find the files changed within a month:
find /tmp/full -type f -mtime -30
- Create a command using
-exec, as above, that generates a long listing of all files in/tmp/fullthat were modified within the past week. - Record the command to show to the TA later.
Part 5: Find recent large files                
- Combine your work from the previous two sections to show all files in
/tmp/fullthat are more than 700kB and were modified within the past two weeks. - Record the command to show to the TA later.
Part 6: Find executable files                
Sometimes, executable files are left over from compiling a program, and can be safely removed. Other times, they’re scripts, and should be kept. This part ignores that possibility.                 
- Create a
findcommand that shows all files in/tmp/fullthat are executable (have the user-execute bit set). - Record the command to show to the TA later.
Part 7: Remove .save files                
- Create a find command that finds all files in
/tmp/fullthat have a suffix of.save. - Use the
-deleteoption offindto create a command that removes those.savefiles. Be careful!- Use
-printinstead of-deleteuntil you get it right.
- Use
- Record the command to show to the TA later.
Credit                
Show your work to the TA.