I've been working with making custom bootloader and kernel code (not necessarily Linux kernel). I'm putting the images on USB, and was using dd to place them on the sector they needed to be on, and I'm getting tired of burning the image to /dev/sda instead of /dev/sdb (effectively destroying my hard drive).

So I was wondering if I could somehow give user access to the 'dd' command, but only to the /dev/sdb drive, so that if I accidentally type /dev/sda it won't let me, because I wouldn't have run the command as sudo or root.


you can make a dd wrapper script that uses sudo, which will only take your bootloader file. that way, you're not likely to make errors if you just keep using your script.

i'm not sure it's worth it to do it using real permissions.

sample script:

sudo dd bs=4K count=1 if=$1 of=/dev/sdb
  • Thats actually a much better idea, it never occurred to me. – codesmith Mar 25 '12 at 0:11
  • You can then control permissions on the script if for some reason you needed to do that. sudo can also be told what programs certain unprivileged users can run if you are interested. – Huckle Mar 25 '12 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.