Results 1 to 8 of 8

Thread: How do I prevent automount of any external devices

  1. #1
    Join Date
    Sep 2006
    Beans
    16

    Post How do I prevent automount of any external devices

    I'm trying to create a LiveCD (using Kubuntu Hardy) for my employer, and I need to know if there is a way to prevent the LiveCD from mounting any other devices (HDD, CD/DVD,USB drive, etc). My employer requires this for security and liability purposes, and is just about the last bridge I need to cross before it is a viable solution.

    Thanks!

  2. #2
    Join Date
    Oct 2005
    Location
    Carterville, IL, USA
    Beans
    211
    Distro
    Ubuntu UNR

    Re: How do I prevent automount of any external devices

    I'm not 100% sure if this will work, but I think you should remove some lines in your /etc/fstab. Removing the line with your cdrom device in it will keep it from auto-mounting (I think). However, if it's a LiveCD, you can't really use the cdrom for anything anyway...

    As far as auto-mounting usb devices, I think there's a line in the default fstab that says something about usbfs. I'm not 100% sure because I'm at work (on Windows) right now, but I think it's there. I'd be willing to bet that removing that will prevent anything connected through usb from being mounted automatically.

    I haven't tried any of this myself, though, so I can't tell you that it'll work for sure. It can't hurt to make a backup of your /etc/fstab and give it a try, though.

    Also, you can do this through the "Removable Drives and Media" preferences in GNOME, which makes it seem like there is a per user, no-root-access-needed way of doing this (even in KDE), but editing your /etc/fstab will be permanent and system-wide (which is probably what you want).

    Let me know if this works for you.

    - Derrick

  3. #3
    Join Date
    Oct 2005
    Location
    Carterville, IL, USA
    Beans
    211
    Distro
    Ubuntu UNR

    Re: How do I prevent automount of any external devices

    After re-reading your post, I think I mis-understood you. Doing what I said will keep it from automatically mounting your cdrom/usb-drives, but you can still manually mount them. I don't think there's a way to prevent manual mounting of drives.

    Maybe someone else will a little more Linux knowledge will prove me wrong.

    - Derrick

  4. #4
    Join Date
    Oct 2007
    Location
    ISS
    Beans
    1,429

    Re: How do I prevent automount of any external devices

    Quote Originally Posted by bravespear View Post
    I'm trying to create a LiveCD (using Kubuntu Hardy) for my employer, and I need to know if there is a way to prevent the LiveCD from mounting any other devices (HDD, CD/DVD,USB drive, etc). My employer requires this for security and liability purposes, and is just about the last bridge I need to cross before it is a viable solution.

    Thanks!
    It's udev which generates devices in /dev. Udev rules live in

    /etc/udev/rules.d

    You can change the rules to achieve whatever you want. Google udev and find some guides about it. Start with these:

    http://www.archive.org/details/Hamps...UserGroup_udev
    http://reactivated.net/writing_udev_rules.html
    http://en.wikipedia.org/wiki/Udev

  5. #5
    Join Date
    Sep 2006
    Beans
    16

    Re: How do I prevent automount of any external devices

    Thanks everyone for pointing me in the right direction!

  6. #6
    Join Date
    Feb 2007
    Beans
    4,045
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: How do I prevent automount of any external devices

    Actually. Udev only creates device nodes in /dev. HAL, the hardware abstraction layer, listens to what udev is doing, and when udev finds a new device, HAL tries to figure out what type of device it is, and if it is a removable storage device, it notifies everyone listening that this should be mounted. gnome-volume-manager takes the ball and mounts it.

    You can find the configuration file for hal at: /etc/hal/fdi/policy/preferences.fdi
    I tried adding some configuration that disables mounting of removable storage devices, and ran "sudo /etc/init.d/hal restart". After that it stopped mounting my USB-pendrive automatically.

    Here's my configuration. The parts I added marked in bold.
    Code:
      <device>
        <match key="storage.hotpluggable" bool="false">
          <match key="storage.removable" bool="false">
            <merge key="storage.automount_enabled_hint" type="bool">false</merge>
          </match>
        </match>
        <match key="storage.removable" bool="true">
            <merge key="storage.automount_enabled_hint" type="bool">false</merge>
        </match>
      </device>

  7. #7
    Join Date
    Sep 2006
    Beans
    16

    Talking Re: How do I prevent automount of any external devices

    Quote Originally Posted by geirha View Post
    Actually. Udev only creates device nodes in /dev. HAL, the hardware abstraction layer, listens to what udev is doing, and when udev finds a new device, HAL tries to figure out what type of device it is, and if it is a removable storage device, it notifies everyone listening that this should be mounted. gnome-volume-manager takes the ball and mounts it.

    You can find the configuration file for hal at: /etc/hal/fdi/policy/preferences.fdi
    I tried adding some configuration that disables mounting of removable storage devices, and ran "sudo /etc/init.d/hal restart". After that it stopped mounting my USB-pendrive automatically.

    Here's my configuration. The parts I added marked in bold.
    Code:
      <device>
        <match key="storage.hotpluggable" bool="false">
          <match key="storage.removable" bool="false">
            <merge key="storage.automount_enabled_hint" type="bool">false</merge>
          </match>
        </match>
        <match key="storage.removable" bool="true">
            <merge key="storage.automount_enabled_hint" type="bool">false</merge>
        </match>
      </device>
    Thanks for the help! Is this also where I would configure the livecd to not mount the internal HDD as well?

  8. #8
    Join Date
    Feb 2007
    Beans
    4,045
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: How do I prevent automount of any external devices

    I haven't checked the LiveCD, but I'm fairly certain it uses HAL too, so I would assume the same configuration applies.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •