Chkdsk ntfs in linux

chkdsk /f /r alternative in ubuntu linux

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?

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.

The NTFS filesystem should only be repaired from Windows only, never from Linux. All WinPE/WinRE images have chkdsk

5 Answers 5

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

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.

Источник

NTFS Repair — chkdsk from Linux [closed]

How can I run Window’s chkdsk.exe from my Linux USB Rescue Stick to fix an NTFS drive? This is for a media player. I’m long done with Windows, but am forced to hold an installation available on my netbook to fix this disk now and then! I want to get rid of this otherwise useless partition. The Linux tool, ntfsfix from ntfs-3g, is no replacement for Windows chkdsk!

I see that you have a solution to share, which is fine, but the answer you’ve given does not answer «run chkdsk.exe from my USB stick to fix an NTFS drive». It shows how to create a particular USB stick.

What you’ve created in your answer is not a «Linux Rescue USB stick». It’s using Linux to create some sort of Windows recovery disk that can run a Windows-based chkdsk on a Windows partition. The only on-topic part of this IMHO is the Linux steps to create the device. Please edit your question to focus on that.

2 Answers 2

Unless you consider running chkdsk.exe under wine or virtualisation, Linux cannot run it. There is a linux compatible tool that can be used to fix ntfs partitions that is called ntfsfix and is available on most distribution repositories.

Читайте также:  Linux cut first characters

It is NOT chkdsk for Linux and may not produce results compatible with Microsoft Windows, however it is able to fix some common ntfs possible problems. It may lose your data while attempting repairs, even though chkdsk may do that too. Example usage:

Where you should replace xY with the appropriate letters for the partition you want to fix.

I use the MiniXP on Hiren’s BootCD. The included version 5.1.2600.0 is a little outdated but does the job.

With this I’m able to obtain the full functionality of chkdsk.exe with merely another boot entry on my rescue stick!

Here is my manual, step-by-step, linux-only approach with an emtpy usb stick:

start a bash session in a terminal

mkdir /tmp/d1 && cd /tmp/d1 wget http://www.hirensbootcd.org/files/Hirens.BootCD.15.2.zip unzip Hirens.BootCD.15.2.zip mkdir iso sudo mount -o loop,ro,uid=$UID Hiren\'s.BootCD.15.2.iso iso 

plug in the usb stick you want to use: careful! everything on it will be deleted!

determine the device of the stick:

note device and partition:

USB_STICK= # e.g. /dev/sdb USB_STICK_PARTITION=$1 

if yes: unmount device or partition(s)

sudo dd if=/dev/zero of=$USB_STICK count=10000 
wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz 
sudo dd if=syslinux-6.03/bios/mbr/mbr.bin of=$USB_STICK 

create a FAT32 partition, e.g.

