External hard driving auto mounting as read only in Debian

Apr 16th, 2012 | By | Category: Linux / Freebsd

Ok so this happens with NTFS drives sometimes if  you need to run chkdsk on the drive for a corrupt inode, improper unmounts, there’s a whole slew of reasnos.. For example my syslog today shows this:

NTFS-fs error (device sdb1): ntfs_read_locked_inode(): Failed with error code -5. Marking corrupt inode 0x7a036 as bad. Run chkdsk.

Best way to fix this is do as the nice man tells you to and go into windows and chkdsk it, fix the errors and you are good.. However if yuo’re like me you don’t visit windows often and even when you do it’s with a pang of guilt and a big dose of disgust so I’d rather deal with this annoyance in Debian than fix it quickly by going into windows.

To make that annoyance a little less annoying I’ve written a very simple script that just quickly unmounts the poorly mounted drive and then remounts it with all of the options you need to write to it and effectively use it.  

So create a file in ~/.local/bin called whatever, I called it fixexternal.sh and put the following inside


read -p “what dev is it? ” device
read -p “whats the path to the mount? ” mountPath

sudo umount $mountPath
sudo mount -a -t ntfs-3g /dev/$device /media/external -o user,exec,dev,suid,rw,umask=000

echo “All fixed”

you’ll need a directory created in /media called external or you could change that to whatever you want.  755 the file, run it and you are off to the races..


Tags: , , , , , , ,

Leave a Comment