Adding USB thumb drive to PiAware 3.5?

It seems not to be possible to add a USB thumbdrive to PiAware.

I have a Kingston 16Gb data traveler 2.0 and no matter what I try it is always mounted immediately, owned by root, and in root group. It is made read only. Obviously this means I can not back things up to the thumb drive, or have a database residing on it being updated.

If one writes often to an SD card then it will be destroyed by this process sooner or later. If the writes can be redirected to a USB stick then it’s an improvement since in the event of a problem the USB stick does not contain the OS and the whole unit is not rendered useless. As long as one backs up any valued data from the thumb drive fairly often then any destruction is going to be usefully limited.

A mate and I spent 4.5 hours one evening trying to persuade a PiAware install to cooperate, but we failed. We noted some command line commands that might have helped were missing, but of course they are missing, so we can’t be sure if they might have been able to help enough.

Making a thumbdrive read only by default rather defeats the point I would have thought. Making it available to the user to back things up seems more sensible. But what would I know? :wink:

Anyone happen know if there is a magic bullet for this problem? My friend’s reaction was to tell me not to be so silly, and of course now he knows how bad this problem really is too! :rofl:

Cheers,
Ian

This is to support loading config from a USB drive (mostly used on FlightFeeders). It’s only present on the piaware sdcard image.

See /lib/udev/rules.d/60-piaware-support.rules and /lib/udev/generate-usb-mount if you want to make it do something different.

(Or if you want a general-purpose system, you might want to start from a vanilla Raspbian image - the PiAware image is very specifically tailored to running piaware)

1 Like

Thanks very much indeed, it looks rather promising for all I know just yet.

I’m after putting a basestation.sqb (can’t recall the exact name for this precise moment) on the USB drive, then having VRS update it as and when it needs. ie it will need to write to that file.

Does this sound like the sort of thing I could then do with that which is already there?

I am working from PiAware 3.5 image and I have not molested it very much at all. Added VRS, wrote a small script, got it to wait 20 seconds then run at reboots from the cron, nothing too heavy.

I’d have preferred to do it daemon style (so it run s like a service and can be started and stopped, no doubt much more tidy), but it’s way beyond my knowledge.

Any hints or help welcome of course! :wink:

If you expect a particular USB drive to always be present then probably the simplest thing to do is to disable the udev rule entirely and just specify your drive in /etc/fstab

1 Like

I had a similar issue with auto-mounted USB drives with the piaware image. If you put a link to dev/null in /etc for this rule it will override the ones in /lib and stop the USB drive from automatically being mounted. You then have to mount it yourself of course.

Sudo ln -s /dev/null /etc/undev/rules.d/60-piaware-support.rules

1 Like

Hi all. I came across this topic while troubleshooting a recent install of the piaware-sd-card-3.7.1.img onto a USB-SSD controller so that I can use an SSD to boot the RPi instead of an SD-CARD.

The problem I found was that the 60-piaware-support.rules script was causing the boot to fail because it was trying to mount the USB device that contains the root file system.

I worked around this temporarily by removing this script from the udev rules.d location, but then found I lost the ability to automount non-bootable USB MSDs.

In order to regain that capability, I modified the script by adding a single line to test for the bootable MSD’s PARTUUID. Not sure if this is the most robust method, but wanted to post it here to see if anyone has a better suggestion.

-----Modified Script Begin-------
pi@piaware:~ $ sudo more /lib/udev/rules.d/60-piaware-support.rules

These rules call generate-usb-mount to automatically generate

systemd mount units for USB removable storage devices when

they are plugged in. systemd then handles mounting the filesystem

asynchronously (so udev is not blocked)

removable USB partitions only

ACTION==“remove”, GOTO=“usb_mount_end”
SUBSYSTEM!=“block”, GOTO=“usb_mount_end”
ENV{DEVTYPE}!=“partition”, GOTO=“usb_mount_end”
ATTR{removable}==“0”, GOTO=“usb_mount_end”

Do not try to mount the bootable drive

ENV{ID_PART_TABLE_UUID}==“6123ecd4”, GOTO=“usb_mount_end”

IMPORT{parent}=“ID_*”
ENV{ID_BUS}!=“usb”, GOTO=“usb_mount_end”

ok, looks like something we want to try to mount

ACTION==“add”,RUN{program}=“generate-usb-mount add %N”
ACTION==“change”,RUN{program}=“generate-usb-mount change %N”

LABEL=“usb_mount_end”
-----Modified Script End-------

-----After reboot from SSD, the USB thumbdrive is mounted automatically----
pi@piaware:~ $ sudo df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 230620884 1211048 220003088 1% /
devtmpfs 470116 0 470116 0% /dev
tmpfs 474724 0 474724 0% /dev/shm
tmpfs 474724 13980 460744 3% /run
tmpfs 5120 4 5116 1% /run/lock
tmpfs 474724 0 474724 0% /sys/fs/cgroup
/dev/sdb1 107768 22040 85728 21% /boot
/dev/sda1 7798784 16 7798768 1% /media/usb/sda1
tmpfs 94944 0 94944 0% /run/user/1000

---- Use udevadm to determine the SSD’s PARTUUID for test in script above—
pi@piaware:~ $ sudo udevadm info -a -q all /dev/sdb
P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.0/host1/target1:0:0/1:0:0:0/block/sdb
N: sdb
S: disk/by-id/usb-KINGSTON_SA400M8240G_3530303236423736383244423034413920202020-0:0
S: disk/by-path/platform-3f980000.usb-usb-0:1.5.1:1.0-scsi-0:0:0:0
E: DEVLINKS=/dev/disk/by-path/platform-3f980000.usb-usb-0:1.5.1:1.0-scsi-0:0:0:0 /dev/disk/by-id/usb-KINGSTON_SA400M8240G_3530303236423736383244423034413920202020-0:0
E: DEVNAME=/dev/sdb
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.0/host1/target1:0:0/1:0:0:0/block/sdb
E: DEVTYPE=disk
E: ID_BUS=usb
E: ID_INSTANCE=0:0
E: ID_MODEL=SA400M8240G
E: ID_MODEL_ENC=\x20SA400M8240G\x20\x20\x20\x20
E: ID_MODEL_ID=0229
E: ID_PART_TABLE_TYPE=dos
E: ID_PART_TABLE_UUID=6123ecd4
E: ID_PATH=platform-3f980000.usb-usb-0:1.5.1:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_5_1_1_0-scsi-0_0_0_0
E: ID_REVISION=SBFK
E: ID_SERIAL=KINGSTON_SA400M8240G_3530303236423736383244423034413920202020-0:0
E: ID_SERIAL_SHORT=3530303236423736383244423034413920202020
E: ID_TYPE=disk
E: ID_USB_DRIVER=usb-storage
E: ID_USB_INTERFACES=:080650:080662:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=KINGSTON
E: ID_VENDOR_ENC=KINGSTON
E: ID_VENDOR_ID=045b
E: MAJOR=8
E: MINOR=16
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=7478930
E: net.ifnames=0