Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read UUID of hdd partitions in Linux by java program?  RSS feed

 
Mandar Khire
Ranch Hand
Posts: 582
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As i try to find out way to get UUID of HDD partitions in Linux.
I used command in terminal as follows:-

But it need administrative rights. After command sudo i can see following result:-


By java program how can i get one of these UUID? example only partition which label is 'home'?
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can list /dev/disk/by-uuid to get the list of uuids. If you want to match them back, they are softlinks to ../../dm-xx items, which could be cross-referenced to ID or label.

Note that labels are filesystem-specific, so not all filesystems support labels.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with Runtime#exec but didn't get any output from blkid.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!