# Mounting USB disk where I want, not in /media

## lyallp

I recently replaced my computer but retained my Gentoo installation (do THAT with Windoze!).

The only problem is that my new computer only had 1 IDE port whereas my old machine had 2.

So, one of my IDE drives made a transition to a USB case and the DVD burner was replaced.

Now, I am having trouble convincing the system to mount my USB based IDE drive in /mnt/disk_06, it insists on mounting in /media/Disk_06. I unmount /media/Disk_06 and then type 'mount /mnt/disk_06' and everything is as I expect.

I use Fluxbox as my window manager, and, as such, don't use any fancy Gnome or KDE based mounting mechanism.

I don't think I have any udev rules that are specific to this.

I am using halevt, since ivman stopped working. (ivman has been removed)

I sort of expected 'mount -a', during boot, to cause the disk to mount according to this /etc/fstab entry. Particularly since I have the USB Case powered on during the boot process.

```
LABEL="Disk_06"   /mnt/disk_06      ntfs-3g   defaults,auto,user,gid=usbd,umask=0,umask=007,silent             0 0

```

I want to mount by label, not by device or UUID, as the device changes, depending on what's plugged in and the UUID can also change, if I replace the disk but not the contents, as just happened recently  :Wink: 

The 'lshal' output for the device is as follows :-

```
udi = '/org/freedesktop/Hal/devices/volume_uuid_8030BC8C30BC8B24'

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

  block.is_volume = true  (bool)

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

  block.minor = 81  (0x51)  (int)

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

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

  info.category = 'volume'  (string)

  info.interfaces = {'org.freedesktop.Hal.Device.Volume'} (string list)

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

  info.product = 'Disk_06'  (string)

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

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

  linux.sysfs_path = '/sys/block/sdf/sdf1'  (string)

  org.freedesktop.Hal.Device.Volume.method_argnames = {'mount_point fstype extra_options', 'extra_options', 'extra_options'} (string list)

  org.freedesktop.Hal.Device.Volume.method_execpaths = {'hal-storage-mount', 'hal-storage-unmount', 'hal-storage-eject'} (string list)

  org.freedesktop.Hal.Device.Volume.method_names = {'Mount', 'Unmount', 'Eject'} (string list)

  org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'} (string list)

  storage.model = ''  (string)

  volume.block_size = 512  (0x200)  (int)

  volume.fstype = 'ntfs-3g'  (string)

  volume.fsusage = 'filesystem'  (string)

  volume.fsversion = '3.1'  (string)

  volume.ignore = false  (bool)

  volume.is_disc = false  (bool)

  volume.is_mounted = true  (bool)

  volume.is_mounted_read_only = false  (bool)

  volume.is_partition = true  (bool)

  volume.label = 'Disk_06'  (string)

  volume.linux.is_device_mapper = false  (bool)

  volume.mount.valid_options = {'ro', 'sync', 'dirsync', 'noatime', 'nodiratime', 'noexec', 'quiet', 'remount', 'exec', 'uid=', 'gid=', 'umask=', 'locale=', 'utf8'} (string list)

  volume.mount_point = '/mnt/disk_06'  (string)

  volume.num_blocks = 312576642  (0x12a18a82)  (uint64)

  volume.partition.flags = {'boot'} (string list)

  volume.partition.label = ''  (string)

  volume.partition.media_size = 160041885696  (0x25433d6000)  (uint64)

  volume.partition.number = 1  (0x1)  (int)

  volume.partition.scheme = 'mbr'  (string)

  volume.partition.start = 32256  (0x7e00)  (uint64)

  volume.partition.type = '0x07'  (string)

  volume.partition.uuid = ''  (string)

  volume.size = 160039240704  (0x2543150400)  (uint64)

  volume.unmount.valid_options = {'lazy'} (string list)

  volume.uuid = '8030BC8C30BC8B24'  (string)

```

I tried putting a couple of extra rules in /etc/halevt/halevt.xml

```
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE halevt:Configuration [

<!-- this entity corresponds with mountable devices, which have 

 volume.policy.should_mount true or don't have 

 volume.policy.should_mount false and are block devices hotpluggable or

 removable.

-->

<!ENTITY MOUNTABLE "hal.block.device &amp; hal.block.is_volume = true &amp; (hal.volume.policy.should_mount = true | ((! hal.volume.policy.should_mount = false) &amp; (hal.block.storage_device.hal.storage.policy.should_mount = true | ((! hal.block.storage_device.hal.storage.policy.should_mount = false)  &amp; (hal.block.storage_device.hal.storage.hotpluggable = true | hal.block.storage_device.hal.storage.removable = true)))))">

]>

<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">

<!--

Remember to use &amp; and &quot; for & and " in xml attributes.

In a match attribute, hal.* is special since it matches any device.

In a match attribute property it is possible to refer to other

device properties. For example 

hal.block.storage_device.hal.storage.policy.should_mount

refers to the storage.policy.should_mount property of the block.storage_device

device associated with a given device.

In an exec attribute, $hal.udi$ is special since it is replaced by

the device udi. $hal.some.property$ is replaced by the value

of the property some.property.

!-->

<!--

Removable devices support

!-->

<!--

This rule matches removable devices which have volume.policy.should_mount true

or don't have volume.policy.should_mount false.

Upon insertion, they are mounted and recorded by halevt-mount. 

-m 002 sets the umask of mount to 002 when pmount is used system-wide

to mount the device. This allows regular users to read the device.

!-->

<halevt:Device match="&MOUNTABLE;">

   <!-- <halevt:Insertion exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->

   <halevt:Insertion exec="halevt-mount -u $hal.udi$ -d /dev/disk/by-uuid/$hal.volume.uuid$ -m 002"/>

</halevt:Device>

<!-- if didn't mount using uuid, try mounting by label - my attempt to get disk_06 to mount properly-->

<halevt:Device match="&MOUNTABLE; &amp; ! hal.volume.is_mounted;">

   <halevt:Insertion exec="halevt-mount /mnt/$hal.volume.label$"/>

</halevt:Device>

<!--

When a device get a mount point, it is passed to halevt-mount which can 

record it. The property that changes is volume.is_mounted, and the action is

executed when the value of volume.is_mounted becomes true.

!-->

<halevt:Device match="hal.block.device &amp; hal.block.is_volume = true &amp; hal.volume.mount_point">

   <halevt:Property name="hal.volume.is_mounted">

      <halevt:Action value="true" exec="halevt-mount -s"/>

   </halevt:Property>

</halevt:Device>

<!--

When a device is unmounted, it is recorded by halevt-mount.

!-->

<halevt:Device match="hal.block.device &amp; hal.block.is_volume = true">

    <halevt:Property name="hal.volume.is_mounted">

        <halevt:Action value="false" exec="halevt-mount -s"/>

    </halevt:Property>

</halevt:Device>

<!--

When a device is removed, it is recorded by halevt-mount.

Note that at that point the device is already out of hal, so we use

* which matches any device in the match attribute, and only pass the

udi to the command.

!-->

<halevt:Device match="hal.*">

     <halevt:Removal exec="halevt-umount -u $hal.udi$ -d /dev/disk/by-uuid/$hal.volume.uuid$; halevt-umount -s"/>

     <!-- <halevt:Removal exec="halevt-umount -u $hal.udi$; halevt-umount -s"/> -->

</halevt:Device>

<!-- 

Example of a use of OnInit. At startup all the devices are matched and the exec

comand is run for those that match. Here we match all the removable devices

that aren't already mounted and mount and register them.

!-->

<halevt:Device match="&MOUNTABLE;">

   <!-- <halevt:OnInit exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->

   <halevt:OnInit exec="halevt-mount -u $hal.udi$ -d /dev/disk/by-uuid/$hal.volume.uuid$"/>

</halevt:Device>

<!-- if didn't mount using uuid, try mounting by label -->

<halevt:Device match="&MOUNTABLE; &amp; ! hal.volume.is_mounted;">

   <!-- <halevt:OnInit exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->

   <halevt:OnInit exec="halevt-mount /mnt/$hal.volume.label$"/>

</halevt:Device>

<!--   <halevt:OnInit exec="halevt-mount -d /mnt/usb/$hal.volume.label$"/> -->

<!-- 

Example of a use of Condition. When a device matches and the condition has become

true for that device, the corresponding exec command is launched.

<halevt:Device match="hal.info.udi = /org/freedesktop/Hal/devices/acpi_PWRF">

    <halevt:Condition name="ButtonPressed" exec="/usr/bin/sudo /sbin/shutdown"/>

</halevt:Device>

!-->

<!-- 

Example of a use of OnInit. At startup all the devices are matched and the exec

comand is run for those that match.

<halevt:Device match="hal.info.category = battery">

    <halevt:OnInit exec="hvbattery -u $hal.udi$ -l $hal.battery.charge_level.percentage$ -s $hal.battery.rechargeable.is_discharging"/>

</halevt:Device>

!-->

</halevt:Configuration>

```

