LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
LinkBack Search this Thread
Old 07-27-2007, 01:46 AM   #1
nasirdaudahmad
LQ Newbie
 
Registered: Dec 2006
Posts: 10

Rep: Reputation: 0
Mounting USB flash drive


Hi
I am using red hat linux 7.1 and I want to mount USB Flash drive how can I do this.
Nasir
 
Old 07-27-2007, 02:34 AM   #2
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

Rep: Reputation: 30
Worth a try:

0. plug in your usb drive
1. as root; fdisk -l
2. find the /dev/??? of your flash drive
3. make a folder anywhere with mkdir.
4. use the command "mount /dev/??? /absolutepathofmynewfolder"
5. the files of your flash disk would now be accesible by going to the folder you created and mounted the flash drive too.
 
Old 07-27-2007, 02:44 AM   #3
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Above should be fine, here's an example too; it assumes the Flash disk's device file was /dev/sda1 and that you would like to mount it under /media/flashdisk. The device file name depends on your configuration (SATA harddrives and USB flash memory keys etc. use sdX device file naming scheme, so the last character and partition number depend on the configuration - on systems with no SATA disks the first plugged disk is usually sda1).

Create the mountpoint if it does not exist already:
Code:
mkdir -p /media/flashdisk
Try to mount the disk, list contents and then umount it:
Code:
mount /dev/sda1 /media/flashdisk
ls /media/flashdisk
umount /media/flashdisk
If that worked, add an fstab entry to ease things up; let's edit the file /etc/fstab and add a new line there like this: device_file mountpoint filesystem_type options 0 0
Code:
/dev/sda1 /media/flashdisk auto defaults,rw 0 0
Save and exit. Now you should be able to mount the disk just by
Code:
mount /media/flashdisk
and umount it using
Code:
umount /media/flashdisk
The above process is done as root (you can't edit fstab as non-root user, and usually mounting is restricted to root only by default). To be able to use the disk as a non-root user also, you must change the configuration a bit; usually this means adding the preferred user to the group mount or equivalent, to let him mount devices, and then making the mountpoint accessible to the user (usually it's owned by root). The latter depends a bit on the filesystem on the device too; for ext3 it's sufficient to change ownership or permissions on the mountpoint (while device is mounted), for FAT filesystem (like most flash disk) you might need to provide an option umask=number in the fstab line (or to mount command) to set a user mask to the device's permissions, which are usually such that non-root users can not write to the device, possibly only read. A mask can be understood as a value that is substracted from the permissions value to get the result. More about this is on the web and other threads, please search.

Last edited by b0uncer; 07-27-2007 at 02:47 AM.
 
Old 07-27-2007, 02:44 AM   #4
brianmcgee
Member
 
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 398

Rep: Reputation: 36
First you have to identify how to talk to your flash drive.

Code:
$ # tail -f /var/log/messages
Then attach your USB device and you will see a similar output:

Quote:
Jul 25 20:14:04 mobilix-03 kernel: usb 5-6: new high speed USB device using ehci_hcd and address 2
Jul 25 20:14:05 mobilix-03 kernel: usb 5-6: configuration #1 chosen from 1 choice
Jul 25 20:14:05 mobilix-03 kernel: SCSI subsystem initialized
Jul 25 20:14:05 mobilix-03 kernel: Initializing USB Mass Storage driver...
Jul 25 20:14:05 mobilix-03 kernel: scsi0 : SCSI emulation for USB Mass Storage devices
Jul 25 20:14:05 mobilix-03 kernel: usbcore: registered new driver usb-storage
Jul 25 20:14:05 mobilix-03 kernel: USB Mass Storage support registered.
Jul 25 20:14:10 mobilix-03 kernel: Vendor: SanDisk Model: U3 Cruzer Micro Rev: 2.18
Jul 25 20:14:10 mobilix-03 kernel: Type: Direct-Access ANSI SCSI revision: 02
Jul 25 20:14:10 mobilix-03 kernel: Vendor: SanDisk Model: U3 Cruzer Micro Rev: 2.18
Jul 25 20:14:10 mobilix-03 kernel: Type: CD-ROM ANSI SCSI revision: 02
Jul 25 20:14:10 mobilix-03 kernel: scsi 0:0:0:0: Attached scsi generic sg0 type 0
Jul 25 20:14:10 mobilix-03 kernel: scsi 0:0:0:1: Attached scsi generic sg1 type 5
Jul 25 20:14:10 mobilix-03 kernel: sr0: scsi3-mmc drive: 8x/40x writer xa/form2 cdda tray
Jul 25 20:14:10 mobilix-03 kernel: SCSI device sda: 990865 512-byte hdwr sectors (507 MB)
Jul 25 20:14:10 mobilix-03 kernel: sda: Write Protect is off
Jul 25 20:14:10 mobilix-03 kernel: sda: assuming drive cache: write through
Jul 25 20:14:10 mobilix-03 kernel: SCSI device sda: 990865 512-byte hdwr sectors (507 MB)
Jul 25 20:14:10 mobilix-03 kernel: sda: Write Protect is off
Jul 25 20:14:10 mobilix-03 kernel: sda: assuming drive cache: write through
Jul 25 20:14:10 mobilix-03 kernel: sda: sda1
Jul 25 20:14:10 mobilix-03 kernel: sd 0:0:0:0: Attached scsi removable disk sda
Now you know that your USB Stick was found correctly and has been assigned to /dev/sda

