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.
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.