26

In windows os chkdsk /f /r will fix a hdd error automatically.
i have lost access in my laptop though i am able to live boot into my laptop using linux.
I have live boot ubuntu 14.04 and i am in a need to run a command to fix hdd logical errors and fix automatically like in windows we can repair using chkdsk /f /r.
So what is the alternative command for chkdsk /f /r in linux in order to fix hdd error?

2
  • for linux filesystems like ext4, etc, use fsck -a /dev/sdXY where X and Y identify the volume you want checked. eg: fsck -a /dev/sda1 manpages.ubuntu.com/manpages/hardy/man8/fsck.8.html For NTFS volumes, put them on a windows system and use chkdsk. there isn't a safe linux tool for NTFS filesystem repair. Or boot from a windows install disk and use the recovery mode command prompt to run chkdsk. Commented Dec 17, 2014 at 12:56
  • The NTFS filesystem should only be repaired from Windows only, never from Linux. All WinPE/WinRE images have chkdsk
    – JW0914
    Commented Jun 11, 2020 at 15:15

5 Answers 5

14

AFAIK there is no full replacement for chkdsk. You basically have two options

ntfsfix is part of ntfs-3g and should be pre-installed on your Ubuntu LiveMedium. It can fix only some fundamental issues with NTFS, but it always triggers a chkdsk on next Windows-startup.

In some cases this can be enough to get it back to a usable state (dependending if Windows can boot far enough to be able to run chkdsk...).

If this fails, you are left with option Nr 2

  • use a Windows install/recovery CD/DVD/BootStick

from there you can run chkdsk from a commandprompt.

If you don't have any Windows-media available, you can also remove the harddrive and connect it to some other Windows-maschine.

6
  • but how can i plug my laptop hdd to my desktop one :/ btw good idea :)
    – rakibtg
    Commented Dec 17, 2014 at 13:03
  • 1
    nost laptops use SATA drives the same as desktops do, so the only issue is mounting it in the case, which you probably don't need to do since your only hooking it up temporarily. I'd just open the desktop case, jack it into an open sata port, and leave it hanging out the side until the repair was complete. if you really want to mount it though, get a 2.5" -> 3.5" adapter tray or get two 1" rails. Commented Dec 17, 2014 at 13:28
  • 2
    I just wanted a chkdsk to run, didn't have a installation CD handy, and didn't have local administrator credentials (for the built-in recovery options). ntfsfix to mark the disk dirty was enough to kick off the chkdsk. Commented Apr 8, 2016 at 20:33
  • @rakibtg There are so many solutions: use a PE boot disk, windows to go... or Hiren's boot if your computer is old enough. You can even put a Windows installation disk and select recovery. Newer Windows version already has the recovery option builtin and you can just select it from the boot menu
    – phuclv
    Commented Feb 27, 2017 at 9:18
  • 2
    ntfsfix DOES NOT fix anything. It just clears the "dirty filesystem" flag. You WILL corrupt data when enough unfixed errors build up.
    – Stepan
    Commented Dec 19, 2017 at 16:09
8

Linux has no tools to fix NTFS file system.

DO NOT use ntfsfix for fixing your disk. It just removes "dirty FS" flag and you get a false sense of security. After a couple of "fixes" your data becomes unrecoverable.

Do use Windows. Either have a separate HDD with Windows, or install VMware, download Windows vmware image from Microsoft, share raw disk with guest OS and check it from there.

1
  • 2
    So true... I'm one of many who trusted ntfsfix tool and got a bitter taste after a 2nd try already... Used TestDisk to recover the data...
    – Mladen B.
    Commented Aug 17, 2021 at 12:45
3

Although it is not as powerful as Windows' chkdsk, you can use following approach:

sudo ntfsfix /dev/sdXY
sudo ntfsresize -i -f -v /dev/sdXY

After that you will be asked to do it in Windows anyways as Linux doesn't have a powerful equivalent, but this can do a good job.

The ntfsresize command above will check for bad clusters and do a filesystem consistency check.

EDIT: Some people are reporting problems that arise with the use of ntfsfix so refrain from using it unless you have no other option as it may cause data loss.

3
  • 2
    ntfsfix FAKES fixing. It hides the problem under the carpet. Great way to fubar your partition.
    – Stepan
    Commented Dec 19, 2017 at 16:17
  • windows, recovery flash & real os, would freeze when I plugged in an external disk. Getting the error cleared with ntfsfix was exactly what I needed to get into NT (showing up as raw now) so I could run a real chkdsk /r (twice, the first time turned it back into ntfs but corrupted, the second time is making it readable and recovering what it can) on it @Stepan
    – Hashbrown
    Commented Apr 20, 2020 at 7:01
  • updated with a note about that.
    – xdevs23
    Commented Apr 20, 2020 at 14:57
0

Use HBCD. It has a windows interface, as well as windows kernel. You can use CMD (CHKDSK) there.

1
  • 1
    To clarify, this answer suggests using a rescue disk (usb/cd/dvd).
    – Mladen B.
    Commented Aug 17, 2021 at 12:47
-4

Use "fsck" : http://ss64.com/bash/fsck.html

fsck -a /dev/sdXY (sdXY is the "partition" or disk that you want check).

2
  • 4
    fsck does not check NTFS partitions
    – kurdtpage
    Commented Jan 24, 2017 at 6:30
  • 1
    what is the command fsck.ntfs for, then?
    – Mladen B.
    Commented Aug 17, 2021 at 12:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .