Troubleshooting a filesystem could involve finding out which file consumes a lot of disk space, or checking bad blocks on the disk. Below some of the tools that could help us diagnose these issues.

The df utility:

The "df" utility gives us information about the filesystems and their disk space usage in the "use%" column. 
When that value gets close to 100%, it means that the partition is about to get full.

The "du" utility:

The "du" utility allows us to know disk usage for files on the system.
After discovering the partition that is full or almost full using "df -h", we could run the utility "du" on its mount point displayed also in the "df -h" results in the "Mounted on" column.
To display the files in an ascending order according to their size, we use the below command:


Example "/etc":


We can see that the last directory "./apparmor.d" has the biggest size in "/etc". 
Once we find the file or the directory that uses up most of the space, we could, for example, compress it using the "tar" utility and free up space:



The "uncompressed_file" could be a file or a directory.

The badblocks utility:

The "badblocks" utility tests a disk for corrupted blocks:


xxx: could be sda or sdb1 for example.
v: verbose (outputs all the details on the screen)
s: show progress

iostat:

With this command you can see how much data is written to a hard drive per second. We can also see the data read per second from these device:


MB_read/s : number of MBs read per second from /dev/sda .
MB_wrtn/s : number of MBs written per sesond to /dev/sda
MB_read :  number of MBs read from /dev/sda since the last boot.
MB_wrtn : number of MBs written to /dev/sda since the last boot.

Symbolic links:

If we need to create a directory on a partition, but we discover that the partition is full, an alternative would be to create a symbolic link on the "full" partition and to make it point to the directory we want to create (somewhere else, where we have enough disk space). 


We use the below command to create a symbolic link:


s_link_name : full path to symbolic link .

Example:


Creates a symbolic link named "extra" in the "/home/Albert" directory that points to the directory "/usr/var/Albert" on another partition (that have enough space).

Brando Sabatini and Ikbal C ©. Powered by Blogger.