Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mount usb flash 1

Status
Not open for further replies.

asm1

Technical User
Oct 9, 2003
77
GB
hi all
does any body know how to mount a USB flash drive
 
USB drives usually appear as /dev/sda1 if you do not have other SCSI devices. try:

mount -t vfat /dev/sda1 /mnt/usb

Be sure to create /mnt/usb first.
 
thx for your promt reply i will give that a try tonight and let you know
 
ok first i tried
/mnt/usb
No such file or directory

then tried
mount -t vfat /dev/sda1 /mnt/usb
just gave me loads of help files, i am on Redhat 9
any ideas? thx

The tougher it gets the more you learn! The more you learn the tougher it gets!
 
Sorry if my info was a bit brief. Anyway, let take it from the top. First create a subdirectory named usb under the the mnt directory. This is where you will mount your flash drive. Actually, you can the subdirectory anything you want but I just called usb for consistency as we already have floppy and cdrom etc. The command to create the subdirectory is:

mkdir /mnt/usb

just incase you didn't know it. Next plugin your flash drive and type in this command to see if your system has registered the device.

dmesg | grep usb

The dmesg command alone will list out a whole lot of system info. We pipe this info to the grep command and tell it to only show us lines that have to word usb in them. You should get some output like

usb.c: registered new driver usb-storage

If you don't see such a line, most likely you don't have usb support built into the kernel. Now, if the system shows that it has recognized your flash drive, we move on to check what device is it registered as.

dmesg | grep sda

This will show us if your device is registered as device sda. You can substitute sda for sdb or sdc if you have other SCSI discs. You should get something like:

sda : READ CAPACITY failed.
sda : status = 1, message = 00, host = 0, driver = 08
sda : block size assumed to be 512 bytes, disk size 1GB.
sda : test WP failed, assume Write Enabled
sda: I/O error: dev 08:00, sector 0
SCSI device sda: 29120 512-byte hdwr sectors (15 MB)
sda : Write Protect is off
sda: sda1

I still do not know why I get these errors, but the idea is that from my output, I know that my usb drive is device sda1 from the last line. From here we just mount the device sda1 to the mount point that we had just created using the command:

mount -t vfat /dev/sda1 /mnt/usb

Change the above command if your device appears as sdb, sdc or any other such sd[x] device.
 
su: user mkdir does not exist
[tony@jstlinbox tony]$ su
Password:
[root@jstlinbox tony]# mkdir /mnt/usb
[root@jstlinbox tony]# dmesg | grep usb
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
usb-uhci.c: $Revision: 1.275 $ time 17:59:01 Mar 13 2003
usb-uhci.c: High bandwidth mode enabled
usb-uhci.c: USB UHCI at I/O 0xd400, IRQ 10
usb-uhci.c: Detected 2 ports
usb.c: new USB bus registered, assigned bus number 1
usb-uhci.c: v1.275:USB Universal Host Controller Interface driver
usb.c: registered new driver hiddev
usb.c: registered new driver hid
usb.c: USB device 2 (vend/prod 0x58f/0x9380) is not claimed by any active driver.
usb.c: registered new driver usb-storage
usb-uhci.c: interrupt, status 2, frame# 448
[root@jstlinbox tony]# dmesg | grep sda
[root@jstlinbox tony]#

no message after last command tried mount anyway but nothing
came into my new dir
thx for your time

The tougher it gets the more you learn! The more you learn the tougher it gets!
 
sorry i am stuck again i refer to the line
Verify that you have the needed kernel modules loaded. To find out what modules you have loaded, open a terminal window and type the following:

lsmod | more

from thr link

when i did this i get

[tony@jstlinbox tony]$ lsmod | more
bash: lsmod: command not found
[tony@jstlinbox tony]$ lsmod|more
bash: lsmod: command not found
[tony@jstlinbox tony]$


The tougher it gets the more you learn! The more you learn the tougher it gets!
 
I don't recall if you have to be root to run 'lsmod', but the binary itself is in '/sbin', which isn't in the normal user's $PATH (the '$' in your post above indicates you are doing this a normal user, not root). Not speaking for all distros, but I have found this to be the case on my Redhat 9 box.

If you use 'su' to switch to root, use 'su -'. That way you will get all your environment variables set, including the $PATH root needs to get some work done.


----
JBR
 
