Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:28:55+00:00 2026-05-24T03:28:55+00:00

I was looking at libblkid and was confused about the documentation. Could someone provide

  • 0

I was looking at libblkid and was confused about the documentation. Could someone provide me with an example of how I could find the UUID of a root linux partition using this library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:28:56+00:00Added an answer on May 24, 2026 at 3:28 am

    It’s pretty much as simple as the manual makes it look: you create a probe structure, initialize it, ask it for some information, and then free it. And you can combine the first two steps into one. This is a working program:

    #include <stdio.h>
    #include <stdlib.h>
    #include <err.h>
    #include <blkid/blkid.h>
    
    int main (int argc, char *argv[]) {
      blkid_probe pr;
      const char *uuid;
    
      if (argc != 2) {
        fprintf(stderr, "Usage: %s devname\n", argv[0]);
        exit(1);
      }
    
      pr = blkid_new_probe_from_filename(argv[1]);
      if (!pr) {
        err(2, "Failed to open %s", argv[1]);
      }
    
      blkid_do_probe(pr);
      blkid_probe_lookup_value(pr, "UUID", &uuid, NULL);
    
      printf("UUID=%s\n", uuid);
    
      blkid_free_probe(pr);
    
      return 0;
    }
    

    blkid_probe_lookup_value sets uuid to point to a string that belongs to the pr structure, which is why the argument is of type const char *. If you needed to, you could copy it to a char * that you manage on your own, but for just passing to printf, that’s not needed. The fourth argument to blkid_probe_lookup_value lets you get the length of the returned value in case you need that as well. There are some subtle differences between blkid_do_probe, blkid_do_safeprobe, and blkid_do_fullprobe, but in cases where the device has a known filesystem and you just want to pull the UUID out of it, taking the first result from blkid_do_probe should do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a way to simulate a multiple keypress using jQuery. For example ALT+F1
Looking for opinions on if OpenCV could be or has been used to detect
Looking for a good example of how to set up child models in knockoutjs.
Looking for an example that: Launches an EXE Waits for the EXE to finish.
Looking for a Linux application (or Firefox extension) that will allow me to scrape
Looking for web service that download a webpage (we'll provide the URL), normalize it
Looking at using a Javascript MVC framework to build a web app (without using
Looking for hidden files: $ find . -type f -not -name . ./.kjj.jpg ./2.jpg.~1~
Looking for a good set of base objects to start a website up in
Looking to move data from a table A to history table B every X

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.