Total Pageviews

Tuesday 20 March 2018

Tips to Solve Linux "Disk Full Or Can’t Write to the Disk" issues

Is the file system is in read-only mode?

You may end up getting an error such as follows when you try to create a file or save a file:
$ cat > file
-bash: file: Read-only file system
Run mount command to find out if the file system is mounted in read-only mode:
$ mount
$ mount | grep '/ftpusers'
To fix this problem, simply remount the file system in read-write mode on a Linux based system:
# mount -o remount,rw /ftpusers/tmp
Another example, from my FreeBSD 9.x server to remount / in rw mode:
# mount -o rw /dev/ad0s1a /

Am I running out of inodes?

Sometimes, df command reports that there is enough free space but system claims file-system is full. You need to check for the inode which identifies the file and its attributes on a file systems using the following command:
$ df -i
$ df -i /ftpusers/
Sample outputs:

Filesystem      Inodes IUsed   IFree IUse% Mounted on
/dev/sda8      6250496 11568 6238928    1% /ftpusers

So /ftpusers has 62,50,496 total inodes but only 11,568 are used. You are free to create another 62,38,928 files on /ftpusers partition. If 100% of your inodes are used, try the following options:  

Is my hard drive is dying?

I/O errors in log file (such as /var/log/messages) indicates that something is wrong with the hard disk and it may be failing. You can check hard disk for errors using smartctl command, which is control and monitor utility for SMART disks under Linux and UNIX like operating systems. The syntax is:

smartctl -a /dev/DEVICE
# check for /dev/sda on a Linux server
smartctl -a /dev/sda

smartctl -a /dev/DEVICE
# check for /dev/sda on a Linux server
smartctl -a /dev/sda

You can also use “Disk Utility” to get the same information
Fig. 01: Gnome disk utility (Applications > System Tools > Disk Utility)

Note: Don’t expect too much from SMART tool. It may not work in some cases. Make backup on a regular basis.

Is my hard drive and server is too hot?

High temperatures can cause server to function poorly. So you need to maintain the proper temperature of the server and disk. High temperatures can result into server shutdown or damage to file system and disk. Use hddtemp or smartctl utility to find out the temperature of your hard on a Linux or Unix based system by reading data from S.M.A.R.T. on drives that support this feature. Only modern hard drives have a temperature sensor. hddtemp supports reading S.M.A.R.T. information from SCSI drives too. hddtemp can work as simple command line tool or as a daemon to get information from all servers:

hddtemp /dev/DISK
hddtemp /dev/sg0

hddtemp /dev/DISK
hddtemp /dev/sg0


You can use the smartctl command as follows too:

smartctl -d ata -A /dev/sda | grep -i temperature

smartctl -d ata -A /dev/sda | grep -i temperature
How do I get the CPU temperature?

You can use Linux hardware monitoring tool such as lm_sensor to get the cpu temperature on a Linux based system:

Dealing with corrupted file systems

File system on server may be get corrupted due to a hard reboot or some other error such as bad blocks. You can repair corrupted file systems with the following fsck command:

umount /ftpusers
fsck -y /dev/sda8

umount /ftpusers
fsck -y /dev/sda8

See how to surviving a Linux filesystem failures for more info.

Dealing with software RAID on a Linux

To find the current status of a Linux software raid type the following command:

 ## get detail on /dev/md0 raid ##
mdadm --detail /dev/md0

## Find status ##
cat /proc/mdstat
watch cat /proc/mdstat

## get detail on /dev/md0 raid ##
mdadm –detail /dev/md0## Find status ##
cat /proc/mdstat
watch cat /proc/mdstat

Sample outputs:


You need to replace a failed hard drive. You must u remove the correct failed drive. In this example, I’m going to replace /dev/sdb (2nd hard drive of RAID 6). It is not necessary to take the storage offline to repair the RAID on Linux. This only works if your server support hot-swappable hard disk:

## remove disk from an array md0 ##
mdadm --manage /dev/md0 --fail /dev/sdb1
mdadm --manage /dev/md0 --remove /dev/sdb1

# Do the same steps again for rest of /dev/sdbX ##
# Power down if not hot-swappable hard disk: ##
shutdown -h now

## copy partition table from /dev/sda to newly replaced /dev/sdb ##
sfdisk -d /dev/sda | sfdisk /dev/sdb
fdisk -l

## Add it ##
mdadm --manage /dev/md0 --add /dev/sdb1
# do the same steps again for rest of /dev/sdbX ##

# Now md0 will sync again. See it on screen ##
watch cat /proc/mdstat

## remove disk from an array md0 ##
mdadm –manage /dev/md0 –fail /dev/sdb1
mdadm –manage /dev/md0 –remove /dev/sdb1# Do the same steps again for rest of /dev/sdbX ##
# Power down if not hot-swappable hard disk: ##
shutdown -h now## copy partition table from /dev/sda to newly replaced /dev/sdb ##
sfdisk -d /dev/sda | sfdisk /dev/sdb
fdisk -l## Add it ##
mdadm –manage /dev/md0 –add /dev/sdb1
# do the same steps again for rest of /dev/sdbX ### Now md0 will sync again. See it on screen ##
watch cat /proc/mdstat

Dealing with hardware RAID

You can use the samrtctl command or vendor specific command to find out the status of RAID and disks in your controller:

## SCSI disk
smartctl -d scsi --all /dev/sgX

## Adaptec RAID array
/usr/StorMan/arcconf getconfig 1

## 3ware RAID Array
tw_cli /c0 show

## SCSI disk
smartctl -d scsi –all /dev/sgX## Adaptec RAID array
/usr/StorMan/arcconf getconfig 1## 3ware RAID Array
tw_cli /c0 show

No comments:

Post a Comment