The block-devices interface

block-devices provides the ability to perform operations on raw disk block devices. This interface gives privileged access to the device.

Auto-connect: no Super-privileged: yes

Requires snapd version 2.37+.

Consumers of this interface require a snap declaration for distribution via the Snap Store.

ⓘ This is a snap interface. See Interface management and Supported interfaces for further details on how interfaces are used.

1 Like

Looking for some details on how to use this interface. Is this the only place the block-devices interface is documented?

Thanks

Yes, though you can examine the code here: https://github.com/snapcore/snapd/blob/master/interfaces/builtin/block_devices.go

You might also be interested in The udisks2 interface

1 Like

I unable to run echo test > /dev/sdb in the runtime shell after connecting to this interface, is there other requirements for the block device access?

$ snap run --shell wild-block-device-filler
$ stat /dev/sdb
  File: /dev/sdb
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 6h/6d   Inode: 880         Links: 1     Device type: 8,10
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2020-12-21 11:12:47.311745859 +0800
Modify: 2020-12-21 11:12:47.311745859 +0800
Change: 2020-12-21 11:12:47.311745859 +0800
 Birth: -
$ echo test >/dev/sdb
bash: /dev/sdb: Permission denied

The device is a USB pen drive to be specific.

Additional info

  • Works in devmode when run as root
  • I expect the command should work when run as a regular user after connecting to the interface.