- 1 USB Disks
- 1.1 Introduction
- 1.2 Supported FileSystems
- 1.3 Identifying your USB drive
- 1.4 Formatting your USB drive
- 1.5 labeling your USB drive
- 1.6 Dual Partitions
- 1.7 Customizing fstab
- 1.8 Mount your disk automatically at boot-up
- 1.9 Mount your disks automatically when connected
- 1.10 Format limitations when linking disk to an ibay
- 1.11 More Information
SME will automatically mount connected USB disk drives into the /media folder. Auto-mounting will be performed based both the specific USB port used to connect your drives and the order in which they are connected unless you use another method to specify mount points.
Imagine this example:
- Connect USB 'A' to your system. It is automatically assigned to /dev/sdc and auto-mounted to /media/usbdisk
- Disconnect USB 'A' and connect USB 'B' (to the same or to a different USB port). It will be assigned to /dev/sdc and auto-mounted to /media/usbdisk.
- Re-connect USB 'A' while USB 'B' is still connected, and it will be assigned to /dev/sdd and auto-mounted to /media/usbdisk1.
Or this example:
- Connect USB 'A' to the second USB port on your SME. It is assigned to /dev/sdc
- Connect USB 'B' to the first USB port without disconnecting USB 'A'. USB 'B' is assigned to /dev/sdd
- Leave both drives connected and re-boot. USB 'B' is now connected to /dev/sdc, while USB 'A' is connected to /dev/sdd!
In one case, SME automatically mounted my USB drive in /media/DiskLabel, but, since the resulting automatic entry in /etc/fstab depended on the assigned device, the next drive I connected was also mounted in /media/DiskLabel, even though it had a completely different label!
The easiest way to avoid this behavior and provide reliable mount points for your USB drives is to label each drive, then specify the desired mount point in /etc/fstab based on the drive label. This will allow you to:
- Reliably mount your USB drives to drive-specific directories regardless of what device is assigned to the drive by SME. This would allow you to specify separate USB disks for specific ibays by using lines like these in /etc/fstab:
LABEL=Disk1 /home/e-smith/files/ibays/ibay-1/html ext3 defaults LABEL=Disk2 /home/e-smith/files/ibays/ibay-2/html ext3 defaults
- Reliably mount multiple disks in the one location, in case you want to use a rotating set of disk drives for backups, by using lines like these in /etc/fstab (just don't connect two of these drives at the same time!):
LABEL=Disk1 /media/backup ext3 defaults LABEL=Disk2 /media/backup ext3 defaults LABEL=Disk3 /media/backup ext3 defaults
- recommended for USB drives intended for use only on SME
- works great under Linux
- supports hard links, symlinks
- can be read under Windows using explore2fs from http://www.chrysocome.net/explore2fs
- File & Disk size limits depend on the block size used when formatting the disk. SME defaults to a 1K block size.
1K block size: 16GB max file size, 2TB max disk size
2K block size: 256GB max file size, 8 TB max disk size.
4K block size: 2TB max file size, 16 TB max disk size
- You can determine your current block size using (replace /dev/sdc1 with the correct value for your USB drive)
dumpe2fs -h /dev/sdc1
- pre-configured on most USB hard drives
- supported natively by Windows
- (2^32)-1 byte ( 4GB - 1 byte) maximum file size
- Requires occasional defragmentation for optimal speed
- Maximum disk size dependent on cluster size. 32KB Clusters would allow a disk of approximately 8TB
Identifying your USB drive
After connecting your USB drive, execute the command
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: 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:
Formatting your USB drive
- Copied with slight changes from Affa#Alternatively_setup_a_USB_drive
- 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.
Use the fdisk program to create a linux partition
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.
- Now format the drive with an ext3 filesystem
mkfs.ext3 -L MyLabel /dev/sdc1
- Make the mount point
mkdir -p /media/usbdevice
- Customize /etc/fstab as shown here: Customizing fstab
- Mount the drive
mount reads /etc/fstab to look for instructions on what to do if not specifically told on the command line. After updating /etc/fstab as recommended, you can "mount" your USB disk reliably by specifying either the target directory:
or the disk label:
- Crosscheck your work using
You can format your drive from your SME server using
mkfs.vfat -n MyLabel /dev/sdd1
Since this command will destroy irretrievably all information on the specified device (/dev/sdd1 in this case), be very sure you know exactly which device is the drive you want to format!
labeling your USB drive
Only required if you didn't label your drive using the previous section.
e2label /dev/sdd1 MyLabel
SME includes 'mtools' which can be used to manage FAT, FAT32, and VFAT partitions.
'mtools' uses drive letters instead of device names to access devices. These drive letters must be defined in /etc/mtools.conf before any of the mtools will work.
You can add your USB drive to /etc/mtools.conf using a command like the one shown below. However,
- be sure to replace /dev/sdd1 with the device name identified above for your USB drive
- be aware that the assigned device may change each time you reconnect your drive or reboot!
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:
SME also includes
dosfslabel which appears to be related to labeling "dos" drives.
produces the following output:
Warning: FAT32 support is still ALPHA. MyLabel
While it is safe to use
dosfslabel to check the label on a drive, you should not use it to create or change the label on any drive that contains data you care about.
A method to use both ext3 and vfat
eg. an ext3 partition the size of your server, for an rsync backup.
the rest as vfat for easier portability
Plug in your drive or check it is unmounted
fdisk /dev/sdd p - print existing partitions d - delete partitions n - create new partitions p (primary), 1, +160G (the size you want) n - create 2nd partition p (primary), 2, return (rest of the disk) p - print and check w - write mkfs.ext3 -L MaxExt3 /dev/sdd1 mkfs.vfat -n MaxVfat /dev/sdd2
Add the following line to the /etc/fstab
LABEL=MyLabel /media/affadevice ext3 defaults
- Replace 'ext3' with 'vfat' if your drive is formatted as fat32/vfat.
- Replace /media/affadevice with the folder in which you want your USB drive mounted (here and in all "mount" commands)
- Make sure that the mount directory (/media/affadevice in this example) exists and is empty! Linux will not mount a drive in a directory that is not empty.
- Add multiple entries as described in USBDisks#The_Solution to meet your specific requirements.
Mount your disk automatically at boot-up
Use the following commands to create a script that will run at each re-boot if you want to re-mount your USB disk automatically:
cat <<EOF > /etc/e-smith/events/local/S95mount_USB #! /bin/sh mount LABEL=MyLabel EOF chmod +x /etc/e-smith/events/local/S95mount_USB
Once the script exists you can add additional mount commands by editing S95mount_USB using:
pico -w /etc/e-smith/events/local/S95mount_USB
The 'local' event will run each time your server boots up. If you connect or disconnect a drive and need to re-mount it you can re-run your auto-mount commands using:
Mount your disks automatically when connected
|Please edit this section to specify how to get SME to automatically mount USB drives when they are connected
If you wish to mount an external USB drive, and then add a link in a ibay to that drive, then in order to change ownership and have write access you must format the drive as ext3 only. Refer this forum thread for info http://forums.contribs.org/index.php?topic=40240.new;topicseen#new
- There is a contrib for managing USB disks:
- There is evidence that some external USB enclosures are incompatible with SME:
- Darrell May's HowTo on scrubbing and re-formatting a USB disk: