LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-05-2010, 12:55 AM   #1
manucng
LQ Newbie
 
Registered: Feb 2010
Location: bangalore
Posts: 1

Rep: Reputation: 0
Smile How to get Drive letter and serial number of thumb drive in linux?


Hi All,

I am new to Linux ,i did one project in windows which will block the thumb drive with respect to serial number(Device instance ID) of the device.i am planning to do the same project in Linux using c/c++.I am very new to Linux,there is no drive letter for thumb drives we insert into Linux OS.How to get Drive letter and how to get Device instance id of thumb drives please help me get some clues.please provide me any tutorial or any links .

Please let me know if have any other clues to block devices with respect "block list" and "allow device list".if the serial number in block list it has to block if serial number in allow device list it has to allow thumb drive to access.


regards,
manu
 
Old 02-05-2010, 01:41 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello and Welcome to LinuxQuestions,

As you stated yourself:
Quote:
there is no drive letter for thumb drives we insert into Linux OS
so don't look for one, you will not find it. Drives are mounted in Linux so you'd have to look for the mountpoints with the mount command. More info on the mount command can be found reading the man page:
Code:
man mount
Device information can be found with several commands, start out with
Code:
lspci
lsusb
and take it from there.

Kind regards,

Eric
 
Old 02-05-2010, 02:48 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Details vary from Linux distro to distro. This is for Slackware 13.0.

Here's an excerpt from /var/log/messages after plugging in a thumb drive
Code:
Feb  5 13:12:12 CW8 kernel: usb 1-8: new high speed USB device using ehci_hcd and address 4
Feb  5 13:12:12 CW8 kernel: usb 1-8: New USB device found, idVendor=0781, idProduct=5151
Feb  5 13:12:12 CW8 kernel: usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Feb  5 13:12:12 CW8 kernel: usb 1-8: Product: Cruzer Micro
Feb  5 13:12:12 CW8 kernel: usb 1-8: Manufacturer: SanDisk Corporation
Feb  5 13:12:12 CW8 kernel: usb 1-8: SerialNumber: 20042203931424B115DC
Feb  5 13:12:12 CW8 kernel: usb 1-8: configuration #1 chosen from 1 choice
Feb  5 13:12:12 CW8 kernel: scsi6 : SCSI emulation for USB Mass Storage devices
Feb  5 13:12:17 CW8 kernel: scsi 6:0:0:0: Direct-Access     SanDisk  Cruzer Micro     0.1  PQ: 0 ANSI: 2
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] 4001760 512-byte hardware sectors: (2.04 GB/1.90 GiB)
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] Write Protect is off
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] 4001760 512-byte hardware sectors: (2.04 GB/1.90 GiB)
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] Write Protect is off
Feb  5 13:12:17 CW8 kernel:  sdc: sdc1
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] Attached SCSI removable disk
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: Attached scsi generic sg3 type 0
The udev system is responsible for handling pluggable devices. It is configured by files under /etc/udev
 
Old 02-05-2010, 03:25 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can use "/sbin/udevadm info --query=property --name /dev/<device>" to print information about a device.
If you know the node, also look at "ls /dev/disk/by-uuid/* -l" or "ls /dev/disk/by-path/* -l". These will be symbolic links to the actual devices and contain the path or uuid in their name.

Using policy kit, you can disable the users ability to mount external drives all together.
You could also have an /etc/fstab entry for mounting a particular usb drives filesystem with "uid=" and/or "dmask" options that will only give access to a particular user. This will only work on that computer. If the user can use "sudo" or "su", then all bets are off.

For your own program, you would probably be working with policy kit to enforce your own policies.

Here is an overview about how policy kit works.
http://hal.freedesktop.org/docs/Poli...operation.html

Last edited by jschiwal; 02-05-2010 at 03:33 AM.
 
  


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
Using a usb thumb drive or flash drive as a swap partition. stevenjoseph Linux - Hardware 8 01-16-2012 01:09 PM
Only root can automount CD drive and USB thumb drive km4hr Red Hat 3 03-25-2009 01:30 PM
Changing the System Volume Serial Number on the Hard drive ElMastermind Linux - Hardware 4 08-15-2008 11:30 PM
Drive volume serial number: any similar concept in Linux? viettrung Programming 8 01-12-2007 09:54 AM
Hard Drive Serial Number? daver Linux - Hardware 4 03-17-2004 10:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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