LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 01-08-2007, 12:54 PM   #1
viettrung
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Rep: Reputation: 0
Question Drive volume serial number: any similar concept in Linux?


Hallo experts,

i am a newbie in Linux. As far as i know, in Windows each drive (i mean, a logical partition, not physical hard disk) is assigned an unique serial number, named 'volume number or volume ID', when it is formatted. So i wonder if there is any similar concept in Linux?

If so, how can i program to get the volume number of the current working logical partition in Linux (if exists) using C++?

Thanks in advance!

Best regards,

.viettrung.

Last edited by viettrung; 01-08-2007 at 12:56 PM.
 
Old 01-08-2007, 01:35 PM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
I think you're thinking of the device node name? (Like /dev/sda, IIRC for Linux; in BSD they are things like sd0a and wd1b because they have a different partitioning / slicing method than Linux & Windows.)

I'm not sure, but I would think the answer would be no, because the filesystem abstracts this information away (since disks can be mounted at any point). Theoretically you could check the active mount table with the current working directory, but the notion of a union filesystem would make this method kind of useless.

Last edited by taylor_venable; 01-08-2007 at 01:37 PM.
 
Old 01-09-2007, 02:20 AM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I think he means the disk LABEL which is file system dependent. ext2 and maybe others linux file systems have it. 'tune2fs' can be used(for ext2-3) to set the label or it can be set during creation.
 
Old 01-09-2007, 04:48 AM   #4
runnerfrog
Member
 
Registered: Jul 2006
Location: Paraná, Argentina
Distribution: Frugalware 0.6 (Terminus) - Kubuntu 7.04 (Feisty Fawn Herd 5)
Posts: 217

Rep: Reputation: 31
Hi, be welcome.
I can be wrong at this, but I believe he/she means exactly what it says there, "logical partition [...] unique serial number", that will be the Universally Unique Identifier (UUID).
An UUID (128 bits) into /etc/fstab looks like this:
Code:
# /dev/hdb10
UUID=2c619834-f4fe-4038-bc5a-f1a0c9c80178 /usr/local reiserfs defaults 0 2
You can see all your partitions UUID's at /dev/disk/by-uuid

I _suck_ at programming, so excuse that, but perhaps this tiny code might help you to understand how to copy the UUID from a source to a destination, using the uuid library:
Code:
#include <uuid/uuid.h>
void uuid_copy(uuid_t destination, uuid_t source);
Please everyone excuse that if it doesn't help.
 
Old 01-09-2007, 11:44 AM   #5
viettrung
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Hi experts,

Thanks for all your suggestions. I'm sorry for replying late.

It seems to me that the concept of Universally Unique Identifier (UUID) that 'runnerfrog' suggested is quite close to what i need to know. I have tried to google this concept to get deeper understanding. Thanks!

If you have any more suggestions or explaination, please let me know. Thanks so much for your time.

Best regards,

.viettrung.
 
Old 01-09-2007, 12:38 PM   #6
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
If its for protection of contents or security measure or whatever copyright thinggy, you have to know that its easy to bypass.
 
Old 01-09-2007, 02:15 PM   #7
viettrung
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks so much for your advice, nx5000. I will consider about that.

I have tried to google what UUID is, and know that UUID for disk partition in Linux is just one use of UUID. So I think the library <uuid/uuid.h> may be not particularly used for getting UUID of a disk partition. Now I try to find out the way to get the UUID of current working partition in Linux using C++. I have tried hard with Google, but so far I get no suitable result. Can anybody help?

Thanks in advance.

.viettrung.
 
Old 01-11-2007, 02:37 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
The command 'blkid' will return the UUID label.
 
Old 01-12-2007, 08:54 AM   #9
viettrung
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Hi gnashley,

Thank you very much for your suggestion. Actually i also got the same idea from my friend just few minutes before i've read your reply. Thank you!

By the way, i have found a reference of using library libblkid (#include "libblkid/libblkid.h") to get the uuid of a existing partition in Linux: http://thunk.org/hg/e2fsprogs/?f=292...c/libblkid.txt.

i hope it may be helpful for someone who deals with the same matter.

Thank experts for helps so far!

.viettrung.
 
  


Reply



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
serial modem volume rayburn Debian 3 02-26-2006 07:15 AM
harddisk serial number secret_force Linux - Hardware 5 01-05-2006 09:15 AM
edit volume serial number (VSN) on floppy disk nvbauer Linux - Hardware 11 08-12-2005 07:44 AM
Hard Drive Serial Number? daver Linux - Hardware 4 03-17-2004 09:57 AM

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

All times are GMT -5. The time now is 08:57 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