How-To Geek

The Beginner’s Guide to Linux Disk Utilities

Knowing how to check the condition of your hard disk is useful to determine when to replace your hard disk. In today’s article, we will show you some Linux disk utilities to diagnose the health of your hard disk.

Image by Scoobay

S.M.A.R.T System

Most modern ATA and SCSI hard disks have a Self-Monitoring, Analysis, and Reporting Technology (SMART) system. SMART hard disks internally monitor their own health and performance.

The SMART tool assesses the condition of your hard disk based on: the throughput of the hard disk, the seek errors rate of the magnetic heads, and other attributes that your hard disk manufacturer built into their hard disk.

Most implementations of SMART systems allow users to perform self-tests to monitor the performance and reliability of their hard disks. The simplest way to perform a SMART system test with Ubuntu is using the ‘Disk Utility’ under the ‘System’ > ‘Administration’ menu.

The disk utility lets you see the model, serial number, firmware, and the overall health assessment of the hard disk, as well as whether a SMART system is enabled on the hard disk.

The ‘SMART data’ button lets you see the SMART features of your hard disk.

The ‘Run Self-test’ button lets you initiate a short,extended, or a conveyance self-test on the hard disk.

When you execute these tests, you’ll see a progress meter, letting you see how far through the test is and what the estimated time of completion is.

The ‘Attributed section’ lets you see the errors and self-test information.

File System Check

There some other tools, beside the Disk Utility GUI, that we can use to diagnose the health of our hard disk. The File System Check (FSCK), that only comes as a command line tool, is one of the tools that we often use to check the condition of our hard disk.

You can use the ‘Check Filesystem’ feature of the ‘Disk Utility’ to perform the same check,if you are not a command line geek like us.

Of course, there are some situations where we have to use the command line tool to check our file system. For example when we are using a headless system, when our Linux box fails to boot, or when we simply want to show off our command line Kungfu skills to our friends.

At first, the FSCK command line tool looks like something that only a computer geek can handle; But you will find that FSCK is a very easy tool to use. There is one thing to note before you run FSCK; You need to unmount the file system using the ‘umount’ command. Fixing a mounted file system with FSCK could end up creating more damage than the original problem.

sudo umount /dev/sdb

The FSCK command is pretty straightforward:

sudo fsck -t ext4 /dev/sdb

This command checks an ext4 file system (/dev/sdb) for inconsistencies. You should replace /dev/sdb with your own partition. You can run the ‘fdisk’ command to find out your system partitions:

sudo fdisk -l

Scheduled File System Checks

If you’re using Ubuntu, you will notice that Ubuntu runs an FSCK session when you boot your system from time to time. If you find this scheduled check annoying, you can re-schedule the scan using the ‘tune2fs’ command. Here’s how it typically looks like:

The mount count parameter tells us that Ubuntu scans our hard disk after 33 disk mounts.

We can configure the mount count using the ‘-c’ option:

sudo tune2fs -c 35 /dev/sda1

This command will re-configure Ubuntu to scan our hard disk after 35 hard disk mounts when the system boots.

Note: change ‘/dev/sda1/’ with your own partition

Bad Blocks

A bad sector is a sector on a computer’s disk drive that cannot be used due to permanent damage (or an OS inability to successfully access it), such as physical damage to the disk surface.

There are two ways to detect bad sectors in Linux: you can use the Disk Utility GUI, or if you are a command line geek like us, you can use the badblocks command to check your hard disk for bad sectors:

sudo badblocks -v /dev/sdb1

Badblock will give us the number of bad sectors in our hard disk.

zainul@zainul-laptop:~$ sudo badblocks -v /dev/sdb1
Checking blocks 0 to 97683200
Checking for bad blocks (read-only test): 3134528 done, 3:27 elapsed
3134560 done, 8:33 elapsed
3134561 done, 10:15 elapsed
3134562 done, 11:57 elapsed
3134563 done, 13:39 elapsed
Pass completed, 5 bad blocks found.

You have two options when you see bad blocks. You can either look for a new hard disk, or mark these bad blocks as unusable hard disk sectors. This involves two steps:

First we have to write the location of the bad sectors into a flat file.

sudo badblocks /dev/sdb > /home/zainul/bad-blocks

After that, we need to feed the flat file into the FSCK command to mark these bad sectors as ‘unusable’ sectors.

sudo fsck -l bad-blocks /dev/sdb

FSCK, Badblocks, and Disk Utility are some of the disk utilities that we often use to scan our hard disks. Do share with the other fellow readers if you know other Linux disk utilities to scan hard disks.

Zainul spends his time trying to make technology more productive, whether it’s Microsoft Office applications, or learning to use web applications to save time.

  • Published 12/15/10

