Disk - How to Run a Checkdisk? - Ask Ubuntu
Disk - How to Run a Checkdisk? - Ask Ubuntu
What tool is the best equivalent of the error checking tool of Windows?
130
disk
1 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
Disks
140 To check for bad sectors check the SMART data, probably the best accessible
by launching the Disks utility (Palimpsest). Even if you don't see any bad
blocks there, launch a self-test to be sure.
2 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
Badblocks
You can also use badblocks
to just check, or to check and fix first write the result to a temporary file:
will check the whole disk and print out all bad blocks encountered on
/dev/sda.
fsck
fsck itself will not help you find bad sectors, worse still, if there are a lot of
bad sectors it can damage your data even more. Use it only when the disk is
healthy.
3 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
2 as a note, on 13.04 you run palimpsest by just running "disks" from the
ubuntu menu, however...I dont' see an option to launch a self-test
(possibly because I have only one drive, and it's the one running
Ubuntu...) – rogerdpack Oct 11, 2013 at 14:04
1 Put info that to list all disks use sudo fdisk -l – Kangarooo Feb 26, 2014 at
4:25
4 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
Throughout this answer I'll assume, that a storage drive appears as a block
device at the path /dev/sdc . To find the path of a storage drive in our
102 current setup, use:
Basic check
• only detects entirely unresponsive media
• safe
S.M.A.R.T. self-test
• adjustable thoroughness
• safe
5 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
thoroughness. This is generally the best option, but usually only available
on (non-ancient) hard disk and solid state drives. Most removable flash
media don't support it.
• How can I check the SMART status of a drive on Ubuntu 14.04 through
16.10?
Read-only check
• only detects some flash media errors
• slow
• safe
To test the read integrity of the whole device without writing to it, we can
use badblocks(8) like this:
This operation can take a lot of time, especially if the storage drive actually
is damaged. If the error count rises above zero, we'll know that there's a
bad block. We can safely abort the operation at any moment (even
forcefully like during a power failure), if we're not interested in the exact
amount (and maybe location) of bad blocks. It's possible to abort
automatically on error with the option -e 1 .
Note for advanced usage: if we want to reuse the output for e2fsck , we
need to set the block size ( -b ) to that of the contained file system. We can
also tweak the amount of data ( -c , in blocks) tested at once to improve
throughput; 16 MiB should be alright for most devices.
6 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
to write. (This will not reliably discover (flash) media, that advertise a larger
size, than they actually have; use Fight Flash Fraud instead.)
• slower
As above, but without restoring the previous drive content after performing
the write test, therefore it's a little faster. Since data is erased anyway,
forceful termination remains without (additional) negative consequence.
7 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
51 fsck /dev/sda1
where /dev/sda1 is the drive you want to check. See 'man fsck' for more
details.
There's also 'badblocks' command which checks a device for, you guessed it,
bad blocks.
Alternatively, you can boot from a Live CD and run the check from there.
8 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
I created the file and rebooted, but it was really quick and there is
nothing new in the boot.log. – Guillaume Coté Aug 29, 2011 at 4:14
fsck just do a very quick check, I tried option -c to check for the bad
block. – Guillaume Coté Aug 29, 2011 at 7:00
fsck -c just said : /dev/sda9: Updating bad block inode. I have no info on
how many bad node and which proportion of the file system they
represent. – Guillaume Coté Aug 29, 2011 at 14:09
9 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
smartctl
IMO smartctl is a better tool. You likely have to install it first
25
Then
to print drive health data, attributes, and available test results. To quit less,
type q . Alternatively
To begin a new short (a few minutes) or long (up to many hours) self test in
background:
GSsmartControl (home page) and Gnome Disks are graphical front ends if
you prefer.
See also
• Smartmontools
• http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html
• http://www.techrepublic.com/blog/linux-and-open-source/using-smartctl-
to-get-smart-status-information-on-your-hard-drives/
10 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
badblocks
22 You can check for badblocks running the command
• -v Verbose mode.
11 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
1 To continue with badblocks later or if you forgot to export the bad sector
to a text file (like me) this answer will help you: superuser.com/a/693000
/218025 – chelder Jan 21, 2015 at 18:22
1 @Private If you have a new question, please use the "Ask a question" link
at the top. – John May 28, 2017 at 3:45
The fsck command fails with btrfs file systems. – Luís de Sousa Feb
28, 2019 at 7:40
12 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
F3 (Fight Flash Fraud) is another option which should additionally detect fake
flash drives (flash drives whose actual capacity is a fraction of advertised
10 capacity):
1. Install F3
3. Write test data to the free space on the drive (check where your drive is
mounted with lsblk )
f3write /media/$USER/D871-DD7C/
f3read /media/$USER/D871-DD7C/
Reference:
• f3 documentation site
• Source code
Badblocks works well but it isn't designed for detecting fake flash drives and
may not report any errors for them.
13 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
You can test-read the entire disk, while showing a progress indicator:
Certain disk problems would manifest as reported I/O errors. This is a bit
nicer than dd due to the progress indicator and because the command-line
interface is a bit more standard and a bit less typo-prone. Note that pv is
basically and enhanced version of cat . It may not be installed by default,
but can be installed with sudo apt-get install pv .
A similar approach is to read the disk with one of the several available tools
that are specifically aware of disk I/O errors -- and have the feature of "trying
hard to rescue data". Search for ddrescue in the package manager.
This will not detect issues that appear only during write access and it
won't report the affected region of the storage medium that one would
need to fix or work around the issue. dd count=1 is also pretty fast
unless the storage medium is utterly broken (or unsupported).
– David Foerster Mar 19, 2017 at 9:17
14 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
If you have a partition that you CAN NOT LOOSE THE DATA follow these
steps
3
1. Determine which partition you want to check for bad sector using the
$fdisk -l commnd
which will determine what are the bad blocks of the given device and
store them on a file called badsectors.txt
3. Now you can use fsck command to tell Ubuntu not to use the bad
sectors mentioned in the badsectors.txt file.
That way life of the hard disk is increased a bit until you get a new one for
replacement.
If you have a complete partition that you want to check for bad physical
sectors and you CAN AFFORD LOOSE ALL DATA on that partition or is
EMPTY follow these steps:
2. sudo gnome-disks
3. Check and double check that there is no important data on that partition
5. Using gnome-disks CREATE a new partition and select the "slow" option
that will check the given space for errors
15 of 16 2024-09-23, 13:39
disk - How to run a checkdisk? - Ask Ubuntu https://askubuntu.com/questions/59064/how-to-run-a-ch...
Does it matter which Ubuntu version it is? Does bionic beaver handle
disk checks differently? – Gabriel Fair Oct 21, 2018 at 19:48
I have not tried this process on that version. – Mauricio Gracia Gutierrez
Oct 22, 2018 at 15:07
16 of 16 2024-09-23, 13:39