If dmesg says it finds a usb mass storage device then you have USB support in your kernel. Before you plug in your USB device type the following:

more /proc/partitions

Then plug in your mass storage device (USB drive) and type it again. You should see new partitions in this file. USB keys are funny and not all formatted the way you may think. I've found some that mount as /dev/sda1 or /dev/sda4. Look in the /proc/partitions file to see how many partitions are found on your SCSI partition or USB device. Try mounting each you see there. Then there is always the case where your USB device will not work with linux. This is pretty rare. I've only run into one. Most of the time it is a product of the formatting that may have come on your USB device as most mfg's unfortunately format these devices for the windows world. When I first got mine I had to mount it under linux, then run fdisk against it to delete all the partitions, then reformat the partitions again. I hope this is not the case for you however we can work all that out.

It may be helpful to post the contents of a:
1. fdisk -l
2. mount
3. the contents of /proc/partitions


Warmongr
 
is this what you aasked for

Code:
[tony@jstlinbox tony]$ su
Password:
[root@jstlinbox tony]# ismod | more
bash: ismod: command not found
[root@jstlinbox tony]# more /proc/partitions
major minor  #blocks  name     rio rmerge rsect ruse wio wmerge wsect wuse runni
ng use aveq
 
  22    64     496672 hdd 8 24 128 16470 0 0 0 0 -44465 29787040 10561585
   3     0    2499840 hda 52239 63373 923922 1234670 50262 86819 1099880 1538074
0 -9 29838290 21846894
   3     1     100768 hda1 32 80 224 590 17 7 48 5910 0 4360 6500
   3     2    2149056 hda2 36075 63141 793738 895580 34239 51385 685752 1838320
0 1109740 2736320
   3     3     249984 hda3 16130 146 129944 338460 16006 35427 414080 13536510 0
 1920370 13921480
[root@jstlinbox tony]# more /proc/partitions
major minor  #blocks  name     rio rmerge rsect ruse wio wmerge wsect wuse runni
ng use aveq
 
  22    64     496672 hdd 8 24 128 16470 0 0 0 0 -44514 29814940 14917470
   3     0    2499840 hda 52272 63425 924602 1235710 50431 86948 1102264 1543249
0 -11 29866180 21641514
   3     1     100768 hda1 32 80 224 590 17 7 48 5910 0 4360 6500
   3     2    2149056 hda2 36108 63193 794418 896620 34282 51494 686968 1840480
0 1111880 2739520
   3     3     249984 hda3 16130 146 129944 338460 16132 35447 415248 13586100 0
 1923570 13971070
[root@jstlinbox tony]# fdisk -1
bash: fdisk: command not found
[root@jstlinbox tony]# fdisk -l
bash: fdisk: command not found
[root@jstlinbox tony]# fdisk -i
bash: fdisk: command not found
[root@jstlinbox tony]#
[code]

what does this mean? is it supported?


The tougher it gets the more you learn! The more you learn the tougher it gets!
 
First part: I don't see any sda partitions in your post from /proc/partitions. Was your USB device plugged in.

My comments below **

tony@jstlinbox tony]$ su
Password:

** use 'su -' without quotes instead of just plain su. This ensures you take on roots environment including path. This explains 0alot of why you keep getting "command not found" errors.
[root@jstlinbox tony]# ismod | more

bash: ismod: command not found

** In this case you got a "command not found error" becuase the correct command is insmod. Additionally you are using it incorrectly. insmod is used to install kernel modules. lsmod lists kernel modules already loaded and depmod loads kernel modules and their dependancies if missing. (Tip: Alway use depmod) I believe what you were after here is dmesg|more

[root@jstlinbox tony]# more /proc/partitions
major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse runni
ng use aveq

22 64 496672 hdd 8 24 128 16470 0 0 0 0 -44465 29787040 10561585
3 0 2499840 hda 52239 63373 923922 1234670 50262 86819 1099880 1538074
0 -9 29838290 21846894
3 1 100768 hda1 32 80 224 590 17 7 48 5910 0 4360 6500
3 2 2149056 hda2 36075 63141 793738 895580 34239 51385 685752 1838320
0 1109740 2736320
3 3 249984 hda3 16130 146 129944 338460 16006 35427 414080 13536510 0
1920370 13921480

** You should see similar partition information above for sda1 sda2 etc depending on how you USB device is formatted.