echo ,,c,\* | sudo sfdisk $USB_STICK 
sudo mkfs.vfat -n MINIXP -v $USB_STICK_PARTITION 
sudo syslinux-6.03/bios/linux/syslinux --install $USB_STICK_PARTITION 
mkdir usb sudo mount -o uid=$UID $USB_STICK_PARTITION usb cp -rv iso/* usb 
echo "default minixp\nlabel minixp\nboot /HBCD/grldr" >usb/syslinux.cfg 

make MiniXP default:

sed -i '/^default/s|/default|2|' usb/HBCD/menu.lst 
sudo umount $USB_STICK_PARTITION sudo umount iso cd .. rm -r d1 

I deleted Parted Magic and the big virus stuff and got it down to 200MB on my Rescue Stick.

Adjust this procedure appropriate for your own rescue stick!

Hiren’s boot CD is a pirated copy of Windows with additional pirated shareware tools and a bunch of freeware as well.

Piracy is not admitted on this site. You are free to be a criminal elsewhere given there are plenty of legal ways to create a bootable Windows disk.

@AndreaLazzarotto actually, there are no such rules on SE. In fact, the rule is kind of the opposite: enforcing laws is not our job, nor are we qualified to do it. Nor can we know the legality of actions in the jurisdiction of each user (also see 1, 2). In any case, this post isn’t advocating piracy! You can perhaps argue that the tool mentioned is breaking licences, but the use it is being put to in this answer is legitimate.

@AndreaLazzarotto the policy you mention is specific to Super User and something they decided on their meta, not an SE-wide decision. I am very simply not qualified to judge whether Hiran’s boot CD is illegal so cannot opine on that. The answer would indeed benefit from a mention of chckdisk , yes, but that is another issue. Presumably, you can run it from the USB created. As for the attitude, again, that’s not relevant to the technical aspects of the answer. The general stance on possibly illegal activities has indeed been discussed and the consensus is: we cannot enforce laws.

Источник

fsck an ntfs drive in Linux

Yes. This was handled by fsck on some releases. If the partition is not listed in /etc/fstab , then you will likely need to tell it the partition type. I’ve used this from a Linux CD to recover a partition Windows wouldn’t boot from.

Читайте также:  Libreoffice linux deb x86

Based on the comments below, the actual fixing is done by the ntfsfix program. It should be available, even if there is no program to run a fsck on an NTFS file system.

Although as noted in the man page for ntfsfix/fsck.ntfs, it is not a Linux version of chkdsk and only checks for certain kinds of obvious problems on the disk.

I assume from the above comment that fsck.ntfs was at some point handled by ntfsfix . Comments on a lower post indicate this may not be workable now as their arguments are not compatible. Anyway, in Debian 8.2, fsck.ntfs does not exist — but ntfsfix does and was able to fix a corrupted MFT I encountered. Thanks @SabreWolfy for the hint.

Unfortunately the ntfsfix tool is very limited compared to Microsoft’s chkdsk. Try to get a Windows install going — preferably with the newest version of Windows as Microsoft is presumably constantly improving chkdsk (I hope..) New versions of Windows are often available for free as trials. If the problem is in a USB disk you can try installing Windows in something like VirtualBox and give the VM control of the USB device.

Or use Ultimate Boot CD for Windows. It’s a live Windows XP CD with lots of recovery tools. That’s how I solved my problem (corrupted NTFS partition). I tried using the ntfsck program included in the Parted Magic live USB, but I got an error saying Boot sector: bad NTFS magic. Segmentation fault .

maybe limited for some people, but it fixed my corrupted MFT just fine 🙂 [until the next time, perhaps! i’m not sure about this drive. ]

Hyper-V Server is a completely free (beer) but heavily cut-down version of Windows that’s designed for running VMs. The installer should contain all the usual utilities like chkdsk / diskpart , etc.

Take care using Windows ‘chkdsk /f’ on an NTFS used by Linux. I just followed this advice to fix errors on my external 2TB backup drive. It deleted the names of 268 files and directories (incl. all my incr. backups) due to invalid characters (from NTFS viewpoint — most often ‘:’ used in timestamps). I reverted it all using the log file, but it took half a day of coding. Some but not all Linux system-calls block writing such invalid names on an NTFS. I use rsync for backups, which silently copies such invalid filenames — normally useful, until you need to fix other problems on the disk.

In my case, none of fsck & ntfsfix could fix the issue of my external NTFS mobile disk.

I end up to boot into windows os, and use follow steps to fix the disk issue.

  • Check the identifier of the bad disk. e.g g
  • Open the «cmd» terminal of windows.
  • Input chkdsk : /f to fix it.
    Where is the identifier, e.g chkdsk d: /f
  • Then it would be fixed within seconds (For a disk of size 1Tb).
Читайте также:  Fusion 360 linux mint

After years, finally I found something that windows can do easily, but linux can’t 😉

@Update — vm solution

You can also create a windows vm (e.g win 7), then mount the mobile disk to windows vm, then you can also use chkdsk to fix the disk, it’s similar as boot into a windows machine.

I’d recommend using flag /x (unmount) for enforcing preventing access to the drive. Help manual says using /x implies also /f , so it helps for doing fixes the same way Linux does ( fsck requires drives being unmounted).

fsck /dev/sdg1 fsck from util-linux 2.21.2 Mounting volume. OK Processing of $MFT and $MFTMirr completed successfully. Checking the alternate boot sector. FIXED NTFS volume version is 3.1. NTFS partition /dev/sdg1 was processed successfully. 

On fedora 22, there is another binary :

lrwxrwxrwx. 1 root root 13 May 22 22:13 /usr/sbin/fsck.ntfs -> ../bin/ntfsck 

If you have NTFSProgs installed, you should be able to run fsck.ntfs or fsck -t ntfs to fsck an NTFS drive.

Running Debian 6.0.3, just installed ntfsprogs, no fsck.ntfs installed, and when running fsck with -t ntfs, get «fsck.ntfs not found». So don’t think the two are related.

@ZayneSHalsall In Debian, it happens to be a symlink to ntfsfix which is in ntfsprogs . I guarantee you that you will be able to run ntfsfix if ntfsprogs installed properly.

Newer versions of Debian and Ubuntu don’t have this symlink. You can make it yourself, but the problem is that ntfsfix has a completely different set of arguments to the standard fsck ones. It’s better to make fsck.ntfs (and fsck.ntfs-3 ) a script containing exec ntfsfix $ (with a shebang of #!/bin/bash ).

@squircle thank you man sudo ntfsfix /dev/sda1 fixed my issue. fsck.ntfs -f /dev/sda1 and fsck -t ntfs -f /dev/sda1 exited early with fsck from util-linux 2.31.1

Using a fsck.ntfs solved my similar problem in a Windows ntfs partition + Ubuntu 20.XX LTS partition (can’t remember exact version):

NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS sda ├─sda1 ├─sda2 vfat FAT32 1950-4B8D 505,9M 1% /boot/efi └─sda3 ext4 1.0 29ee8e5b-457e-4610-a503-c8142cc40d68 sdb └─sdb1 ntfs HDD 42AEC908AEC8F607 sdc ├─sdc1 ntfs Recuperação 04C0478BC0478242 └─sdc2 ext4 1.0 8be461e1-7470-45f6-844c-7559ed2769e9 380,6G 8% / 

As you can see, I need to fix my HDD labeled driver (42AEC908AEC8F607), so ln -s /bin/ntfsfix /sbin/fsck.ntfs and after an fsck /dev/sdb1 solved for me, even loggin windows ‘refuse to mount’ FAILED:

root@bruno-andrade:/home/bruno# fsck /dev/sdb1 fsck from util-linux 2.37.2 Mounting volume. The disk contains an unclean file system (0, 0). Metadata kept in Windows cache, refused to mount. FAILED Attempting to correct errors. Processing $MFT and $MFTMirr. Reading $MFT. OK Reading $MFTMirr. OK Comparing $MFTMirr to $MFT. OK Processing of $MFT and $MFTMirr completed successfully. Setting required flags on partition. OK Going to empty the journal ($LogFile). OK Checking the alternate boot sector. FIXED NTFS volume version is 3.1. NTFS partition /dev/sdb1 was processed successfully. 

Thanks to @tanguy in his answer: fsck an ntfs drive in Linux

Источник

Оцените статью
Adblock
detector