Comments (14)

  1. David Levine

    I really appreciate the Linux knowledge that gets shared on this site. It seems like some of the writers use it as their main OS, which is amazing. I’m messed around with a few different Linux distros, but I’ve never disciplined myself to keep using it. I just don’t feel like putting the “work” into it. However, I know it’s a great OS and many people really love it.

  2. Robert

    I agree – having these little tutorials posted is great :) It gives me more reason to try and have a dedicated Linux box in my home (though, it’s rather hard to pry myself away from Windows 7 – games, photoshop, dreamweaver … and easier to do a few other things). However, this definitely gives me cause to always keep a Linux LiveCD handy at work ^_^

  3. asdf-chan

    – I just don’t feel like putting the “work” into it. –

    If you play around with Ubuntu there is nothing to work yourself into. Only things you might want to know is how to use your packetmanager like apt in the CLI, but even that is not necessary on Ubuntu because of the GUI that you can use. If something f**ks up you probably need to search for a solution on the net like any other problem that occurs on other operating systems that you are not familiar with.

  4. jerrybee

    I really appreciate these “bite-size” Linux tutorials as an easy way to learn more about running Linux. I’ve tried many different Linux distros over the past 10 (?) years, dual-booting with Windows 2000 in order to run the few programs that require it. A comment to those folks who feel that Linux is difficult: you should have tried it 10 years ago — today’s Linux is a piece of cake compared to the effort required back then. Another thought is: if you’d started out using Linux and had used it for a few years now, you’d find that learning Windows today was difficult — like much of life, it depends on the perspective.

    I’ve settled in on the Debian-origin distros, such as Ubuntu and Mint, the latter being the one I spend most of my time in. One good site to visit regularly to see what’s happening in the Linux world is , where you can download just about any distro to play with.

    And to those who’d like to try Linux but hesitate to do so, I’d recommend they set up a dual-boot with Mint, continue to do your work in Windows where you’re comfortable, but start spending some time in Mint (or Ubuntu or whatever) , get a book such as “Ubuntu Linux for Non-Geeks” which does a fantastic job of introducing the newcomer, and take your time.

    My motivation to try Linux was based on my dislike of any one company having almost complete control of a market. To those who feel the same way, try Linux and you’ll find the route to escape from that domination.

  5. hanki

    Yes, HTG, it is much appreciated your Linux coverage. I have run Ultimate Edition for almost two years on family computer. Teenagers love the GUI and not having lock-up’s all the time. My daughter the geek figured out how to use Open Office and convert to MSOff. for her homework. Really appreciate the help. For newbbies I’m gonna plug a great OS (it’s free after all) Google up Unity OZ and try that out. A great starter system with lots of forum help. Thanks again.

  6. Zainul Franciscus

    We’re glad that you like our Linux articles. We are trying to present Linux as a friendlier OS to everyone so that we all can get the most out of Linux. Please feel free to drop us a line if you have any question on Linux or any other technical stuff.

    Stay tune for more Linux articles =)

  7. Kalyan

    I have switched to UBUNTU on two of my computers (a desktop to begin with and now on my old HP Win-XP laptop) about a month back.

    It is an amazing experience as everyday I realize how good OS this UBUNTU Linux is!

    Now I have to convince my son (who has a PhD in computer science and did his undergraduate project in Red Hat Linux!) and my daughter (who is doing medicine in Cambridge) to switch to this great UBUNTU OS! This could be much more difficult than learning to use UBUNTU! They both think it is bad idea!

    Any suggestions – how to convince them?

    I can see this site would be a great place for me to learn Linux!

    Thanks to to all the contributors for their sharing!


  8. VoiceOfWisdom

    That drive is so fucked.

  9. Bhaskar Chowdhury

    @Kalyan : You son has a better idea about GNU/Linux if you try to do so,you might get different reaction about it ;as he should .And about your daughter I am not sure.But having said that UBUNTU has a different learning curve, and I personally not so comfortable with it.Yes I am living with GNU/Linux for almost a decade now and running serveral GNU/Linux distro at workplace and personally.

    Ubuntu is derived from Debian, and it has has it own way of managing things which not matched with other GNU/Linux variants.

    Tell your son about Gentoo, Arch,Debian and Slackware and of course Fedora and you will see your sons eyes will be enlighten with curiocity.

    Convincing your daughter is altogether different story..pls look at for find a correct variant of GNU/Linux ,which help mediacal students.I am sure there will be some.A distribution called openSUSE might help..I am not sure.


  10. Zainul Franciscus

    @Kalyan After so much peer pressure from my friends due to the fact that I am the only one left among my friends who does not know Linux, and now to mention how amazingly slow my PC was with Windows, I decided to install Linux. It has been the right thing to do and I have been having so much fun using Linux.

    We’re look forward to write more Linux articles for our readers. Please feel free to drop us an email or ask your question in the forum if you need any help with Linux.

    Thank you for the comment and keep subscribing to our site =)

  11. Andrei Sun


    I have a question: Smart test shows that my hard disk has some errors, and it shows a warning: number of sectors in waiting (i translated from Romanian) – value 4 sectors. I noticed that after i open my computer, it signs out of my account. This happened on 10.10 and now in 11.04. What should i do? Thank you very much, Andrei Sun

  12. Donald

    Andrei Sun

    i would use ddrescue to ghost it to a new hard drive

  13. James

    If I do the Bad Block thing in Ubuntu, format the drive and install Windows on it, will the drive still ignore the bad blocks it found with Ubuntu?

  14. Nicolas Grilly

    Hello and thanks for your post!

    Are you sure the following command:
    sudo badblocks /dev/sdb > /home/zainul/bad-blocks

    should not be replaced by this:
    sudo badblocks -c 4096 /dev/sdb > /home/zainul/bad-blocks

    fsck expects block numbers to be based on the actual blocksize of the filesystem.

    Of course, 4096 must be replaced by the actuel blocksize of your filesystem (you can get it using dumpe2fs).

    Am I missing something?

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!