[root@jstlinbox tony]# more /proc/partitions
major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse runni
ng use aveq

22 64 496672 hdd 8 24 128 16470 0 0 0 0 -44514 29814940 14917470
3 0 2499840 hda 52272 63425 924602 1235710 50431 86948 1102264 1543249
0 -11 29866180 21641514
3 1 100768 hda1 32 80 224 590 17 7 48 5910 0 4360 6500
3 2 2149056 hda2 36108 63193 794418 896620 34282 51494 686968 1840480
0 1111880 2739520
3 3 249984 hda3 16130 146 129944 338460 16132 35447 415248 13586100 0
1923570 13971070
[root@jstlinbox tony]# fdisk -1
bash: fdisk: command not found
** Here is the case where "su -" would have worked. You can always use /sbin/fdisk

[root@jstlinbox tony]# fdisk -l
bash: fdisk: command not found

** See note above
[root@jstlinbox tony]# fdisk -i
bash: fdisk: command not found

** See note above
[root@jstlinbox tony]#

Keep the faith brotha we'll get you there. BTW. What is the make and mfg for your usb device?

warmongr
 
First part: I don't see any sda partitions in your post from /proc/partitions. Was your USB device plugged in
the second time i did the more proc/partions command it was plugged in.

What is the make and mfg for your usb device?
not sure what an mfg is (is it "mount fat g???")
the make is "Mobile disk v3.0 TwinMos corp" thats all i know as i had it given.
the next bit is very long usb plugged in though
Code:
[tony@jstlinbox tony]$ s-
bash: s-: command not found
[tony@jstlinbox tony]$ su-
bash: su-: command not found
[tony@jstlinbox tony]$ su -
Password:
[root@jstlinbox root]# dmesg|more
Linux version 2.4.20-8 (bhcompile@porky.devel.redhat.com) (gcc version 3.2.2 200
30222 (Red Hat Linux 3.2.2-5)) #1 Thu Mar 13 17:54:28 EST 2003
BIOS-provided physical RAM map:
 BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
 BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
 BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
 BIOS-e820: 0000000000100000 - 0000000007ee0000 (usable)
 BIOS-e820: 0000000007ee0000 - 0000000007ef0000 (ACPI data)
 BIOS-e820: 0000000007ef0000 - 0000000007f00000 (ACPI NVS)
 BIOS-e820: 0000000007f00000 - 0000000008000000 (reserved)
 BIOS-e820: 00000000fff80000 - 0000000100000000 (reserved)