So, the bottom line, I am kinda lost. Any ideas?

----------

## justinkb

you could make a symlink /mnt/disk_06 -> /media/Disk_06 to circumvent the problem, if you need a quick solution now.

anyway, this stuff shouldn't be set in /etc/stab anymore nowadays, look at udev rules.

----------

## Lori

I have some external drives too, and of course they show up with different device name every once in the while. What I do is using udev to automatically create a symlink using a consistent name and use that name in /etc/fstab. For example I have a Maxtor drive which will be recognized as /dev/maxtor, with partitions /dev/maxtor[0-2].

I created the following /etc/udev/rules.d/99-personal.rules file for this:

```
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="Maxtor 6", SYMLINK+="maxtor%n", MODE="0660"
```

You can use 

```
udevinfo --query=all --name=/dev/sdb
```

 or for more details 

```
udevadm info -a -p `udevadm info -q path -n /dev/sdb`
```

 to get the details that would uniquely identify your device.

Hope this helps!

----------

## lyallp

I already have udev rules (out of the box) which create the following

```
# udevinfo --query=all --name=/dev/sdf1

P: /block/sdf/sdf1

N: sdf1

S: disk/by-id/usb-Initio_WD1600JB-00EVA0_0010100000000000-0:0-part1

S: disk/by-path/pci-0000:00:1d.7-usb-0:2.2.1:1.0-scsi-0:0:0:0-part1

S: disk/by-uuid/8030BC8C30BC8B24

S: disk/by-label/Disk_06

<snip>

```

So, the /dev/disk/by-label is already there.

The whole reason it's in fstab is it's obvious, at least to me, and for compatibility.

If the disk moves, I have to reconfigure a few pieces of software, a pile of symlinks I already have, etc.

If I execute mount, by hand against it's mount point (mount /mnt/disk_06),  it's fine.

All of the following variants of /etc/fstab entries work fine, it's just the auto-mounting I am having problems with.

```

LABEL="Disk_06"                                                              /mnt/disk_06      ntfs-3g      defaults,auto,user,gid=usbd,umask=0,umask=007,silent             0 0

UUID="8030BC8C30BC8B24"                                                      /mnt/disk_06      ntfs-3g      defaults,auto,user,gid=usbd,umask=0,umask=007,silent             0 0

/dev/disk/by-label/Disk_06                                                    /mnt/disk_06      ntfs-3g      defaults,auto,user,gid=usbd,umask=0,umask=007,silent             0 0

/dev/disk/by-id/usb-Initio_WD1600JB-00EVA0_0010100000000000-0:0-part1        /mnt/disk_06      ntfs-3g      defaults,auto,user,gid=usbd,umask=0,umask=007,silent             0 0

```

By the way, I have found that halevt is core dumping, investigation on that front is on-going. I am using 0.1.4-r1.

----------

## lyallp

I seem to have had a little joy, more updates soon, by editing /etc/hal/hal.conf and setting

```
<storage_automount_enabled_hint>true</storage_automount_enabled_hint>
```

----------

