Drive volume serial number: any similar concept in Linux?
ProgrammingThis 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.
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.
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++?
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.
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.
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:
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:
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.