Changes

From SME Server
Jump to navigationJump to search
68 bytes added ,  15:29, 8 March 2016
m
Gave better formatting to echo output in script.
Line 1: Line 1:  
===USB Disks===
 
===USB Disks===
 
{{Warning box|NTFS partitions are supported if you install ntfs-3g and ntfsprogs, please use either fat32/vfat or ext2/ext3/ext4}}
 
{{Warning box|NTFS partitions are supported if you install ntfs-3g and ntfsprogs, please use either fat32/vfat or ext2/ext3/ext4}}
====Introduction====
  −
=====The Problem=====
  −
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 Solution=====
  −
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:<br>
  −
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!):<br>
  −
LABEL=Disk1 /media/backup ext3 defaults
  −
LABEL=Disk2 /media/backup ext3 defaults
  −
LABEL=Disk3 /media/backup ext3 defaults
  −
   
====Supported FileSystems====
 
====Supported FileSystems====
 
=====ext2/ext3/ext4=====
 
=====ext2/ext3/ext4=====
Line 53: Line 26:     
====Identifying your USB drive====
 
====Identifying your USB drive====
 +
See [[USBDisks#USB_on_SME_8|USB_on_SME_8]] for SME 8 servers.
 +
 
After connecting your USB drive, execute the command
 
After connecting your USB drive, execute the command
 
  mount
 
  mount
Line 76: Line 51:  
You'll most likely find an existing vfat dos partition, which you have to delete first. Refer to http://wiki.contribs.org/AddExtraHardDisk#Partitioning_the_disk for steps to create a partition. In the following we assume, that you have created a single partition ''/dev/sdc1''.
 
You'll most likely find an existing vfat dos partition, which you have to delete first. Refer to http://wiki.contribs.org/AddExtraHardDisk#Partitioning_the_disk for steps to create a partition. In the following we assume, that you have created a single partition ''/dev/sdc1''.
 
</li><li>Now format the drive with an ext3 filesystem
 
</li><li>Now format the drive with an ext3 filesystem
  mkfs.ext3 -L MyLabel /dev/sdc1
+
  mkfs ext3 -L MyLabel /dev/sdc1
 
</li><li>or format the drive with an ext4 filesystem
 
</li><li>or format the drive with an ext4 filesystem
  mkfs.ext4 -L MyLabel /dev/sdc1
+
  mkfs ext4 -L MyLabel /dev/sdc1
 
</li><li>Make the mount point
 
</li><li>Make the mount point
 
  mkdir -p /media/usbdevice
 
  mkdir -p /media/usbdevice
Line 172: Line 147:  
* Add multiple entries as described in [[USBDisks#The_Solution]] to meet your specific requirements.
 
* Add multiple entries as described in [[USBDisks#The_Solution]] to meet your specific requirements.
   −
* or for ntfs
+
Or for ntfs
  LABEL=MyLabel /media/affadevice ntfs-3g defaults
+
  /dev/NTFS-partition /media/affadevice ntfs-3g defaults   0      0
    
====Mount your disk automatically at boot-up====
 
====Mount your disk automatically at boot-up====
Line 185: Line 160:     
Once the script exists you can add additional mount commands by editing S95mount_USB using:
 
Once the script exists you can add additional mount commands by editing S95mount_USB using:
  pico -w /etc/e-smith/events/local/S95mount_USB
+
  nano -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:
 
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:
 
  signal-event local
 
  signal-event local
 +
 
====Mount your disks automatically when connected====
 
====Mount your disks automatically when connected====
 
{{incomplete}}
 
{{incomplete}}
Line 208: Line 184:  
We use hal for the first and manually create and mount for the second
 
We use hal for the first and manually create and mount for the second
    +
=====Find the Drive Name=====
 
To find  the device name, label, filesystem and the uid
 
To find  the device name, label, filesystem and the uid
 +
Create the file hal-find-by-property.sh
 +
 +
nano hal-find-by-property.sh
 +
 +
paste the text below into the file and save it.
    
  #! /bin/bash
 
  #! /bin/bash
Line 218: Line 200:  
         fs=$(hal-get-property --udi $udi --key volume.fstype)
 
         fs=$(hal-get-property --udi $udi --key volume.fstype)
 
         lb=$(hal-get-property --udi $udi --key volume.label)
 
         lb=$(hal-get-property --udi $udi --key volume.label)
         echo $dev": label "$lb",file system: "$fs ",uid: "$udi
+
         echo device: $dev", label: "$lb", file system: "$fs", uid: "$udi
 
     fi
 
     fi
 
  done
 
  done
   −
To check a mount point exists and mount
+
Make the file executable.
 +
chmod +x hal-find-by-property.sh
    +
Run the file with the USB drive attached and read the output of the file from the terminal.
 +
sh hal-find-by-property.sh
 +
 +
The output will tell you the device, volume label, file system type, and the uid. If this is a new drive you have to run fdisk to create a partition and format the drive before you can mount it.
 +
=====Run fdisk on the Drive=====
 +
 +
To create a partition with fdisk, use the device output from the hal-find-by-property.sh script as the argument to the fdisk command. If the output from hal-find-by-property.sh is /dev/sdb1 the fdisk command will be
 +
fdisk /dev/sdb1
 +
 +
You can list the partitions on the disk by entering the p command when prompted. It's a good idea to see what partitions exist before you start. If the drive is pre-formatted for fat or ntfs it's good practice to delete the factory partitions.
 +
 +
If this is a new drive, you will need to create a new primary partition. Do this by entering an n at the prompt followed by p for primary. Enter a partition number of 1. fdisk will then ask for the first and last sector. If you are formatting a new disk, hit enter at both questions. This will use the entire disk. When the process ends, hit p to verify you have the disk setup like you want it. Once you are happy with the partition table, hit w to write the partition table and exit fdisk.
 +
 +
=====Format The Drive=====
 +
 +
You now need to format the drive. To format the drive with an ext3 filesystem located at /dev/sdb1 and give it a label of usbdrive, issue the following command:
 +
mkfs.ext3 -L usbdrive /dev/sdb1
 +
 +
=====Mount The Drive=====
 +
 +
Finally you mount the drive. As mentioned before, the mount point has to exist before you issue the mount command. A typical place for USB drives to be mounted is /media. If there is already a mount point in /media you can check it by listing the directory contents of media.
 
  ll /media
 
  ll /media
mount /dev/sda1 /media/120Gbfat32 (ie. mount /media/120Gbfat32 no longer works)
+
 
  ls -lh /media/120Gbfat32/
+
Once you have a suitable location, make sure nothing is mounted there by issuing the mount command from the terminal with no arguments. If you wanted to mount the drive /dev/sdb1 at /media/usbdrive, you would issue the following command
  umount /dev/sda1 (when finished)
+
 
 +
  mount /dev/sdb1 /media/usbdrive
 +
  ls -lh /media/usbdrive/
 +
 
 +
=====UnMount the Drive=====
 +
 
 +
Unmount the drive before unplugging it with
 +
  umount /dev/sdb1
    
Note:  When configuring a USB drive to be used by the built in [[SME_Server:Documentation:Administration_Manual:Chapter10|Workstation Backup To USB]] you must ensure that the drive is not mounted automatically.  When configuring the Workstation Backup, it will look for unmounted removable drives and allow you to select what you want.  If the drive is already mounted when you configure it then you will get an error saying "No Removable disk available".
 
Note:  When configuring a USB drive to be used by the built in [[SME_Server:Documentation:Administration_Manual:Chapter10|Workstation Backup To USB]] you must ensure that the drive is not mounted automatically.  When configuring the Workstation Backup, it will look for unmounted removable drives and allow you to select what you want.  If the drive is already mounted when you configure it then you will get an error saying "No Removable disk available".
95

edits

Navigation menu