Last active
January 21, 2022 21:18
-
-
Save UedaTakeyuki/432562e98ce00c8fb036e18861e7e515 to your computer and use it in GitHub Desktop.
NTFS & USB automounter setup script on RPi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NTFS | |
sudo apt-get install fuse ntfs-3g | |
# usb automount | |
# | |
# http://raspberrypi.stackexchange.com/questions/41959/automount-various-usb-stick-file-systems-on-jessie-lite | |
sudo apt-get install usbmount | |
sudo sed -i 's|FILESYSTEMS="vfat ext2|FILESYSTEMS="vfat ntfs fuseblk ext2|g' /etc/usbmount/usbmount.conf | |
sudo sed -i 's|FS_MOUNTOPTIONS=""|FS_MOUNTOPTIONS="-fstype=ntfs-3g,nls=utf8,umask=007,gid=46 -fstype=fuseblk,nls=utf8,umask=007,gid=46 -fstype=vfat,gid=1000,uid=1000,umask=007"|g' /etc/usbmount/usbmount.conf | |
cat << 'EOS1' > /etc/udev/rules.d/usbmount.rules | |
KERNEL=="sd*", DRIVERS=="sbp2", ACTION=="add", PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c" | |
KERNEL=="sd*", SUBSYSTEMS=="usb", ACTION=="add", PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c" | |
KERNEL=="ub*", SUBSYSTEMS=="usb", ACTION=="add", PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c" | |
KERNEL=="sd*", ACTION=="remove", RUN+="/usr/share/usbmount/usbmount remove" | |
KERNEL=="ub*", ACTION=="remove", RUN+="/usr/share/usbmount/usbmount remove" | |
EOS1 | |
cat << EOS2 > /etc/systemd/system/usbmount@.service | |
[Unit] | |
BindTo=%i.device | |
After=%i.device | |
[Service] | |
Type=oneshot | |
TimeoutStartSec=0 | |
Environment=DEVNAME=%I | |
ExecStart=/usr/share/usbmount/usbmount add | |
RemainAfterExit=yes | |
EOS2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment