Laufwerk mounten
Ein bestimmtes Laufwerk mounten
Möchte man ein bestimmtes NTFS-Laufwerk mounten wird folgendermaßen vorgegangen:
Feststellen, ob ntfs-3g installiert ist:
dpkg -l | grep ntfs-3g
Wenn nicht, muss das Paket installiert werden:
sudo apt-get install ntfs-3g
Einhängeverzeichnis erstellen (Name ist frei wählbar)
cd /media sudo mkdir usbhdd
Eindeutige UUID des Laufwerks ermitteln:
sudo blkid
Die UUID in der fstab eintragen:
sudo nano /etc/fstab
Am Ende der Datei:
UUID=FFFFFFFFFFFFFFFF /media/usbhdd ntfs-3g defaults 0 0
Adding NTFS to usbmount
- Install usbmount with
sudo apt-get install usbmount
- Install NTFS driver package ntfs-3g with
sudo apt-get install ntfs-3g
- Configure usbmount to mount specified filesystems by opening the usbmount file with
sudo nano /etc/usbmount/usbmount.conf
Change the line MOUNTPOINTS= to
MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3"
In here there is a line called FILESYSTEMS="". Only filesystems specified in this line are mounted via usbmount, so we change it to:
FILESYSTEMS="vfat ntfs fuseblk ext2 ext3 ext4 hfsplus"
If you want usbmount to mount NTFS Filesystems, be sure to add ntfs and fuseblk to the line. NTFS devices are sometimes listed as fusblk by the ntfs-3g package, so those two are the same. I don't really know why though.
Also, if you don't add fuseblk in the configuration, unplugged NTFS Devices will not automatically unmount. They will stay mounted and keep the folder they are mounted to until the device is manually unmounted with unmount /dev/sda1 --> where sda1 could be another variable.
The next important line is FS_MOUNTOPTIONS="".
Here you specify which filesystems should be mounted and how they should be mounted. We change it to (one line, blank before -fstype)
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"
Änderung gegenüber Original (KEIN Zugriff auf USB-Sticks!)
FS_MOUNTOPTIONS="-fstype=ntfs-3g,nls=utf8,umask=007,gid=46 -fstype=fuseblk,nls=utf8,umask=007,gid=46 -fstype=vfat,gid=users,dmask=0007,fmask=0117"
With this the filesystems vfat (fat32) ntfs-3g (NTFS), and fuseblk (NTFS again) are mounted. I think most parameters can stay the same. Again here just add ntfs-3g (add ntfs-3g not ntfs) and fuseblk to be able to mount all NTFS Files. For more filesystems add more lines starting with -fstype=.
Keep NTFS mounted untill device is unplugged
Here is a solution for the problem, when the mounted NTFS drive is only accessible for a few seconds. This fix comes from Christian Weinberger.
Create the file usbmount.rules in /etc/udev/rules.d/ with
sudo nano /etc/udev/rules.d/usbmount.rules
This is the content (enlarge the browser window!)
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"
Create the file usbmount@.service in /etc/systemd/system/ with
sudo nano /etc/systemd/system/usbmount@.service
This is the content:
[Unit] BindTo=%i.device After=%i.device [Service] Type=oneshot TimeoutStartSec=0 Environment=DEVNAME=%I ExecStart=/usr/share/usbmount/usbmount add RemainAfterExit=yes
Now reboot and check with cat /etc/mtab to which folder the usb devices are mounted to. By Default they are mountet to /media/usbstick0.