Tuesday, September 21, 2010

Linux mount USB

USB disks are used more and more and almost nobody thinks about how a USB drive is attached to the computer. You plugin your disk and it works. When you are done you get your drive and move on. When using windows or most of the Linux GUI driven systems there is nothing to think about. However, if you run a couple of commandline only Linux systems you have to do more than only plugin your USB cable. However, it is not very hard to do this from a Linux shell in a manual way. Basicly it is the same as mounting a new drive or network drive on your system.

The trick is to find out where the drive is mounted under /dev and then mount it at a location on your system by using the standard commands you are used to.

When you attache your USb drive to the system it can be good to have a tail -f running on your /var/log/messsages. You will find a message somthing like the one below when you attache your drive.


Sep 16 17:26:09 homebox00 kernel: [2063013.339435] usb 4-1: new high speed USB device using ehci_hcd and address 4
Sep 16 17:26:10 homebox00 kernel: [2063013.472602] usb 4-1: configuration #1 chosen from 1 choice
Sep 16 17:26:10 homebox00 kernel: [2063013.476190] scsi4 : SCSI emulation for USB Mass Storage devices
Sep 16 17:26:10 homebox00 kernel: [2063013.477177] usb 4-1: New USB device found, idVendor=1058, idProduct=1001
Sep 16 17:26:10 homebox00 kernel: [2063013.477849] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 16 17:26:10 homebox00 kernel: [2063013.478958] usb 4-1: Product: External HDD
Sep 16 17:26:10 homebox00 kernel: [2063013.479588] usb 4-1: Manufacturer: Western Digital
Sep 16 17:26:10 homebox00 kernel: [2063013.480205] usb 4-1: SerialNumber: 574341553433383836343732
Sep 16 17:26:15 homebox00 kernel: [2063018.486535] scsi 4:0:0:0: Direct-Access WD 10EAVS External 1.05 PQ: 0 ANSI: 4
Sep 16 17:26:15 homebox00 kernel: [2063018.504738] sd 4:0:0:0: [sda] 1953525168 512-byte hardware sectors (1000205 MB)
Sep 16 17:26:15 homebox00 kernel: [2063018.506813] sd 4:0:0:0: [sda] Write Protect is off
Sep 16 17:26:15 homebox00 kernel: [2063018.509230] sd 4:0:0:0: [sda] 1953525168 512-byte hardware sectors (1000205 MB)
Sep 16 17:26:15 homebox00 kernel: [2063018.511297] sd 4:0:0:0: [sda] Write Protect is off
Sep 16 17:26:15 homebox00 kernel: [2063018.512656] sda: unknown partition table
Sep 16 17:26:15 homebox00 kernel: [2063018.518501] sd 4:0:0:0: [sda] Attached SCSI disk


From this you can see that the new drive is at /dev/sda . At the system I am attaching this drive I have a directory at /storage/disk0 and I will use this location to mount the USB drive.

You can now simply use the below command:
mount /dev/sda /storage/disk0

If you do a df -h you will see the new drive attached to your /storage/disk0 location. This can be any other location you want.



No comments: