6

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!

5
  • 2
    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.
    – Jeff Schaller
    Oct 14, 2017 at 22:36
  • 1
    Boot the Mini Windows Xp, open a Command prompt and run chkdsk.exe NTFS_DRIVE: /F /V
    – bashianer
    Oct 15, 2017 at 5:13
  • 3
    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.
    – Jeff Schaller
    Oct 15, 2017 at 12:54
  • I'm not a native English speaker, but my intentions should have become clear.
    – bashianer
    Oct 18, 2017 at 11:49
  • sudo ntfsfix /dev/sdxY Jun 18, 2018 at 4:36

2 Answers 2

10

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.

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:

ntfsfix /dev/sdxY

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

1
  • 3
    Truism! That's why I asked explicitly for chkdsk.exe.
    – bashianer
    Oct 19, 2017 at 13:56
2

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:

dmesg

or

journalctl

or

less /var/log/syslog

note device and partition:

USB_STICK=  # e.g. /dev/sdb

USB_STICK_PARTITION=${USB_STICK}1

recheck it:

/sbin/fdisk -l $USB_STICK

check if mounted:

mount | grep $USB_STICK

if yes: unmount device or partition(s)

sudo umount ${USB_STICK}{,{1..4}}

clear it:

sudo dd if=/dev/zero of=$USB_STICK count=10000

download syslinux:

wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz

extract it:

tar xzf syslinux-6.03.tar.gz

write master boot record:

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 

format it:

sudo mkfs.vfat -n MINIXP -v $USB_STICK_PARTITION

make it bootable:

sudo syslinux-6.03/bios/linux/syslinux --install $USB_STICK_PARTITION

copy content:

mkdir usb

sudo mount -o uid=$UID $USB_STICK_PARTITION usb

cp -rv iso/* usb

create config file:

echo "default minixp\nlabel minixp\nboot /HBCD/grldr" >usb/syslinux.cfg

make MiniXP default:

sed -i '/^default/s|/default|2|' usb/HBCD/menu.lst

tidy up:

sudo umount $USB_STICK_PARTITION

sudo umount iso

cd ..
rm -r d1

done!

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!

9
  • 1
    Hiren's boot CD is a pirated copy of Windows with additional pirated shareware tools and a bunch of freeware as well. Oct 15, 2017 at 0:44
  • Who cares? For years I was a Windows Hacker too. (In remembrance of SoftICE...)
    – bashianer
    Oct 15, 2017 at 9:18
  • 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. Oct 15, 2017 at 9:55
  • 3
    @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.
    – terdon
    Oct 15, 2017 at 12:36
  • 2
    @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.
    – terdon
    Oct 15, 2017 at 14:00

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