I'm using up to date Arch Linux 5.12.5.
SD cards from time to time become corrupted, and if not bricked have to be reset/ reformatted.
I do this as follows
# 1. unmount the card / make sure it's unmounted
umount /dev/mmcblk0
umount /dev/mmcblk0p1
# 2. wipe the card. After this the card cannot be mounted becasue
# there is no partition. There's nothing on it at all.
echo password | sudo -S dd bs=4M if=/dev/zero of=/dev/mmcblk0 oflag=sync
# 3. create a GPT partition table
# the "-s" defaults the go ahead answer to "yes" so that
# no user input is necessary rather confusingly the
# command is 'mklabel' for creating a partition table!
sudo parted -s /dev/mmcblk0 mklabel gpt
# 4. create a GPT file system
# HAVING THE "-E root_owner=$UID:$GID" IS ESSENTIAL,
# OTHERWISE THE PARTITION CAN ONLY BE WRITTEN TO AS ROOT
sudo mkfs.ext4 -F -O ^64bit -E root_owner=$UID:$GID -L 'SD_CARD' '/dev/mmcblk0'
If I use the below line, ie miss out setting the UID:GID to me as above, then ownership of the file system is for root only and the SD card cannot be written to by anyone other than root
sudo mkfs.ext4 -F -O ^64bit -L 'SD_CARD' '/dev/mmcblk0
When I use the below line, which sets the UID:GID to my UID:GID, then ownership of the file system is for me only and the SD card cannot be written to by anyone other than me
sudo mkfs.ext4 -F -O ^64bit -E root_owner=$UID:$GID -L 'SD_CARD' '/dev/mmcblk0'
How do I set the UID:GID so that the SD card file system can be written to by anyone?