USB Flash Drive Handling
Now I want to manually mount, write to, and manage USB flash drives. Auto-mount will be disabled. Below is a memo explaining how to do it.
Detection vs Mounting vs Permissions
| Layer | Symptom | Meaning |
|---|---|---|
| Detection | no /dev/sdX |
hardware / driver issue |
| Mount | device exists, not accessible | not mounted |
| Permissions | “Permission denied” | wrong mount options |
Diagnostics
Check device
lsblk
Check filesystem
blkid
Check kernel messages
dmesg | tail
Check read-only flag
cat /sys/block/sda/ro
Correct Workflow
Detect device
lsblk
Example:
sda 58.6G
└─sda1 58.6G
If ISO image → reformat
doas umount /mnt/usb # must not be inside mount dir
doas wipefs -a /dev/sda
doas fdisk /dev/sda
Inside fdisk:
o # new partition table
n # new partition
w # write
Format
exFAT:
doas mkfs.exfat /dev/sda1
Mount with correct permissions
doas mount -t exfat -o uid=$(id -u),gid=$(id -g) /dev/sda1 /mnt/usb
Use
touch /mnt/usb/testfile
ls /mnt/usb
Unmount
cd ~
doas umount /mnt/usb