-1

My HDD

Disk /dev/sdb: 927.5 GiB, 995875618816 bytes, 1945069568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc4094bc2

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sdb1            2048     718847     716800   350M  c W95 FAT32 (LBA)
/dev/sdb2          718848  269154303  268435456   128G  7 HPFS/NTFS/exFAT
/dev/sdb4       269156350 1945067519 1675911170 799.1G  f W95 Ext'd (LBA)
/dev/sdb5       403374080 1945067519 1541693440 735.1G  6 FAT16
/dev/sdb6       269156352  403374079  134217728    64G 83 Linux

I have formatted /dev/sdb5 as udf with

mkfs.udf --utf8 -l UDFStore /dev/sdb5

on Gentoo. But blkid doesn't list /dev/sdb5. How can I reliably mount my UDF partition at startup in /etc/fstab when device enumeration changes due to additional connected USB devices at startup.

Necktwi
  • 996
  • 5
  • 12
  • 22

2 Answers2

1

Aside from device names, you can mount filesystems using their UUID or label.

For example, if when you created the filesystem you labeled it UDFStore, you can add an /etc/fstab entry like this: LABEL=UDFStore /data udf defaults 0 0

Emmanuel Rosa
  • 6,808
  • 2
  • 18
  • 22
  • that didn't work. `lsblk` shows no label for `/dev/sdb5`. Stupid of me for voting up without testing. Ur answer felt very obvious! huh! – Necktwi Sep 08 '18 at 16:41
  • Plug in the device, then, run `find /dev/disk`. You'll see paths corresponding to your disks and partitions. Look through the directories `by-label`, `by-partlabel`, and `by-id`. Those are reliable paths, one of which may correspond to the UDF partition. To use filesystem or partition ID's, you can run `lsblk -o NAME,FSTYPE,LABEL,PARTLABEL,PARTUUID` and match those ID's with the appropriate path from the `find` command above, by looking for device files in the `by-uid` and `by-uuid` directories. Then in /etc/fstab` substitute `/dev/sdb5` with the reliable path of your choice. – Emmanuel Rosa Sep 09 '18 at 03:20
  • `lsblk` for my udf partition reports no `FSTYPE`,`LABEL`,`PARTLABEL` and `PARTUUID` – Necktwi Sep 09 '18 at 03:40
  • See if this helps: https://unix.stackexchange.com/questions/35973/udf-and-fstab-no-uuid?rq=1 – Emmanuel Rosa Sep 09 '18 at 06:35
  • Though the solution mentioned there is for entire hard disk, can I still `mkudffs --media-type=hd --vid=UDFStore /dev/sdb5`? Does it destroy data? – Necktwi Sep 09 '18 at 06:55
  • Yes, you can use a partition instead of a hard disk. And yes, formatting the partition again will destroy the data in it. – Emmanuel Rosa Sep 09 '18 at 08:00
  • Is there a way to set the VID without formatting? Just yesterday, I spent 12+ hrs backing up the data to the UDF partition. – Necktwi Sep 09 '18 at 12:05
  • Try using `udflabel`. Check the man page first, but the command should be something like `udflabel --vid=[yourlabelhere] /dev/[device here]` – Emmanuel Rosa Sep 09 '18 at 12:58
0

But blkid doesn't list /dev/sdb5.

That is probably because of blkid cache. Use -p to bypass cache and specify also block device. E.g.

$ blkid -p /dev/sdb5

It should print something like this:

VOLUME_ID="UDFStore" UUID="5c587177a6c9eba4" VOLUME_SET_ID="5c587177a6c9eba4LinuxUDF" LABEL="UDFStore" LOGICAL_VOLUME_ID="UDFStore" VERSION="2.01" TYPE="udf" USAGE="filesystem"

Then you can use printed UUID to specify your entry in /etc/fstab.

Pali
  • 131
  • 1
  • 3