CT320: Network and System Administration

Fall 2019

Disk Full

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:

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:                 

  1. Create a mount point:
    • mkdir /tmp/large
  2. Buy a larger disk, and mount it onto /tmp/large:
    • just pretend
  3. Copy the data (type carefully):
    • rsync -aH /tmp/full/ /tmp/large/
    • We use rsync rather than cp because rsync handles hard links correctly.
  4. Verify that this file got copied:
    • ls -l /tmp/full/a/l/e/relax.txt /tmp/large/a/l/e/relax.txt
  5. 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
  6. Why don’t the change times match?
    • Write down the answer to show to the TA.
  7. Verify that the data in /tmp/full/w/o/r/crowd.perl got copied properly.
    • How did you do this? Write down the answer to show to the TA.
  8. Verify that /tmp/full/symlink, a symlink, got copied properly.
    • How did you do this? Write down the answer to show to the TA.
  9. 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?                 

  1. Look for files bigger than five kilobytes:
    • find /tmp/full -type f -size +5k
  2. How big are they? Let’s improve that command:
    • find /tmp/full -type f -size +5k -exec ls -ld {} \;
  3. The columns don’t line up, because ls is executed many times. Modify the command to execute ls only once:
    • find /tmp/full -type f -size +5k -exec ls -ld {} +
  4. Add the -h option to ls to print human-readable file sizes:
    • find /tmp/full -type f -size +5k -exec ls -ldh {} +
  5. Now, modify the -size +5k to get the list down to a dozen files.
  6. 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?                 

  1. Find the files changed within a month:
    • find /tmp/full -type f -mtime -30
  2. Create a command using -exec, as above, that generates a long listing of all files in /tmp/full that were modified within the past week.
  3. Record the command to show to the TA later.

Part 5: Find recent large files

  1. Combine your work from the previous two sections to show all files in /tmp/full that are more than 700kB and were modified within the past two weeks.
  2. 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.                 

  1. Create a find command that shows all files in /tmp/full that are executable (have the user-execute bit set).
  2. Record the command to show to the TA later.

Part 7: Remove .save files

  1. Create a find command that finds all files in /tmp/full that have a suffix of .save.
  2. Use the -delete option of find to create a command that removes those .save files. Be careful!
    • Use -print instead of -delete until you get it right.
  3. Record the command to show to the TA later.

Credit

Show your work to the TA.