Skip Navigation
Text:
Increase font size
Decrease font size

    Disk Usage

    — filed under:

    Monitoring and controlling UNIX disk space use

    Reviewed by John Sopko 10/1/2012

    Your home directory is the directory you find yourself in when you log in on virtually any Linux machine in the department. All users' home directories can be accessed by the path /home/login the actual directory will be in a partition (a part of a disk) of some AFS file server. Note that /home/login is a symbolic link to your AFS space in our cell /afs/cs.unc.edu/home/login.

    1. To find out how much AFS space you are using execute the commands:

    cd (this takes you to your home directory)
    fs exam .

    File . (536884167.1.1) contained in volume 536884167
    Volume status for vid = 536884167 named D3.home.frog
    Current disk quota is 4000000
    Current blocks used are 2051002
    The partition has 71458102 blocks available out of 129319696

     

    The "Current disk quota" and "Current blocks used" are given in 1k blocks, so, for example, "Current blocks used are 2051002" indicates you are using 2051 MegaBytes or 2.051GigaBytes of space and the quote is 4GB.

    2. The disk space of any file or directory can be determined using the Linux "du", (disk usage), command. You can use this at the top level of your home directory to learn how much space that directory takes. The numbers provided are in kilobytes; see "man du" for details. For example, the following du command gives a summary of the size of all directories in your home directory:

    cd
    du -s *

    The results are given in kilobytes. You can use the "-h" (human readable) option to have larger files and directories listed in megabytes or gigabytes. From the output of the du command you can see which directories are taking the most room and cd to those directories and repeat the command to isolate where all your space is being used.

    3. For information on the total space available on the partition where your home directory currently resides, execute the following afs command:

    cd
    fs df

    Suggestions for Limiting File Space

    To reduce your disk space use, you can either remove, truncate, or compress some files. Here are some specific methods:

    1. Simply remove files you are sure you don't need any more.

    2. Copy files you will not need for a good while to DVD. You can buy them at the Student Stores.

    3. An option for files-I'm-going-to-need-soon-but-not-today is to "tar" and "compress" them. Example: You have a "working copy" of a directory called "bigdir":

    % cd bigdir
    % make clean (.o files don't compress well)
    cd ..
    % tar cf bigdir.tar bigdir
    % gzip -v bigdir.tar (creates bigdir.tar.gz)
    % rm -rf bigdir

    Compression is usually 50-60% for text files but can be as high as 90%.

    To get it back

    % cd to-where-you-want-the-software
    % gunzip bigdir.tar.gz
    % tar xf bigdir.tar
    % rm bigdir.tar

    Document Actions