# Automounting eSATA

## SerialPrecision

I was trying to automount my HDD through eSATA following the instructions here:  http://vstone.eu/2009/04/hal-and-auto-mounting-external-e-sata-devices

So I wrote an fdi file:

```

$ cat /etc/hal/fdi/policy/50-esata-WDC_Caviar_Black.fdi 

<?xml version="1.0" encoding="utf-8"?>

<deviceinfo version="0.2">

  <device>

     <!-- WDC Caviar Black 1TB -->

    <match key="storage.serial" string="SATA_WDC_WD1001FALS__WD_WMATV8201326">

        <merge key="storage.is_external" type="bool">true</merge>

    </match>

    <match key="storage.is_external" bool="true">

        <merge key="storage.removable" type="bool">true</merge>

        <merge key="storage.hotpluggable" type="bool">true</merge>

        <merge key="volume.ignore" type="bool">false</merge>

    </match>

    <match key="@block.storage_device:storage.is_external" bool="true">

        <merge key="volume.ignore" type="bool">false</merge>

    </match>

  </device>

</deviceinfo>

```

restarted hald, but then in lshal I get the following:

```

udi = '/org/freedesktop/Hal/devices/storage_serial_SATA_WDC_WD1001FALS__WD_WMATV8201326'

  block.device = '/dev/sdb'  (string)

  block.is_volume = false  (bool)

  block.major = 8  (0x8)  (int)

  block.minor = 16  (0x10)  (int)

  block.storage_device = '/org/freedesktop/Hal/devices/storage_serial_SATA_WDC_WD1001FALS__WD_WMATV8201326'  (string)

  info.capabilities = {'storage', 'block'} (string list)

  info.category = 'storage'  (string)

  info.parent = '/org/freedesktop/Hal/devices/pci_197b_2363_scsi_host_scsi_device_lun0'  (string)

  info.product = 'WDC WD1001FALS-0'  (string)

  info.udi = '/org/freedesktop/Hal/devices/storage_serial_SATA_WDC_WD1001FALS__WD_WMATV8201326'  (string)

  info.vendor = 'ATA'  (string)

  linux.hotplug_type = 3  (0x3)  (int)

  linux.sysfs_path = '/sys/block/sdb'  (string)

  storage.automount_enabled_hint = true  (bool)

  storage.bus = 'pci'  (string)

  storage.drive_type = 'disk'  (string)

  storage.firmware_version = '05.0'  (string)

  storage.hotpluggable = false  (bool)

  storage.lun = 0  (0x0)  (int)

  storage.media_check_enabled = false  (bool)

  storage.model = 'WDC WD1001FALS-0'  (string)

  storage.no_partitions_hint = false  (bool)

  storage.originating_device = '/org/freedesktop/Hal/devices/computer'  (string)

  storage.partitioning_scheme = 'mbr'  (string)

  storage.removable = false  (bool)

  storage.removable.media_available = true  (bool)

  storage.removable.media_size = 1000204886016  (0xe8e0db6000)  (uint64)

  storage.requires_eject = false  (bool)

  storage.serial = 'SATA_WDC_WD1001FALS-_WD-WMATV8201326'  (string)

  storage.size = 1000204886016  (0xe8e0db6000)  (uint64)

  storage.vendor = 'ATA'  (string)

  volume.ignore = true  (bool)

```

So it seems that hal is ignoring the flags set in my fdi file. Then I tried doing this: http://en.gentoo-wiki.com/wiki/HAL#Fixed_drives Which didn't automount my drive but at least the ignore flag was set to false. Then I added the other rules from my original fdi file to 99-storage-policy-no-fixed-drives.fdi so now it looks like this:

```

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> 

<deviceinfo version="0.2">

<device>

  <match key="@block.storage_device:storage.hotpluggable" bool="false">

    <match key="@block.storage_device:storage.removable" bool="false">

      <merge key="volume.ignore" type="bool">false</merge>

      <merge key="storage.removable" type="bool">true</merge>

      <merge key="storage.hotpluggable" type="bool">true</merge>

    </match>

  </match>

</device>

</deviceinfo>

```

This does actually automount the drive in /media/disk however only root has write permission on this mount. I am wondering why hal didn't read the original fdi file and also if there is a better way of doing this so that the drive is mounted with normal permissions. Also another thing I tried was copying my original fdi into /usr/share/hal/fdi/policy/10osvendor/ but this also was ignored by hald.

----------

## dmpogo

Tough world, given it is so trivial with standard autofs ... or what am I missing ?

----------

## SerialPrecision

I am not familiar with autofs, I was using halevt to perform automounting of USB drives. Is this a better way?

----------

## dmpogo

 *SerialPrecision wrote:*   

> I am not familiar with autofs, I was using halevt to perform automounting of USB drives. Is this a better way?

 

Well, better is a difficult concept, depends on your needs. I do not use hal at all, having setup autofs 10 years ago for my needs, and it is fine.

(Autofs is a venerable kernel based automounter, which is a backbone of many, if not most NFS installations )

Really,   HAL is useful in two regards (automount-wise) --

a) mounting random, unknown disks, several at a time (somebody came with a memory stick

and stick it in your usb port, while your computer may have two other sticks already in)

b) comminucating with desktop environment (some notification, nice icon)

As negative, it has atrocious configuration syntax and is being, well, depreciated.

autofs is a kernel based automounter, which mounts volumes when you access them and unmounts them after period of unuse.

Device creation on connection, as always, is done by udev.

It is easy to configure (having very powerful possibilities to present bunch of volumes in an ordered fashing, mount remote volumes over network etc).

For volumes that are static it is excellent, and is as good as it gets.

An autofs weakness was always mounting a random volume, which may appear at unpredictable device and have unknown beforehand partition.

I.e not so much hotpluggable things, but unknown things.

This is largely mitigated if you do know your hardware (but not the device udev will assign to it), by using UUIDs to mount it. 

It also does not communicate with desktop - but it just works, I always know I can access the volume if it is connected.

In my workflow, I do not stick random hardware into my computer and have little use for HAL discovery features. I have one

USB stick, one external backup drive and one cdrom, all managed by autofs.  If my daughter once a year brings me her USB stick, I can mount it by hand

if anything.

I would suspect external SATA drive (unless you have a bunch of them shuffling around) is a good candidate for autofs.

----------

