Wearing my paranoid sysadmin hat: given that the write protect switch on
SD cards is purely advisory, it would be a good idea to check that the
SD to USB adapter actually honours the advice. I.e. try to write to it
with write protect on.
[Slight pause.]
OK, thought I'd better try my own advice rather than just handing it
out. I put a microSD card out of an old phone into a SanDisk mSD -> SD
adapter and plugged that into my SanDisk SD -> USB adapter, mounted it
(FAT32 file system already on it) and wrote a file to it. Worked as
you'd expect. I then unmounted and unplugged it, flipped the write
protect switch and tried to remount. Result was
mount_msdosfs: /dev/da5s1: Input/output error
Mounting it read-only was fine. So, the write protect is honoured by at
least some SD -> USB adapters. Looks like Polytropn's idea is the way to
go if you want write protectable USB flash drives. The one I've got is a
SanDisk MicroMate Reader, it's USB 2.0 and can handle cards up to 32GB,
so it's just on the edge of what you need. I'd guess there's probably a
USB 3.0 version around by now.
As for formatting SD cards via a USB adapter, I've done that quite
often. So far I've written disk images using dd (for RPi), used
newfs_msdos for both FAT16 and FAT32 and plain newfs for UFS2
filesystems, all without problem.
Good point. I had presumed that the writable mount failed because it
tries to update the superblock, but making sure at the disk driver level
is sensible. With write protect enabled on the card:
fileserver:1# tail /var/log/messages
May 24 16:50:28 fileserver kernel: ugen3.7: <SanDisk> at usbus3
May 24 16:50:28 fileserver kernel: umass2: <SanDisk SDDR-113, class 0/0,
rev 2.00/94.12, addr 7> on usbus3
May 24 16:50:28 fileserver kernel: umass2: SCSI over Bulk-Only; quirks
= 0x4100
May 24 16:50:28 fileserver kernel: umass2:12:2:-1: Attached to scbus12
May 24 16:50:28 fileserver kernel: da5 at umass-sim2 bus 2 scbus12
target 0 lun 0
May 24 16:50:28 fileserver kernel: da5: <SanDisk SDDR-113 9412>
Removable Direct Access SCSI-0 device
May 24 16:50:28 fileserver kernel: da5: Serial Number 000000009412
May 24 16:50:28 fileserver kernel: da5: 40.000MB/s transfers
May 24 16:50:28 fileserver kernel: da5: 3768MB (7716864 512 byte
sectors: 255H 63S/T 480C)
May 24 16:50:28 fileserver kernel: da5: quirks=0x2<NO_6_BYTE>
fileserver:1# dd if=/dev/zero of=/dev/da5 bs=4k count=1
dd: /dev/da5: Input/output error
1+0 records in
0+0 records out
0 bytes transferred in 2.353360 secs (0 bytes/sec)
Yes, it works at the disk driver level.
Gary, if you want bigger/faster than my adapter, there's a USB3.0
version of my adapter available, look for the SanDisk Extreme PRO®
SDHC™/SDXC™ UHS-II Card Reader/Writer, aka the SanDisk SDDR-329. You'll
need to check it honours the write protect switch of course.