# External HDD

## rsnfunky

Dear All,

I want to mount my external HDD (500 gb) that is connected via a usb. What will be the code and what entry should I make in /etc/fstab.

----------

## NeddySeagoon

rsnfunky,

Your kernel needs SCSI disk support, USB-storage support and support for all the filesystems you want to use on the drive.

When you have that, you can mount the partition(s) manually to test.

At that time, when the drive is detected, the kernel will show what device name it was allocated for the whole drive and each partition.

You need not have entries in fstab, udev and friends can be made to allocate fixed names and automount the partitions your drive contains.

The first step is to check you have all the needed kernel support and test by mounting by hand.

----------

## jcat

You can also mount drives by "LABEL" instead of using udev rules for persistent naming etc.  But yes, make sure you have the desired kernel support, then try mounting it ("man mount" for details or post back).

Cheers,

jcat

----------

## rsnfunky

I had built the kernel with all the device support (USB, SCSI, Firewire, and all filesystems). The kernel also detects the drice (mass storage device) during bootup. 

But my query is how do I mount it. What will be the device name. It is attached to the PCI-USB card. 

Eg. If I have to mount my primary HDD i will use mount /dev/hda /mnt/<drive> ; similarly what do I use for this mass storage device?

----------

## NeddySeagoon

rsnfunky,

look in dmesg - you will see something like 

```
[ 2510.833079] usb 3-2.1: new high speed USB device using ehci_hcd and address 5

[ 2510.925899] usb 3-2.1: configuration #1 chosen from 1 choice

[ 2510.936213] scsi4 : SCSI emulation for USB Mass Storage devices

[ 2510.943691] usb-storage: device found at 5

[ 2510.943773] usb-storage: waiting for device to settle before scanning

[ 2515.937734] usb-storage: device scan complete

[ 2515.938211] scsi 4:0:0:0: Direct-Access     Pendrive DatawriteVoyager 2.00 PQ: 0 ANSI: 2

[ 2515.944438] sd 4:0:0:0: [sdd] 506495 4096-byte hardware sectors (2075 MB)

[ 2515.945188] sd 4:0:0:0: [sdd] Write Protect is off

[ 2515.945193] sd 4:0:0:0: [sdd] Mode Sense: 0b 00 00 08

[ 2515.945195] sd 4:0:0:0: [sdd] Assuming drive cache: write through

[ 2515.950667] sd 4:0:0:0: [sdd] 506495 4096-byte hardware sectors (2075 MB)

[ 2515.951573] sd 4:0:0:0: [sdd] Write Protect is off

[ 2515.951578] sd 4:0:0:0: [sdd] Mode Sense: 0b 00 00 08

[ 2515.951581] sd 4:0:0:0: [sdd] Assuming drive cache: write through

[ 2515.951584]  sdd: unknown partition table

[ 2515.953874] sd 4:0:0:0: [sdd] Attached SCSI removable disk

[ 2515.953916] sd 4:0:0:0: Attached scsi generic sg5 type 0
```

As the USB device is detected.

The important part here is 

```
[ 2515.951584]  sdd:
```

which shows that the device is /dev/sdd.

This was taken with my pendrive, which has no partitions, or the partitions would also be shown.

If your drive has not yet been partitioned and formatted, you cannot mount it. You can learn that from 

```
fdisk with fdisk -l /dev/sd...
```

when you know the device for your USB storage.

----------

## mimosinnet

 *rsnfunky wrote:*   

> I want to mount my external HDD (500 gb) that is connected via a usb. What will be the code and what entry should I make in /etc/fstab.

 

I was having the same issue and I have followed these steps inspired by the udev guides in gentoo-wiki:

1.- Identify the disk: 

```
$ udevinfo -a -p $(udevinfo -q path -n /dev/sdb1)

(rellevant output)

  looking at parent device '/devices/pci0000:00/0000:00:03.3/usb1/1-3/1-3:1.0/host5/target5:0:0/5:0:0:0':

    KERNELS=="5:0:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS=="sd"

    ATTRS{device_blocked}=="0"

    ATTRS{type}=="0"

    ATTRS{scsi_level}=="0"

    ATTRS{vendor}=="SAMSUNG "

    ATTRS{model}=="HD400LD         "
```

2.- Build a rule in /etc/udev/rules.d/10-local.rules with the disk information that creates a symlink to the device and runs mount:

```
KERNEL=="sd?1", SUBSYSTEMS=="scsi", ATTRS{model}=="HD400LD", GROUP="users", SYMLINK+="PeekBox", RUN+="/bin/mount /dev/PeekBox"
```

3.- Define the drive in /etc/fstab with the relevant permitions and mountpont:

```
/dev/PeekBox    /mnt/PeekBox    vfat    noauto,users,gid=100,umask=007  0 0
```

At plugging the usb hard disk it gets automounted at its own mountpoint: 

```
$ mount

/dev/sdb1 on /mnt/PeekBox type vfat (rw,noexec,nosuid,nodev)
```

Question:

I have noticed in the examples given in the gentoo-wiki that the RUN list assignment points to a script instead of executing the mount. The  Writing udev rules by Daniel Drake states:

 *Daniel Drake wrote:*   

> The functionality introduced here allows you to run a program after the device node is put in place. This program can act on the device, however it must not run for any extended period of time, because udev is effectively paused while these programs are running. One workaround for this limitation is to make sure your program immediately detaches itself.

 

Is it safe to use the command 'mount' in the RUN list assignment?

Thanks!

[fixed BBCode tags - NeddSeagoon ... eventually]

[Thanks!!!   :Very Happy: , very efficient...!!! - mimosinnet]

----------

## lyallp

I am not sure about you, but I simply look in /dev/disk/by-id/ for my newly mounted disk devices.

I then put in my /etc/fstab, an entry like

```

/dev/disk/by-id/usb-WDC_WD20_00JB-00GVA0_DEF1082AC0DB-0:0-part1           /mnt/usb/externalCase   vfat      noauto,user,gid=usbd,umask=0,umask=007,quiet      0 0

/dev/disk/by-id/usb-USB_Flash_Drive_123456789ABCDEF-0:0              /mnt/usb/KanesKey      vfat      noauto,user,gid=usbd,umask=0,umask=007,quiet      0 0

```

No chance of some device being called /dev/sda1 today when it was /dev/sdb1 yesterday.

I tend to use 'gkrellm' to do my mounting and unmounting if my ivman setup has not already mounted the device.

I start ivman in the background, when I login and have the following snippet in my ~/.ivman/IvmConfigActions.xml

```

    <!-- mount everything we can -->

    <ivm:Match name="ivm.mountable" value="true">

        <ivm:Option name="mount" value="true" />

    </ivm:Match>

```

----------

## mimosinnet

Thanks for answering   :Very Happy:  . It seems both procedures are doing similar things:

 *lyallp wrote:*   

> I am not sure about you, but I simply look in /dev/disk/by-id/ for my newly mounted disk devices.
> 
> I then put in my /etc/fstab, an entry like
> 
> ```
> ...

 

I tell UDEV to name my HD400LD hard disk /dev/PeekBox. How will your box name your device? By the way, what does the option "quiet" do?

 *lyallp wrote:*   

> I tend to use 'gkrellm' to do my mounting and unmounting if my ivman setup has not already mounted the device.

 

I had a look at ivman and I was about to use it. Nevertheless, it adds another daemon running in your system, and I only want to use it (at the moment) to automount devices. From this naif perspective: if udev already does it, why using ivman to do similar things?

At the same time, I have not used ivman and I am just starting to use udev. I do not have much arguments on the strengths and weaknesses of each procedure. Also, I am not sure you can use the command mount in the UDEV RUN list assignment.

----------

## lyallp

I find gkrellm particularly useful for mounting network shares and for unmounting USB disks/keys.

I guess, it comes down to how much maintenance you want to do when you have a new disk.

Me, I simply add a new entry to the /etc/fstab and to gkrellm, you, will have to update udev and unmount/remount by other means.

----------

## mimosinnet

 *lyallp wrote:*   

> I find gkrellm particularly useful for mounting network shares and for unmounting USB disks/keys.

 

Yes, gkrllm is very nice. I do not remember exactly why, but I changed from gkrellm to conky, I think it was when I changed from windowmaker to fvwm. 

 *lyallp wrote:*   

> I guess, it comes down to how much maintenance you want to do when you have a new disk.
> 
> Me, I simply add a new entry to the /etc/fstab and to gkrellm, you, will have to update udev and unmount/remount by other means.

 

Yes you're right. Despite you can automount in udev just by writting a single line, the syntax is complex and you have to be aware of what are you doing in your box. I will continue to use udev to see how it works, but I can clearly see your point. 

Finally, what is the option "quiet" doing in your /etc/fstab? I cannot find it in "man mount".

Thanks for your comments!

----------

## lyallp

$ man mount

...section... 

Mount options for fat

...second last entry...

```
       quiet  Turn  on the quiet flag.  Attempts to chown or chmod files do not return errors, although they fail. Use

              with caution!

```

similar to

$ man mount.ntfs-3g

...

```

       silent Do nothing on chmod and chown operations, but do not return error.  This option is on by default.
```

I guess you might also be interested in seeing a Windows share mount.

```
//kanes-pc/kanes-c      /mnt/kanes-pc/c      smbfs    user,fmask=0770,dmask=0770,umask=0007,iocharset=iso8859-1,credentials=/etc/samba/private/auth.kanes-pc.lyall,noauto,gid=smb,quiet          0 0
```

The only problem with this is that only root (or whoever the owner of the credentials file is) can mount this share although, using gkrellm, I have 'sudo mount ...' as the mount command and have configured sudo to allow me to do 'sudo mount' without asking for a password (by putting myself in the wheel group and setting up so that people in the wheel group do not have to use passwords if they are using /bin/mount or /bin/umount).

in /etc/sudoers, one of the config items 

```
# more specifics...

%wheel ALL=(root) NOPASSWD: /bin/mount, /bin/umount
```

I guess I could have created a 'mounters' group instead.

Since this is my personal computer, not a server, I am not too concerned about the security consequences of this.

----------

## mimosinnet

Silly me....   :Embarassed: ! I could not find the 'quiet' option and man mount | grep quiet gave me nothing. Thanks very much for your comments: I am going to play with the options you have given me.   :Smile: 

Cheers!

----------

