I was installing RedSleeve onto my new Raspberry PI and needed to fix a problem when writing the image onto the SD card. I kept getting “Permission denied” error messages, when issuing the command to write the image.
Let’s see…
Am I using sudo? Yes I am.
Is the disk unmount before trying to write to it? Yes it is.
Ok everything seems to be in order. Let’s check my command
sudo xz -cd raspi-v2-redsleeve-cli-0.3.img.xz | dd of=/dev/rdisk1 bs=8388608
Ah, Ha!! sudo is not being applied to the part of the command after the pipe.
Ok, how to solve this. We can use the “-c” switch on the bash command to apply sudo to the entire command string.
sudo bash -c 'xz -cd raspi-v2-redsleeve-cli-0.3.img.xz | dd of=/dev/rdisk1 bs=8388608'
Now my SD is being written to.
Thank you VERY much…I wasted some hours before I found this.
Thanks!!
Awesome blog post! I really enjoyed reading this content. Keep posting.
Thank you. This too saved me some time. I also found a slightly simpler solution: just place 'sudo' a second time after the pipe:
sudo xz ….. | sudo dd …..
This appears to work as well…
Bless your heart.