0MB HIGHMEM available.
126MB LOWMEM available.
On node 0 totalpages: 32480
zone(0): 4096 pages.
zone(1): 28384 pages.
zone(2): 0 pages.
Kernel command line: ro root=LABEL=/1
Initializing CPU#0
Detected 451.033 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 897.84 BogoMIPS
Memory: 123628k/129920k available (1347k kernel code, 4892k reserved, 999k data, 132k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 512K
CPU serial number disabled.
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
CPU:     After generic, caps: 0383f9ff 00000000 00000000 00000000
CPU:             Common caps: 0383f9ff 00000000 00000000 00000000
CPU: Intel Pentium III (Katmai) stepping 03
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... OK.
POSIX conformance testing by UNIFIX
mtrr: v1.40 (20010327) Richard Gooch (rgooch@atnf.csiro.au)
mtrr: detected mtrr type: Intel
PCI: PCI BIOS revision 2.10 entry at 0xfdb21, last bus=1
PCI: Using configuration type 1
PCI: Probing PCI hardware
Transparent bridge - Intel Corp. 82801AA PCI Bridge
PCI: Using IRQ router PIIX [8086/2410] at 00:1f.0
isapnp: Scanning for PnP cards...
isapnp: No Plug & Play device found
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
apm: BIOS not found.
Starting kswapd
VFS: Disk quotas vdquot_6.5.1
pty: 2048 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS MULTIPORT SHARE_IRQ SERIAL_PCI ISAPNP enabled
Real Time Clock Driver v1.10e
Floppy drive(s): fd0 is 1.44M
FDC 0 is a post-1991 82077
NET4: Frame Diverter 0.46
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Uniform Multi-Platform E-IDE driver Revision: 7.00beta-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH: IDE controller at PCI slot 00:1f.1
ICH: chipset revision 2
ICH: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:pio
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:pio, hdd:DMA
hda: WDC AC22500L, ATA DISK drive
blk: queue c03c9f40, I/O limit 4095Mb (mask 0xffffffff)
hdd: DVS DVD-ROM DSR-600H 990413MP, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
hda: task_no_data_intr: status=0x51 { DriveReady SeekComplete Error }
hda: task_no_data_intr: error=0x04 { DriveStatusError }
hda: 4999680 sectors (2560 MB) w/256KiB Cache, CHS=620/128/63, UDMA(33)
ide-floppy driver 0.99.newide
Partition check:
 hda: hda1 hda2 hda3
ide-floppy driver 0.99.newide
md: md driver 0.90.0 MAX_MD_DEVS=256, MD_SB_DISKS=27
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
Linux IP multicast router 0.06 plus PIM-SM
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
RAMDISK: Compressed image found at block 0
Freeing initrd memory: 146k freed
VFS: Mounted root (ext2 filesystem).
Journalled Block Device driver loaded
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
Freeing unused kernel memory: 132k freed
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
usb-uhci.c: $Revision: 1.275 $ time 17:59:01 Mar 13 2003
usb-uhci.c: High bandwidth mode enabled
PCI: Found IRQ 10 for device 00:1f.2
PCI: Setting latency timer of device 00:1f.2 to 64
usb-uhci.c: USB UHCI at I/O 0xd400, IRQ 10
usb-uhci.c: Detected 2 ports
usb.c: new USB bus registered, assigned bus number 1
hub.c: USB hub found
hub.c: 2 ports detected
usb-uhci.c: v1.275:USB Universal Host Controller Interface driver
usb.c: registered new driver hiddev
usb.c: registered new driver hid
hid-core.c: v1.8.1 Andreas Gal, Vojtech Pavlik <vojtech@suse.cz>
hid-core.c: USB HID support drivers
mice: PS/2 mouse device common for all mice
hub.c: new USB device 00:1f.2-1, assigned address 2
usb.c: USB device 2 (vend/prod 0x58f/0x9380) is not claimed by any active driver.
EXT3 FS 2.4-0.9.19, 19 August 2002 on ide0(3,2), internal journal
Adding Swap: 249976k swap-space (priority -1)
SCSI subsystem driver Revision: 1.00
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
usb-uhci.c: interrupt, status 2, frame# 458
scsi0 : SCSI emulation for USB Mass Storage devices
  Vendor: Generic   Model: Flash Disk        Rev: 7.77
  Type:   Direct-Access                      ANSI SCSI revision: 02
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 2
USB Mass Storage support registered.
kjournald starting.  Commit interval 5 seconds
EXT3 FS 2.4-0.9.19, 19 August 2002 on ide0(3,1), internal journal
EXT3-fs: mounted filesystem with ordered data mode.
parport0: PC-style at 0x378 [PCSPP,TRISTATE,EPP]
ip_tables: (C) 2000-2002 Netfilter core team
8139too Fast Ethernet driver 0.9.26
divert: allocating divert_blk for eth0
eth0: SMC1211TX EZCard 10/100 (RealTek RTL8139) at 0xc88bdf00, 00:00:e8:98:73:31, IRQ 11
eth0:  Identified 8139 chip type 'RTL-8139A'
eth0: Setting half-duplex based on auto-negotiated partner ability 0000.
parport0: PC-style at 0x378 [PCSPP,TRISTATE,EPP]
lp0: using parport0 (polling).
lp0: console ready
Linux agpgart interface v0.99 (c) Jeff Hartmann
agpgart: Maximum main memory to use for agp memory: 93M
agpgart: Detected an Intel i810 Chipset.
agpgart: AGP aperture is 64M @ 0xe8000000
memory : c6132980
memory : 00000000
memory : c6132900
ide-floppy driver 0.99.newide
hdd: ATAPI DVD-ROM drive, 512kB Cache, DMA
Uniform CD-ROM driver Revision: 3.12
[root@jstlinbox root]#

i think this is what u was asking for, RedHat can see the disk i think but where do i go from here? interesting to read anyway. thx again for your time






The tougher it gets the more you learn! The more you learn the tougher it gets!
 
i have now been able to mount the usb device by using
mount -t vfat /dev/sda1 /mnt/usb
so thank you warmonger and zeland for your help and also megisteric for the very good link. [medal]

The tougher it gets the more you learn! The more you learn the tougher it gets!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top