Hey guys, I've got a WD Elements HDD with NTFS file system located at /dev/sdb1. Every time I plug it in, it doesn't show up automatically, which means I always have to run the commands `sudo ntfsfix /dev/sdb` followed by `sudo mount /dev/sdb /mnt/user/Elements`. I'm wondering if there's a way to automate this process so I don't have to do it every single time. Also, I'm considering switching the file system to ext4 using `sudo mkfs.ext4 /dev/sdb1`, but I'm worried since I sometimes use this HDD with Windows, albeit not often. Additionally, I'm thinking about writing a .sh script to handle this, checking the device's serial number and executing those commands automatically. Where would I declare these rules? I heard /etc/udev/rules.d/ is a good spot, but I don't want to mess anything up. Thanks for the help!
2 Answers
What are you doing with the drive in between Linux sessions? If you’re using it on Windows, make sure to run a filesystem check and safely eject it before unplugging. Also, if you're dual-booting, make sure Windows Fast Boot or Hibernate features are disabled; you need to perform a proper shutdown instead of letting it sleep. If this is a Linux-only use-case, converting to ext4 could be a good option, but remember, it will erase the drive.
You can automate the mounting of your NTFS partition by adding it to your /etc/fstab file. This will let your system know to mount the drive automatically when you plug it in. Check out this guide on how to do it: [Linux Nightly - Mount NTFS Partition](https://linuxnightly.com/mount-ntfs-partition/). Good luck!
Just to clarify, /etc/fstab is mainly for partitions that you want to mount at boot, but it can still work for your external HDD as long as you get the UUID right. You’ll need to find out the UUID of your HDD using the command `lsblk -f`.
I’m using it on both Windows and Linux. My goal is to find a way to avoid having to run ntfsfix when I reconnect it in Linux since it doesn’t show up automatically right now. Thanks for your insights!