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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-09-2004, 05:37 AM
|
#1
|
LQ Newbie
Registered: Mar 2004
Posts: 3
Rep:
|
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
|
|
|
03-09-2004, 07:48 AM
|
#2
|
Senior Member
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073
Rep:
|
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.
|
|
|
03-09-2004, 08:08 AM
|
#3
|
LQ Newbie
Registered: Mar 2004
Posts: 3
Original Poster
Rep:
|
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
|
|
|
03-11-2004, 11:04 AM
|
#4
|
Member
Registered: Mar 2004
Location: Belgium
Distribution: Ubuntu
Posts: 133
Rep:
|
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
|
|
|
03-11-2004, 02:13 PM
|
#5
|
HCL Maintainer
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,941
Rep:
|
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. :}
|
|
|
11-12-2008, 08:09 AM
|
#6
|
LQ Newbie
Registered: Sep 2008
Posts: 1
Rep:
|
Quote:
Originally Posted by Saradas
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.
|
|
|
All times are GMT -5. The time now is 11:32 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|