Page 1 of 1

Automount Your External Device (USBKEYS, SSD, HDD) Everytime you Start MiSTer

Posted: Fri Feb 10, 2023 11:14 am
by TuffyDK

Hi

I prefer to have my games on USBKEYS - I have for now installed 2 USBKEYS on my Mister, and I know that sometimes those 2 USBkeys wont always be mounted as /media/usb0 and /media/usb1 (if you have 2 usbkeys)

Sometimes the do switch around, so to be sure always to "lock" em at the mountpoint you want, you can do this simple "trick".

  1. Power on Mister
  2. Connect Mister via SSH (like putty)
  3. Type the command: ls -lia /dev/disk/by-uuid/

This will show you what devices are attached your Mister: For my Mister output this:

169 lrwxrwxrwx 1 root root 15 Feb 10 11:55 0221-F4EA -> ../../mmcblk0p1
269 lrwxrwxrwx 1 root root 10 Feb 10 11:55 10B6-C207 -> ../../sda1
261 lrwxrwxrwx 1 root root 11 Feb 10 11:55 897d406f-b1e7-4fcf-8817-8d7ad204e477 -> ../../loop0
257 lrwxrwxrwx 1 root root 10 Feb 10 11:55 98E6-48E0 -> ../../sdb1
200 lrwxrwxrwx 1 root root 11 Feb 10 11:55 f6fc4f39-51d7-45ed-a4af-dc7ea13c3d6f -> ../../loop8

I can see there are 3 devices (actually 5 but just ignore the 2 loop) attached to the Mister: 1 SD card (mmcblk0p1) and 2 USBKEYS (sda1 & sdb1)
We are only interessted in sda1 and sdb1

If we take the first one (sda1): 10B6-C207 -> ../../sda1 - It shows a unique id which is: 10B6-C207
and for sdb1: 98E6-48E0

We need those 2 ids for our fstab (linux automount)

  1. Make a backup of the current fstab by write this: cp /etc/fstab /etc/fstab_backup_2023-02-10
    check to see if the file is there with this command: ls -lia /etc/fstab_backup_2023-02-10

  2. Edit the /etc/fstab file by type this: nano /etc/fstab

  3. Go down to the buttom of the file, and type this (Remember YOUR own Unique ID's and dont type in mine):

UUID=10B6-C207 /media/usb0 auto nosuid,nodev,nofail 0 0

UUID=98E6-48E0 /media/usb1 auto nosuid,nodev,nofail 0 0

  1. Save and Close Nano with Ctrl + x and press Y for Yes and press enter.

  2. Reboot your Mister and now you should have your USBKEYs (or even HDD) assigned at the correct mountpoints EVERY TIME you start Mister!! :-)

/TuffyDK


Re: Automount Your External Device (USBKEYS, SSD, HDD) Everytime you Start MiSTer

Posted: Sun Feb 12, 2023 3:40 pm
by Malor

FAT volumes have shorter UUIDs than ext4 ones, and you can find both kinds quickly and easily.

You can use 'lsblk' to list all your drives, like this:

Code: Select all

/root# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0         7:0    0     2M  0 loop /var/lib/bluetooth
loop8         7:128  0   375M  0 loop /
mmcblk0     179:0    0 238.3G  0 disk
├─mmcblk0p1 179:1    0 238.3G  0 part /media/fat
└─mmcblk0p2 179:2    0     3M  0 part

Then you can use 'blkid' to dump the UUID for any partition:

Code: Select all

blkid /dev/mmcblk0p1
/dev/mmcblk0p1: LABEL="MiSTer_Data" UUID="0217-D108" BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos" PARTUUID="8c357333-01"

blkid /dev/loop8
/dev/loop8: LABEL="rootfs" UUID="f6fc4f39-51d7-45ed-a4af-dc7ea13c3d6f" BLOCK_SIZE="4096" TYPE="ext4"

The first listing is my /media/fat partition, and shows only an 8-char UUID. The second listing is the loopback Linux filesystem, which shows a normal ext4 long UUID. You want to use those instead when they exist.

It's quite possible that everyone may have the exact same UUIDs on their base SD cards. I don't know if Mr. Fusion gives them new ones or not. External ext4s will probably all be unique.

Linux can get very confused if you have the same UUID present in more than one filesystem. I had real problems with this on the Raspberry Pi, where I was using their default image plus resizer. Plugging in a second card (for data transfer) that had been burned and then resized would result in the new drive not even showing up, because it had the same UUIDs as the existing one. I had to learn how to change a UUID, which I won't get into here. And note that if you change a UUID, you also have to change everything that points at that ID, which will usually be at least in the boot environment and in /etc/fstab.


Re: Automount Your External Device (USBKEYS, SSD, HDD) Everytime you Start MiSTer

Posted: Sun Feb 12, 2023 7:16 pm
by Bas

The serial number on FAT can be changed without any impact to the FS itself. It's a random-ish number anyway (a timestamp of when it was created). Not sure if mlabel is present on MiSTer but that could help you change it.