USBDisks

From SME Server
Jump to navigationJump to search

USBDisks

Incomplete.png Incomplete:
This article or section needs to be expanded. Please help to fill the gaps or discuss the issue on the talk page


SME will automatically mount connected USB disk drives into the /media folder.

Auto-mounting will be performed based on the specific USB port used to connect your drives unless you use another method to specify mount points.

This means that if you insert USB drive 'A', it should auto-mount to /media/usbdisk. If you now dismount this disk and mount drive 'B' in the same USB port, it, too, will auto-mount to /media/usbdisk. Additionally, if you connect drive 'A' to another USB port, it may auto-mount to /media/usbdisk1.

The easiest way to avoid this behavior is to provide a label for each of your USB drives, and specify the desired mount point in /etc/fstab based on the drive label.

ext2/ext3 vs. FAT32/VFAT

  • ext2/ext3 works great under Linux
  • ext2/ext3 supports hard links, symlinks
  • ext2/ext3 can be read under Windows using http://www.chrysocome.net/explore2fs
  • fat32/vfat comes pre-configured on most USB hard drives
  • fat32/vfat is suppoted natively by Windows.

Identifying your USB drive

After connecting your USB drive, execute the command

mount

and look for anything mounted in /media/???.

If your drive did not auto-mount, search /var/log/messages for the kernel commands related to your device using:

egrep "(kernel|fstab|scsi).*(usb|USB)" /var/log/messages

You should have a line logged by fstab-sync giving the auto-mount folder created and the device name for your new device that looks like this:

Sep 23 17:11:14 office fstab-sync[32193]: added mount point /media/usbdisk1 for /dev/sdd1

You should now be able to mount your USB drive using the values found in /var/log/messages. In our example, that would mean:

mount /media/usbdisk1

or

mount /dev/sdd1

Formatting your USB drive

ext3

Copied with slight changes from Affa#Alternatively_setup_a_USB_drive

  1. Connect a USB hard disk to the USB Bus. Now you must determine what device the kernel has assigned to the drive. View the /var/log/message and search for Initializing USB Mass Storage driver. A few lines below you'll find the name of the device. In this example it is sdc. Replace /dev/sdc by your device in following instructions.
  2. Use the fdisk program to create a linux partition
    # fdisk /dev/sdc
    You'll most likely find an existing vfat dos partition, which you have to delete first. In the following we assume, that you have created a single partition /dev/sdc1.
  3. Now format the drive with an ext3 filesystem
    mkfs.ext3 -L MyLabel /dev/sdc1
  4. Make the mount point
    # mkdir -p /mnt/affadevice
  5. Customize /etc/fstab as shown here: #Customizing_fstab
  6. Mount the drive
    mount /mnt/affadevice
  7. Crosscheck your work using the df command
    # df
vfat

It's probably easier to format your vfat drive on your windows system. You *must* have one, or you wouldn't be using this format...

If that sounds unhelpful, you could try (warning, untested!):

mkfs.vfat -n MyLabel /dev/sdd1

labeling your USB drive

ext3
e2label /dev/sdd1 MyLabel
vfat

Linux uses 'mtools' to manage FAT, FAT32, and VFAT partitions. 'mtools' uses drive letters to access devices. These drive letters must be defined in /etc/mtools.conf before any of the mtools will work. You can create a definition for your USB drive using a command like this one (be sure to replace /dev/sdd1 with the device name identified above for your USB drive!):

echo 'drive e: file="/dev/sdd1"' >> /etc/mtools.conf

Once you have created the drive letter in mtools.conf you can view or edit the disk label using the following commands.

Show the current label:

mlabel -s e:

Clear the volume label:

mlabel -c e:

Assign a new volume label:

mlabel e:NewLabel
mlabel -c e:NEWLABEL

Customizing fstab and rc.local

Add the following line to the /etc/fstab
LABEL=MyLabel /mnt/affadevice ext3 defaults

  • Replace 'ext3' with 'vfat' if your drive is formatted as vfat.
  • Replace /mnt/affadevice with the folder in which you want your USB drive mounted

If you want your drive to auto-mount whenever you re-boot, add a line like this to /etc/rc.local
mount LABEL=MyLabel

More Information