You can also check with

Code:
# cat /proc/partitions
or
Code:
# fdisk -l
If you have not configured automount then you can mount the flash disk with

Code:
# mkdir -p /mnt/usbdisk
# mount -t vfat /dev/sda /mnt/usbdisk
 
Old 07-27-2007, 03:28 AM   #5
sunils1973
Member
 
Registered: Jan 2007
Posts: 302

Rep: Reputation: 30
Quote:
Originally Posted by nasirdaudahmad
Hi
I am using red hat linux 7.1 and I want to mount USB Flash drive how can I do this.
Nasir
but I am using debian with 2.6 kernel

there is no entry in device file sda1

but sdb is there also ttyS1 and I guesss sdb is link to ttyS1

I applied the command
#mount -t /dev/sdb /mnt

then message "you should mention the filesystem type"

then

#mount -t usbfs /mnt

The command worked and i was able to find some entries in the /mnt directory. But it was not what i expected. Instead of the directories and files in the usb, it displayed

001 002 003 ....(which are folders) and a text file (I don't remember the text file name. but the entries on it was about usb information.).

Inside the folders there were text files with the same name. I did'nt view the contents of these text files.
 
Old 07-27-2007, 03:32 AM   #6
sunils1973
Member
 
Registered: Jan 2007
Posts: 302

Rep: Reputation: 30
Quote:
Originally Posted by nasirdaudahmad
Hi
I am using red hat linux 7.1 and I want to mount USB Flash drive how can I do this.
Nasir
but I am using debian with 2.6 kernel

there is no entry in device file sda1

but sdb is there also ttyS1 and I guesss sdb is link to ttyS1

I applied the command
#mount -t /dev/sdb /mnt

then message "you should mention the filesystem type"

then

#mount -t /dev/sdb usbfs /mnt

The command worked and i was able to find some entries in the /mnt directory. But it was not what i expected. Instead of the directories and files in the usb, it displayed

001 002 003 ....(which are folders) and a text file (I don't remember the text file name. but the entries on it was about usb information.).

Inside the folders there were text files with the same name. I did'nt view the contents of these text files.
 
Old 07-27-2007, 08:45 AM   #7
Hern_28
Member
 
Registered: Mar 2007
Location: North Carolina
Distribution: Slackware 12.0, Gentoo, LFS, Debian, Kubuntu.
Posts: 906

Rep: Reputation: 38
Error in command.

The -t option is expecting a file system type. Try mount -t vfat /dev/$$$ /mnt/### where $$$ = the name given to the device by the system and ###=directory you created to mount the device( you can create a custom directory with mkdir /mnt/(whatever you want to name it).

If you just use the /mnt directory it can give wierd output because you have other drives mounted to folders inside that directory.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting a USB Flash drive carlgulliver100 Linux - Software 2 11-13-2006 11:51 AM
Mounting a USB Flash Drive hm3buzz Linux - Hardware 4 08-25-2006 10:05 AM
USB flash drive mounting android6011 Linux - Hardware 5 01-03-2006 07:45 PM
USB Flash Drive not Mounting Kentara Linux - Hardware 1 03-12-2005 08:59 AM
Mounting a USB Flash Drive Garibaldi3489 Slackware 3 01-04-2005 09:09 PM


All times are GMT -5. The time now is 05:07 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration