I need some help...

I have a raspberry pi 4b with a SATA hat and four 1GB HDD's attached to the SATA Hat. I have them mounted as sda1 through to sdd1 and the correct entries in my /etc/fstab file. They all mount at boot  and I can find them in their respective mount points /mnt/disk1 through 4.

The problem I have is and I'll try to explain here. I have three printers connected to a USB hub and that hub in turn is connected to the Raspberry Pi's USB port. Two of the 3D Printers have SKR 1.4 Turbo boards and those boards have a SD Card slot. If I have the printers powered on when I start my Raspberry Pi it mounts those two SD cards as sda1 & sdb1. This then kicks out my HDD's sda1 and sdb1 and moves al my drive up by one letter, so sda1 moves to sdc1, sdb1 moves to sdd1 etc. As I have the RepeaterServer folder linked to sda1 (more space than the pi's sd card) my whole server crashes.

I have found that /etc/udev/rules.d/10-flash.rules has three rules for mounting USB devices as sda1 etc. Is there any way I can either move my HDD's sda1..4 to another device or do the same with the USB devices tagged in the 10-flash.rules file?

Comments

  • Your problem is that device numbering /dev/sdX is dependent on order of detection. Means if printer is connected or not can already change your order.
    The flash rules like
    KERNEL=="sda1", SUBSYSTEMS=="usb", TAG+="systemd", ENV{SYSTEMD_WANTS}+="usb-mount.service"
    are quite simple as we do not know the device exactly. What you need is mount your drive by UUID so it is always mounting exactly your drive regardless of sdX name, like described e.g. here:
    https://www.simplified.guide/linux/disk-mount-uuid

  • The drives are mounted using UUID and sda1 is where I have my symlinked Repeater-Server folder. If I list all devices ls -l /dev/disk/by-id I can see that my two SKR boards are sda and sdb. 
  • Just to add a little more to this...

    When I mount my HDD sda1 to /mnt/disk1 the usb-mount.service scripts also then mount the same hdd to /media/flash, the same applies to sdb1 > /media/flash2 and sdc1 > /media/flash3. This as I understand is because of a service located at /usr/local/Repetier-Server/scripts/usb-mount.service (I'm not 100% sure it is located in that dir, I'm not infant of the machine right now). 

    Is there anyway to either edit the /usr/local/Repetier-Server/scripts/usb-mount.service to prevent this or even remove the service all-together?
  • You can remove /dev/udev/10-flash.rules I think it is named. That is the rule that triggers the server aoutomount of sda1 - sdc. Then it does not matter that the scripts it self exist as they never get called. If you need them for usb upload you mought then add the rules with detection by usb stick id or for later drive numbers.
  • edited April 19
    Thanks for that information. I traced my problem back to this /usr/local/Repetier-Setup/templates/usb-mount.service. What was happening and I'll try to explain...

    I have my HDD's as sda sdb sdc sdd and each has a partition which I have been mounting sda1..2..3..4 > /mnt/disk1..2..3...4 etc. as soon as I had mounted sda1 for example the usb-mount.service calls /usr/local/Repetier-Setup/bin/usb-mount which then mounts it /media/flash. So running lsblk -f I could see that sda1 had been mounted to media/flash and it is also mounted to /mnt/disk1.  

    Looking at that usb-mount script it is looking for sda1..2..3 which it then mounts to /media/flash..2..3. When I then connected my printers USB hub to the PI's USB port my HDD's would all move from sda1 to sdc1 etc. and the SKR boards would take sda1 & sdb1 but my HDD's would stay as sda..b..c..d and still be mounted to /media/flash etc.. Shouldn't matter if I use UUID in fstab? I have mounted the HDD's using their UUID's in fstab but for some reason that didn't seem to work and the server would crash after a short while. Perhaps you could add to that /usr/local/Repetier-Setup/bin/usb-mount script the SUBSYSTEMS to TAG option and have it only mount devices tagged as USB?
  • > Perhaps you could add to that /usr/local/Repetier-Setup/bin/usb-mount script the SUBSYSTEMS to TAG option and have it only mount devices tagged as USB?
    Since the pi has no HDD ports natively, what system does your hard disk use? Isn't that USB as well? I think if so it should just be added in udev rules to only match the subsystem, but I already said removing the file should help already. Makes not much sense anyway with 7 HDD devices at start up and none is a usb stick.

    Also our scripts mount flash folders, I think it is possible to mount same device multiple times, so should not affect you mounting it on your preferred place.

    But how do you tell serve to use hdd instead? One important thing is that the folder/mount must exist before server starts or it will fail.

    Name shift with SKR present can happen - as I said order of detection by linux gives naming here.
  • Let apologise if I'm coming across as argumentative, not my intention at all. I just have experienced an issue and I'm only trying to find out why and what could be done to resolve it. I'm most definitely not trying to pick fault at your software, which is excellent.

    I have reinstalled the raspberry pi image but this time I have written it to a USB thumb drive which is now the boot device. The SD Card is no longer needed. 

    ls -l /dev/disk/by-id
    usb-APPLE_HD_D_HTS541010A9E66_1234567890123-0:1 -> ../../sde
    usb-APPLE_HD_D_HTS541010A9E66_1234567890123-0:1-part1 -> ../../sde1
    usb-HGST_HTS_541010A9E680_1234567890123-0:0 -> ../../sdf
    usb-HGST_HTS_541010A9E680_1234567890123-0:0-part1 -> ../../sdf1
    usb-HGST_HTS_541010A9E680_1234567890123-0:1 -> ../../sdg
    usb-HGST_HTS_541010A9E680_1234567890123-0:1-part1 -> ../../sdg1
    usb-Marlin_SDCard_01_0EFF4010AF6998A65E4146DEF50020C0-0:0 -> ../../sdc
    usb-Marlin_SDCard_01_0F00A019AF6998A65E4148B6F50020C6-0:0 -> ../../sdb
    usb-SanDisk_Ultra_Fit_0101fd8dda4736fb8ac02fee53b0d62e4cf879e30faa296d3aea83d085513bf610c900000000000000000000dd8bdc73008a270083558107372901c6-0:0 -> ../../sda
    usb-SanDisk_Ultra_Fit_0101fd8dda4736fb8ac02fee53b0d62e4cf879e30faa296d3aea83d085513bf610c900000000000000000000dd8bdc73008a270083558107372901c6-0:0-part1 -> ../../sda1
    usb-SanDisk_Ultra_Fit_0101fd8dda4736fb8ac02fee53b0d62e4cf879e30faa296d3aea83d085513bf610c900000000000000000000dd8bdc73008a270083558107372901c6-0:0-part2 -> ../../sda2

    The above output is missing one HDD as per...
    df -h
    /dev/sda1       253M   71M  182M  29% /boot
    /dev/sde1       916G   77M  916G   1% /mnt/disk2
    /dev/sdd1       916G  762M  916G   1% /mnt/disk1
    /dev/sdf1       916G   88M  916G   1% /mnt/disk3
    /dev/sdg1       916G  1.7G  915G   1% /mnt/disk4

    So, having re-installed and by using a usb device to boot from everything so far has been very stable. 

    Again apologies if I have come across wrong.

  • My problem currently is that I do not understand what your problem is that you want to describe. You already know the id trick and all disks are there. What do you want to achieve?

    df only shows mounted devices - /dev/disk/by-id shows connected disks. Not necessary the same since there is no automounter active except the 10-flash.rules solution maybe, but not sure you have them on or off. See no mount to the normal mount point so assume off.

    You need to add all mounts by id to /etc/fstab so they get mounted on startup by linux do designed folder.

    What I also miss is / folder in df output. /dev/sda2 I guess it would be.
Sign In or Register to comment.