I am currently considering using squashfs to store information on flash drives. However, whenever the flash drive is inserted, Fedora 34 assigns it a device id (/dev/sd?) which may change from one boot to another, making it difficult to write scripts involving that drive. Is there any way to assign a label, to the drive or to the partition, which would assist in identifying the drive?
No, the squashfs filesystem format supports neither labels nor UUIDs.
(It seems squashfs is mostly meant to be used for “loop” mounts, where the /dev/loop# name is already known from the start. You’d store the actual squashfs image inside another “normal” filesystem, not directly on raw disk.)
As an alternative, the GPT partition table format allows you to define partition labels and UUIDs (accessible through the
by-partuuid symlinks) which exist independently of the filesystem within. You can set a custom partlabel through fdisk or gdisk, with the “change partition name” command.
(Linux will also attempt to generate pseudo-PARTUUID symlinks for partitions on MBR disks as well – only if the MBR has a non-zero “NT disk signature”.)
The flash drive may also provide a “physical” serial number and/or a WWN that is available through
The -EROFS filesystem is an alternative to squashfs; it still doesn’t support custom labels, but does support filesystem-level UUIDs.