How To Auto-mount USB and External Storage devices with rw in Arch Linux

Posted on 37 views

On fresh installation of Arch Linux, i realized that every time i insert an External hard drive or USB stick, it will mount as read only. This need to be fixed since you basically use External storage as a Backup for data and when mounted with read only permission,there is less you can do with it.

After installing Arch Linux on my Laptop, i configured Nvidia grahics card driver using

Easiest way to Install Nvidia 3D Graphics acceleration driver on ArchLinux

Then i set Fingerprint scanner by following

How to Setup built-in Fingerprint reader authentication with PAM on any Linux

The remaining thing was to auto-mount my External Hard drive so that i could transfer files to and from it smoothly.This can be used for Ubuntu, CentOS and any other Linux distribution with variations only in group names and package to install.This guide is biased on External disk storage with NTFS partition format since it always have problems.  First make sure you have usb_storage kernel module loaded.

sudo modprobe usb_storage

Since i would like to mount and access my External storage devices using standard non-root account, i have to make sure that i am a member of both wheel, disk and storage system groups.Replace josepy with your username.

sudo gpasswd -a $USER wheel
sudo gpasswd -a $USER  storage
sudo gpasswd -a $USER  disk

Additionally, make sure you’re a member of group “users”

sudo gpasswd -a $USER users 

Next step is to install ntfs-3g package; which is an open source implementation of Microsoft’s NTFS file system that includes read and write support.

sudo pacman -S ntfs-3g

If you restart your computer now, External storage devices should be mounted without any problem, both NTFS, VFAT and Ext4 format systems.

Mounting NTFS partition(s) automatically and Manually

Mounting Manually:

Create Mount Point

sudo mkdir -p /mnt/mountpoint
sudo chown $USER /mnt/mountpoint

Replace josepy with your username. The syntax to mount is:

sudo mount -t ntfs-3g /dev/your_NTFS_partition /mount_point 

Since the NTFS partition format i woud like to mount is /dev/sdb1, minw will look like below:

sudo mount -t ntfs-3g /dev/sdb1  /mnt/mountpoint

The mount command  /usr/bin/mount.ntfs will be used.

Mounting Automatically:

NTFS partition(s) can be setup to mount automatically by specifying mount rules in static filesystem configuration (fstab) or by the use of udev rules.

sudo nano /etc/fstab

The add the line below at the end of the file.

/dev/sdb1 /mnt/mountpoint ntfs-3g uid=josepy,gid=users,umask=0022 0 0

/dev/sdb1 with your device location.
josepy with your username
/mnt/mountpoint with mount point you created before.
Options Explained:
umask: Sets file permissions on newly created files.Default umask for root and user is 0022. With this umask,new folders have the directory permissions of 755 and new files have permissions of 644.
uid: The user id number. Specified user will have full access to the partition
gid: Group id of users with full access to partition.

To prevent NTFS entries in /etc/fstab from getting mounted automatically at boot use noauto option.

Mounting USB stick Manually and automatically

Mounting Manually

sudo mkdir /mnt/usbstick
sudo chown $USER /mnt/usbstick

I will then mount it as non-root user,

sudo mount -o gid=users,fmask=113,dmask=002 /dev/sdc1 /mnt/usbstick

Mounting Automatically

If you want non-root users to be able to mount a USB memory stick via fstab, add the following line to your /etc/fstab file:

/dev/sdc1 /mnt/usbstick vfat josepy,noauto,noatime,flush 0 0

Remeber to substitute josepy for your username.
Now any user can mount with

sudo mount /mnt/usbstick

Unmount with

sudo umount /mnt/usbstick

If you would like to  format Partition to NTFS, use

sudo mkfs.ntfs -Q -L Movies  /dev/sb2

Movies is the Partition Label


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.