LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-09-2004, 05:37 AM   #1
Saradas
LQ Newbie
 
Registered: Mar 2004
Posts: 3

Rep: Reputation: 0
Question Linux, usb-storage... how to mount them and see their partition table


Hello,
i have to make a software to mount/unmount USB disks. In particular, i found this file /proc/scsi/usb-storage* that tells me when the device is attached and when it isn't, but, it doesn't tell me the name of the relative device file in /dev
So, now my problems are:
1) Find out the name of the device-file in /dev for every file in /proc/scsi/usb-storage*
2) Find out how many partitions the disk keeps (because an usb disk might have different partitions)
3) For every partition know the device-file in /dev, the size on the disk and the file-system it uses

Any idea?

Thank you,
Saradas
 
Old 03-09-2004, 07:48 AM   #2
Andrew Benton
Senior Member
 
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
Plugin the USB device, open a terminal and type in dmesg
It should print up loads of stuff, browse through it looking for something that looks familier. For me, the computer usually assigns USB stuff to /dev/sda1 so I've applied the supermount patch, http://supermount-ng.sourceforge.net/ made a folder called mp3 in /mnt and added this line to /etc/fstab
none /mnt/mp3 supermount dev=/dev/sda1,fs=auto,--, 0 0
Now if I plug in an mp3 player, an Iomega USB hard disk or a digital camera it will automatically be mounted in /mnt/mp3 and any user can access it through an icon on their desktop. To look at the partitions on the USB hard drive I would plug it in and then use
cfdisk /dev/sda1
though it may need to be unmounted before you can actually do anything to it. You''l need to work that out.
 
Old 03-09-2004, 08:08 AM   #3
Saradas
LQ Newbie
 
Registered: Mar 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Hmmm, no, my goal is different. I know about all of this, but i don't want to do it this way, for the following reasons:
1) I want to be able to mount/unmount the devices manually and as normal user (the system has not to mount/unmount them automatically)
2) I have many USB devices, some of them use /dev/sda some others /dev/sda1, etc...
3) When i plug the USB devices in a different order sometimes they are sda, some other times they are sdb, etc

The points 2) and 3) make it impossible for me to correctly setup the fstab file.

In few words, i want to make a program that deals with usb-storage devices similarly to how Windows does. The user has NOT to worry what device-name the usbdisk has, it has not to worry to add lines to the fstab, and the user has to have the right to mount and unmount devices graphically where he/she prefers inside his home folder.

So i need to know:
1) How to detect when an usb-disk is plugged in
2) How to detect when an usb-disk is removed
3) The list of partitions inside the usb-disk and the relative device-files inside /dev

Thanx,
Luca
 
Old 03-11-2004, 11:04 AM   #4
free_ouyo
Member
 
Registered: Mar 2004
Location: Belgium
Distribution: Ubuntu
Posts: 133

Rep: Reputation: 15
Hope this will help you :
When inserted, the USB key woulb be visible with : "fdisk -l"
This give you all the hard drives with the properties (name : /dev/xxx + size) and the partitions.

That way, you will have the device (/dev/xxx), you only have to mount it on your selected mount-point.

free_ouyo
 
Old 03-11-2004, 02:13 PM   #5
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,941

Rep: Reputation: 129Reputation: 129
Re: Linux, usb-storage... how to mount them and see their partition table

Quote:
Originally posted by Saradas
Hello,
i have to make a software to mount/unmount USB disks.
Have you looked at USB Manager and Murasaki for this task?
Not sure if they'll help, but you'll know after a little homework. :}
 
Old 11-12-2008, 08:09 AM   #6
rvsivakumar17
LQ Newbie
 
Registered: Sep 2008
Posts: 1

Rep: Reputation: 0
Smile

Quote:
Originally Posted by Saradas View Post
Hmmm, no, my goal is different. I know about all of this, but i don't want to do it this way, for the following reasons:
1) I want to be able to mount/unmount the devices manually and as normal user (the system has not to mount/unmount them automatically)
2) I have many USB devices, some of them use /dev/sda some others /dev/sda1, etc...
3) When i plug the USB devices in a different order sometimes they are sda, some other times they are sdb, etc

The points 2) and 3) make it impossible for me to correctly setup the fstab file.

In few words, i want to make a program that deals with usb-storage devices similarly to how Windows does. The user has NOT to worry what device-name the usbdisk has, it has not to worry to add lines to the fstab, and the user has to have the right to mount and unmount devices graphically where he/she prefers inside his home folder.

So i need to know:
1) How to detect when an usb-disk is plugged in
2) How to detect when an usb-disk is removed
3) The list of partitions inside the usb-disk and the relative device-files inside /dev

Thanx,
Luca


Hi,

You can also try this following command " df -h " this command also shows the mounted devices in your system.i think it will be useful 2 u..

Thank u,

With Rgds,
Shiva.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB storage devices difficult to mount and use jaakkop Slackware 4 11-16-2005 04:03 PM
Cannot mount usb storage under 2.6.9 stelmed Slackware 6 12-12-2004 08:34 AM
how to mount a usb storage automatic ? lemon_hou Linux - Hardware 2 03-07-2004 10:55 PM
Errors trying to mount USB Mass Storage Device Ctawp Linux - Hardware 7 12-04-2003 01:32 AM
USB Mass Storage Partition oulevon Linux - Hardware 3 11-20-2002 05:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:32 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration