Perform dd operation from a snap

Hi, I want to create a snap that can run a dd command like :

dd if=/dev/zero of=/dev/sda bs=4096 count=6

Could someone tell me which plug gives the permission to do this?

Because snappy-debug doesnt give me any useful responses.

i always get an error when i try runnin gthe above command through a snap.

dd: failed to open ‘/dev/sda’: Operation not permitted

I have connected “raw-usb” interface already

Hi Rahul,

I think raw-volume would do what you need.

Keep in mind auto-connection of raw-volume, if you need it, is usually handled by your gadget snap, so you will have to file a support case with us if the interface serves your needs and you require auto-connection and allow-installation permissions.

  • Daniel

But this volume is an external usb mounted as /dev/sda. Would i still have to use raw-volume interface? Since this volume is not present all the time and only appears when the usb is plugged in

now that you mention it, you may need to use block-devices instead, since I think raw-volume requires a volume (filesystem) to be present.

If your USB device always appears as the /dev/sda block device, the rules we would configure should cover it even if the device is not present.

I’ll ask the snapd team’s folks to confirm everything I’m saying but it’s probably worth trying on your side to see if it works as I described.

  • Daniel

Thank you, the block-devices interface works