The df command in linux displays the amount of disk space used and available on Linux file systems.
If this command is hanging or not responding, it might be due to one of the following reasons:
1. Network File System (NFS) mounts that are not responding. If you have any networked drives or directories and they are not currently accessible (due to network issues, server downtime, etc.), it could cause the df command to hang while it waits for a response.
2. Disk or File System issues: If your disk is full, or there are file system errors, it could cause the df command to hang.
Get Your Free Linux training!
Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!3. DNS issues: The df command in Linux is used to report file system disk space usage, and it doesn’t directly interact with DNS (Domain Name System). However, when df is hanging, it’s often due to it trying to read a filesystem that is not responding. If you have a mounted network filesystem (for example, NFS, CIFS, or SMB) that relies on a DNS lookup to connect to the remote server, and there’s a problem with DNS resolution, then this could cause df to hang as it waits for the filesystem to respond.
Here’s how you can potentially fix it:
- Use the -l (local) option: This makes df only display local file systems, not networked ones. Run df -l and see if the command still hangs.
- Identify unresponsive NFS mounts: If you have networked drives or directories, make sure they are all currently accessible.
- Check your DNS settings: Make sure your DNS settings are correct. You can usually find these in /etc/resolv.conf. If you’re unsure of what they should be, you can try using Google’s DNS servers (8.8.8.8 and 8.8.4.4) as a test.
- Test your DNS server: You can use the dig or nslookup command to test if your DNS server is working correctly. For example, dig google.com or nslookup google.com. If these commands don’t return a response, it might indicate a problem with your DNS.
- Check your network mounts: If you are using network mounts that rely on DNS, check to see if these are still accessible. You can do this using the mount command to list all mounts, and then cd into the directory and attempt to list the contents using ls. If this hangs, it may indicate that the mount is not responding.
- Unmount problematic mounts: If a network mount is causing the issue, you might need to unmount it. You can do this with the umount command, like sudo umount /path/to/mount. After unmounting, df should run without hanging.
- Check and repair file system: You may need to check your file system for errors. This can typically be done with the fsck command, but be careful as improperly using fsck can result in data loss. You should consult the man page (man fsck) or other reliable resources before proceeding.
- Check your disk usage: If your disk is extremely full, it may be causing issues. You can check disk usage with the du command.
Remember, some commands might require superuser (root) privileges, so you might need to prepend them with sudo, like sudo umount /path/to/mount, and enter your password when prompted.
Some commands might require superuser (root) privileges, so you might need to prepend them with sudo, like sudo df -l or sudo fsck, and enter your password when prompted.
gyu
Wednesday 1st of November 2023
It is indeed a nfs issue for me. I fixed it using your guide. Thanks