/usb_drive_automount_and_share

A bunch of scripts to allow auto-mount and auto-share with smb of connected USB devices in Linux.

Primary LanguageShell

This is a bunch of scripts I wrote for my NAS (a Raspberry Pi) to enable auto-mounting of usb drives using a udev rule, and automatically share the drive through SMB using samba.

Installation:

* make sure you have samba installed  
* clone the repo  
* cd to the repo  

sudo mv udev/rules.d/10-usb_drives.rules /etc/udev/rules.d/  
sudo mv udev/usb* /etc/udev/  
sudo chmod +x /etc/udev/usb_*  
sudo mv usr_local_sbin/cleanup_devices.sh /usr/local/sbin/  
sudo chmod +x /usr/local/sbin/cleanup_devices.sh  
sudo mv samba/load_usb_shares.sh /etc/samba/  
sudo chmod +x /etc/samba/load_usb_shares.sh  
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig  
sudo mv samba/smb.conf /etc/samba/smb.conf  

add the following line to /etc/rc.local: 
   /usr/local/sbin/cleanup_devices.sh &  
   
sudo reboot  

Caution: The smb.conf provided here sets the drives to be publicly accessible without any password, and guests access the files in the shares as root.

References: