Mounting usb drives on Linux

Submitted by sean on Fri, 08/14/2009 - 13:23

Increasing disks have usb and firewire connections, and automatic recognition and mounting on Linux server editions (which have no GUI tools) is not always easy.

These notes are primarily for Ubuntu, but also work on my Suse 10.

To see if a disk is visible

# list disks


fdisk -l

# list disk, with UUID and label


# list devices
ls -al /dev/disk/by-label

ls -al /media

# list partitions

partprobe -s

Ask the system to re-detect disks

rchal restart    [Suse ony]

The order that usb disks are mounted may change, and thus their /dev/sdXY number. Thus it better to assign a label, and mount using the label in /etc/fstab. So lets prepare a new disk /dev/sdc1 for usage:

# Create a partition sdc1

fdisk /dev/sdc
# Put an 'ext3' filesystems on that partition
mkfs.ext3 /dev/sdc1

# Lets label the disk EXTERNAL1, and check that the labelling worked:
e2label /dev/sdc1 EXTERNAL1
e2label /dev/sdc1
ls -al /dev/disk/by-label/

Now to mount the disk now and automatically in the future.
On some systems the disk is automatically mounted as /media/LABEL (i.e. /media/EXTERNAL1 in the above example)

on other systems an /etc/fstab entry is needed:

LABEL=EXTERNAL1 /external1  ext3 noauto,noatime,nodiratime,hotplug 0  2

Create mount point and mount

mkdir /external1 && mount /external1

If mounting a Windows NTFS formatted disk, find the UUID (with 'blkid') and try an fstab entry like this:

UUID=9A7836057835E0A5 /media/usb1      ntfs-3g  force,noauto 0       2

There is more to learn though, I've had instances of

  • USB disk not being mounted during powerup of the server, but mounting later worked fine.
  • External USB disk mounting fine on one Ubutun 8.04 server, but not visible on another (as if there was a HW issue)
  • USB disk umounting themselves/disappearing when idle.