question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ways to query udiskie for information

See original GitHub issue

I’m trying to automate some stuff right now (basically mount a specific LUKS partition as part of a bigger process) which requires me to figure out the current device ID of a partition. While this is almost trivial as root (parsing the output of tools like blkid or lsblk) it’s a lot more tedious to do as a regular user. I’m not even sure yet what the best way of implementing it will be. All I really need is a list of devices managed via udiskie/udisks2 (typically those not managed by /etc/fstab) with device file, file system, uuid, label, mount point (if any) and maybe size. So far I’ve been trying to build a bash script but the output of udisksctl is quite annoying to parse and working with dbus from bash is just plain masochism. You’d think that info is easy to get but alas…

So I could think of two ways to make this work in conjunction with udiskie:

  1. A cli tool like udiskie-info could be used to access information in simple readable format. For example
    • udiskie-info could output a simple list of block devices mounted/mountable via udisks
    • udiskie-info --blkid could output information in the typical blkid formatting. (In case anyone is wondering, native blkid doesn’t return reliable information when run as non-root.)
    • The output formatting options of lsblk could also serve as inspiration.
  2. If udiskie were to provide a (documented) Python API people could use that in a simple Python script and call it where needed. I’d really like that, actually.

Let me know what you think. If you know a better way of doing what I’m trying to do I’ll be happy as well.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coldfixcommented, Jul 3, 2016

Hey,

I’ve added a very basic udiskie-info. However, my main concern was a use-case of my own, so it may not address all your needs. Let me know if you’d like something changed/added or otherwise feel free to close the issue.

(Note that the exact command line interface may still change. This is also the reason that I will not add “official” documentation for this utility yet.)

Usage examples:

# list all managed devices:
$ udiskie-info -a
/dev/mapper/luks-7354dbf1-a8ee-4d70-bfcd-4e7d7ccc9af6
/dev/sdb
/dev/sdb1
/dev/sdb2
/dev/sdc
/dev/sdc1
/dev/sdd
/dev/sdd1
/dev/sr0

# list only luks devices
$ udiskie-info -a -f is_luks
/dev/sdb2

# list only filesystems that are not already mounted:
$ udiskie-info -a -f is_filesystem -f '!is_mounted'
/dev/mapper/luks-7354dbf1-a8ee-4d70-bfcd-4e7d7ccc9af6
/dev/sdb1
/dev/sdc1
/dev/sdd1
...

# get partition labels for specific devices
$ udiskie-info -o id_label /dev/sdb1 /dev/sdc1
MAD
STÏCKŸé

At this time, you can only have one output column, but several filters.

0reactions
philercommented, Feb 26, 2017

That’s really cool, thanks for adding!

(btw it didn’t quite work when you mentioned it but now it does.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

udiskie(8) - Arch manual pages
udiskie is an udisks2 front-end written in python. Its main purpose is automatically mounting removable media, such as CDs or flash drives.
Read more >
How to use the udiskie.locale._ function in udiskie | Snyk
To help you get started, we've selected a few udiskie.locale._ examples, based on popular ... _log.info(_('unlocked {0} using keyfile', device)) return True.
Read more >
udiskie · PyPI
If you need a version of udiskie that supports python2, please check out the 1.7. ... add format strings for the undocumented udiskie-info...
Read more >
udisks - Freedesktop.org
udisks · a daemon, udisksd, that implements well-defined D-Bus interfaces that can be used to query and manipulate storage devices. · a command- ......
Read more >
Ubuntu Manpage: udisksctl - The udisks command line tool
udisksctl - The udisks command line tool. SYNOPSIS. udisksctl status udisksctl info {--object-path OBJECT | --block-device DEVICE} udisksctl mount ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found