systemd: How do I automount a USB filesystem using /etc/fstab?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
11
down vote

favorite
1












I want my USB filesystems to automount when I connect the device.



How do I setup automount with systemd via /etc/fstab?










share|improve this question



























    up vote
    11
    down vote

    favorite
    1












    I want my USB filesystems to automount when I connect the device.



    How do I setup automount with systemd via /etc/fstab?










    share|improve this question

























      up vote
      11
      down vote

      favorite
      1









      up vote
      11
      down vote

      favorite
      1






      1





      I want my USB filesystems to automount when I connect the device.



      How do I setup automount with systemd via /etc/fstab?










      share|improve this question















      I want my USB filesystems to automount when I connect the device.



      How do I setup automount with systemd via /etc/fstab?







      systemd autofs automounting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 28 '17 at 19:17









      Martin Schröder

      6041725




      6041725










      asked Feb 23 '17 at 7:39









      Tom Hale

      5,89922576




      5,89922576




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          11
          down vote



          accepted










          Connect your device and find out the UUID of the filesystem by running either blkid or lsblk -f.



          Add a line to /etc/fstab such as:



          UUID=05C5-A73A /mnt/32GBkey vfat noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=2,x-systemd.device-timeout=2


          Then execute:



          systemctl daemon-reload && systemctl restart local-fs.target


          Explanation:




          • noauto - don't mount with mount -a


          • nofail - boot will continue even if this mount point is not mounted successfully


          • x-systemd.automount tell systemd to automount this etnry


          • x-systemd.idle-timeout=2 - wait 2 seconds before unmounting the device after last usage


          • x-systemd.device-timeout=2 - wait only 2 seconds before giving No such device if the device is not connected

          Note:



          1. There are no quotes around the UUID number.

          2. The mount point directory doesn't need to exist - it will be created

          For more information about the options available, see systemd.mount(5)






          share|improve this answer


















          • 2




            Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
            – Fiximan
            Feb 23 '17 at 9:52










          • /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
            – Tom Hale
            Feb 23 '17 at 10:28










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f347006%2fsystemd-how-do-i-automount-a-usb-filesystem-using-etc-fstab%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          11
          down vote



          accepted










          Connect your device and find out the UUID of the filesystem by running either blkid or lsblk -f.



          Add a line to /etc/fstab such as:



          UUID=05C5-A73A /mnt/32GBkey vfat noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=2,x-systemd.device-timeout=2


          Then execute:



          systemctl daemon-reload && systemctl restart local-fs.target


          Explanation:




          • noauto - don't mount with mount -a


          • nofail - boot will continue even if this mount point is not mounted successfully


          • x-systemd.automount tell systemd to automount this etnry


          • x-systemd.idle-timeout=2 - wait 2 seconds before unmounting the device after last usage


          • x-systemd.device-timeout=2 - wait only 2 seconds before giving No such device if the device is not connected

          Note:



          1. There are no quotes around the UUID number.

          2. The mount point directory doesn't need to exist - it will be created

          For more information about the options available, see systemd.mount(5)






          share|improve this answer


















          • 2




            Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
            – Fiximan
            Feb 23 '17 at 9:52










          • /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
            – Tom Hale
            Feb 23 '17 at 10:28














          up vote
          11
          down vote



          accepted










          Connect your device and find out the UUID of the filesystem by running either blkid or lsblk -f.



          Add a line to /etc/fstab such as:



          UUID=05C5-A73A /mnt/32GBkey vfat noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=2,x-systemd.device-timeout=2


          Then execute:



          systemctl daemon-reload && systemctl restart local-fs.target


          Explanation:




          • noauto - don't mount with mount -a


          • nofail - boot will continue even if this mount point is not mounted successfully


          • x-systemd.automount tell systemd to automount this etnry


          • x-systemd.idle-timeout=2 - wait 2 seconds before unmounting the device after last usage


          • x-systemd.device-timeout=2 - wait only 2 seconds before giving No such device if the device is not connected

          Note:



          1. There are no quotes around the UUID number.

          2. The mount point directory doesn't need to exist - it will be created

          For more information about the options available, see systemd.mount(5)






          share|improve this answer


















          • 2




            Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
            – Fiximan
            Feb 23 '17 at 9:52










          • /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
            – Tom Hale
            Feb 23 '17 at 10:28












          up vote
          11
          down vote



          accepted







          up vote
          11
          down vote



          accepted






          Connect your device and find out the UUID of the filesystem by running either blkid or lsblk -f.



          Add a line to /etc/fstab such as:



          UUID=05C5-A73A /mnt/32GBkey vfat noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=2,x-systemd.device-timeout=2


          Then execute:



          systemctl daemon-reload && systemctl restart local-fs.target


          Explanation:




          • noauto - don't mount with mount -a


          • nofail - boot will continue even if this mount point is not mounted successfully


          • x-systemd.automount tell systemd to automount this etnry


          • x-systemd.idle-timeout=2 - wait 2 seconds before unmounting the device after last usage


          • x-systemd.device-timeout=2 - wait only 2 seconds before giving No such device if the device is not connected

          Note:



          1. There are no quotes around the UUID number.

          2. The mount point directory doesn't need to exist - it will be created

          For more information about the options available, see systemd.mount(5)






          share|improve this answer














          Connect your device and find out the UUID of the filesystem by running either blkid or lsblk -f.



          Add a line to /etc/fstab such as:



          UUID=05C5-A73A /mnt/32GBkey vfat noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=2,x-systemd.device-timeout=2


          Then execute:



          systemctl daemon-reload && systemctl restart local-fs.target


          Explanation:




          • noauto - don't mount with mount -a


          • nofail - boot will continue even if this mount point is not mounted successfully


          • x-systemd.automount tell systemd to automount this etnry


          • x-systemd.idle-timeout=2 - wait 2 seconds before unmounting the device after last usage


          • x-systemd.device-timeout=2 - wait only 2 seconds before giving No such device if the device is not connected

          Note:



          1. There are no quotes around the UUID number.

          2. The mount point directory doesn't need to exist - it will be created

          For more information about the options available, see systemd.mount(5)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 13 at 11:32









          Philippe Gachoud

          363210




          363210










          answered Feb 23 '17 at 7:39









          Tom Hale

          5,89922576




          5,89922576







          • 2




            Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
            – Fiximan
            Feb 23 '17 at 9:52










          • /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
            – Tom Hale
            Feb 23 '17 at 10:28












          • 2




            Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
            – Fiximan
            Feb 23 '17 at 9:52










          • /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
            – Tom Hale
            Feb 23 '17 at 10:28







          2




          2




          Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
          – Fiximan
          Feb 23 '17 at 9:52




          Is there any advantage to this over a udev rule? This seems very specific for a single device (given the UUID-dependency of fstab), where a udev rule could cover e.g. any USB flash drive.
          – Fiximan
          Feb 23 '17 at 9:52












          /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
          – Tom Hale
          Feb 23 '17 at 10:28




          /etc/fstab doesn't have the dependency you assert, accepting LABEL=..., PARTLABEL=... and good old /dev/usbkey. You could always setup a udev rule to make /dev/usbkey, but I don't know how to mount using udev alone.
          – Tom Hale
          Feb 23 '17 at 10:28

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f347006%2fsystemd-how-do-i-automount-a-usb-filesystem-using-etc-fstab%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay