Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become an Expert!

Join 244,060 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,387 people online right now. Registration is fast and FREE... Join Now!




Mounting A USB or Pen Drive In Linux

 
Reply to this topicStart new topic

> Mounting A USB or Pen Drive In Linux, mounting a Pen drive in linux

bsdninja
*



post 6 Jan, 2005 - 03:42 PM
Post #1


If you are having problems mounting a USB storage drive (hard drive or pen drive etc) first plug in the device and boot the computer. Watch your boot-up process to see if it detects the device. If so you probably won’t have to recompile your kernel.

First step is to go into your kernel’s source directory. Usually /usr/src/linux
If it is a recent kernel i.e. 2.6+ type:
QUOTE
make menuconfig


This will bring up a graphical menu of your kernel’s options, If you have to change anything here you must compile your kernel for the changes to take affect.

You want to enable scsi support and USB support like below if they are not already:

Device Drivers -------->
SCSI Device Support --------->
[*] legacy /proc/scsi/ support
<*> SCSI disk support
<*> SCSI generic support
USB Support -------------->
<*> Support for USB
[*] USB device filesystem
< > EHCI HCD (USB 2.0) support
< > OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
<*> USB Mass Storage support

If you experience problems with it still not seeing your drive try enabling EHCI or OHCI.

Now if you didn’t have to change anything here you can skip the compiling phase and go to mounting.

Next you need to compile. There are many ways to go about this so I'll just show you how I usually do it (recent kernels 2.6+). Type:
QUOTE
make (not necessary but I like to make sure)
(wait)
make modules
(wait)
make modules_install
(wait)
make bzImage
cp arch/i386/boot/bzImage /boot/linux-usb (you can name "linux-usb" what ever you want)


I will explain this next part for lilo if you use grub or something else your on your own here.

Edit your /etc/lilo.conf
and add:
CODE

       image=/boot/linux-usb (where linux-usb is the name of your image)
    label=name (where name is the name you want to pop up on lilo)
    read-only
    root=/dev/hda1 (where hda1 is what ever partition your using)

Now save and exit the lilo.conf file.
Now type "lilo" at the command line. It should say something about adding your image.
Reboot and make sure it all works.

*mounting*
If your kernel is all good and ready you should be able to mount
Go into your /dev directory
look for sdXX where XX is a leter and number ex: sda1.
Some distros will only make a dev for the devices you have and some will not. If there are a lot of sdXX's in there than just start with sda1 and try others if you have no luck.
Make a directory to mount your drive to ex:
QUOTE
mkdir /mnt/pendrive

Then mount it:
QUOTE

mount -t vfat /dev/sda1 /mnt/pendrive
where vfat is the type and sda1 is the dev for your drive.
the -t vfat is not allways nessisary but if it mounts and you have read or write errors then you need the -t vfat.
Well hopefully this helps someone. Oh don't forget to unmount using
umount /mnt/pendrive
Where /mnt/pendrive is the mount point.  If you dont unmount you will loose changes and risk messing up your partition.
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

_byte_
*



post 10 Jan, 2005 - 10:34 PM
Post #2
Description is gud! Let me try that on my linux.
Go to the top of the page
+Quote Post

Nova Dragoon
Group Icon



post 2 Jun, 2005 - 01:30 PM
Post #3
Some flashdrives do not have partitions. And linux will attach them to /dev/sda
Go to the top of the page
+Quote Post

Nova Dragoon
Group Icon



post 8 Jun, 2005 - 01:13 PM
Post #4
Many digital cameras will attach to linux as a usb mass-storage device and will be accessible the same way as a flash drive.

Ex. My Nikon CoolPix 4600
Go to the top of the page
+Quote Post

siddu_sundaram
*



post 11 Aug, 2005 - 11:08 PM
Post #5
hi
i have a problem when i am using this command to load my usb it just gives me details that it is not able to load this file system what may be the problem pls helproot@ttyp0[knoppix]# mkdir /mnt/usb/
root@ttyp0[knoppix]# mount -t -vfat /dev/sda /mnt/usb
mount: fs type -vfat not supported by kernel
root@ttyp0[knoppix]#

this is the reply i get when i am typing the command
thanks sad.gif
Go to the top of the page
+Quote Post

Nova Dragoon
Group Icon



post 12 Aug, 2005 - 07:21 AM
Post #6
Looks like you don't have vfat filesystem support compiled in your kernel.

Go to your source directory which should be
/usr/src/linux*.* ....

run:
make menuconfig

VFAT is found
In 2.6:
Goto Filesystems->DOS/FAT/NT Filesystems
Select VFat

In 2.4:
Goto Filesystems
Select DOS Fat fs support


Look here for more info on compiling and installing your kernel

If you need more help compiling your kernel, open up a new thread in the Operating Systems Forum.
Go to the top of the page
+Quote Post

born2c0de
Group Icon



post 12 Aug, 2005 - 08:02 AM
Post #7
Thanx Nova Dragoon, helped me out quite a bit.
Go to the top of the page
+Quote Post

amos
**



post 27 Sep, 2005 - 10:27 AM
Post #8
I've previously had all of the following attached to my box at one time or another as USB drives - pendrive, mp3 player (iRiver), camera, and mobile phone. Its probably 6 months or more since I upgraded to Slackware 10.1, for one reason or another I'd connected none of these recently. I've been using a 2.6.11 kernel which I compiled myself.(I might get round to slapt-get upgrading to 10.2 next weekend and compiling a newer kernel)

When I plugged my pendrive in the other month, so that I could copy something from it to my Linux box, I had the normal entries for it in fstab, but got an error when I tried to mount it.

Looking at dmesg after plugging the drive in gave me the following output:

CODE
usb 2-2.3: new full speed USB device using ehci_hcd and address 5
uba: device 5 capacity nsec 125952 bsize 512
uba: device 5 capacity nsec 125952 bsize 512
/dev/ub/a: p1


It used to have /dev/sda or /dev/sda1 as its mount point. I couldn't find any references to what was going on on Google or Linuxquestions.org, and I tried all of the combinations of /dev/ub* I could think of so I left it. I've now found a reply to someones similar query which boils down to:

If you enable BLK_DEV_UB it completely disrupts the USB-storage driver. So what you have to do is disable it in:

->Device Drivers
->Block Devices

and deselect the option for:
Low Performance USB Block driver

this should re-enable the SCSI drivers (after recompiling and installing the kernel) and restore the pendrive/camera/mp3 player to /dev/sd*.

Hope this helps anyone who was having similar problems to myself.

Cheers
Amos
Go to the top of the page
+Quote Post

Nova Dragoon
Group Icon



post 27 Sep, 2005 - 11:34 AM
Post #9
CONFIG_BLK_DEV_UB:

This driver supports certain USB attached storage devices
such as flash keys.

Warning: Enabling this cripples the usb-storage driver.

If unsure, say N.

Symbol: BLK_DEV_UB [=n]
Prompt: Low Performance USB Block driver
Defined at drivers/block/Kconfig:354
Depends on: USB
Location:
-> Device Drivers
-> Block devices


These guys are to blame tongue.gif
* Copyright © 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
* Copyright © 2004 Pete Zaitcev (zaitcev@yahoo.com)
Go to the top of the page
+Quote Post

amos
**



post 27 Sep, 2005 - 01:02 PM
Post #10
When I originally came across the problem at the end of July I did a search on both Google and linuxquestions and nothing showed up. It was only when I checked it out again today that I actually found anything.

I'm assuming it must have been enabled by default because the kernels on both my laptop and desktop had it enabled (and I configured both from scratch).

Cheers
Amos
Go to the top of the page
+Quote Post

Nova Dragoon
Group Icon



post 27 Sep, 2005 - 07:57 PM
Post #11
Thats weird, it shouldnt have been enabled by default, default is N in the config script?

Were you using Vanilla sources?
Go to the top of the page
+Quote Post

amos
**



post 28 Sep, 2005 - 09:10 AM
Post #12
QUOTE
Thats weird, it shouldnt have been enabled by default, default is N in the config script?

Were you using Vanilla sources?


Maybe I did enable it then, it just seems strange that I enabled it twice separately on 2 different machines. I assumed I'd used vanilla sources but I might have used a Slackware 2.6.x .config file to get me started I can't actually remember (but I doubt if that was the cause as I can't see Patrick rendering users' pendrives unusable without a kernel recompile).

Basically I must have done it! blush.gif

Twice! stupid.gif

Cheers
Amos

This post has been edited by amos: 28 Sep, 2005 - 09:11 AM
Go to the top of the page
+Quote Post

k.sangeeth
**



post 2 Aug, 2007 - 08:58 PM
Post #13
-t option in mount was very helpful .. good work
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
5 User(s) are reading this topic (5 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 7/3/09 11:16PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month