alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.55k stars 220 forks source link

🐛 Template Customization - local disk unable to load label that contains space #1499

Closed josiah-eichelman closed 3 months ago

josiah-eichelman commented 3 months ago

Description

When attempting to load a local disk by 'Label' ex, 'TOSHIBA EXT', the 'EXT" is cutoff (I believe due to the parsing in the script, see SS below) making it unable to be found/mounted.

There might be something else going on, but from the logs this seems to be the issue.

image

Reproduction steps

1. Go to 'any add on config'
2. Load a local disk with a label that contains a space
3. View logs - notice how its unable to mount

Addon Logs

/etc/cont-init.d/00-local_mounts.sh: executing
---------------------------------------------------
[06:17:09] INFO: Available Disks for mounting :
NAME   LABEL            SIZE FSTYPE   RO
├─sda2                   24M squashfs  0
├─sda3                  256M squashfs  0
├─sda4                   24M squashfs  0
├─sda5                  256M squashfs  0
└─sdb1 TOSHIBA EXT      1.8T ext4      0
---------------------------------------------------
Supported fs :  ext3 ext2 ext4 squashfs vfat msdos iso9660 btrfs
Inspired from : github.com/dianlight
---------------------------------------------------
Local Disks mounting...
... TOSHIBA is a device by label
lsblk: /dev/disk/by-label/TOSHIBA: not a block device
Error : /etc/cont-init.d/00-local_mounts.sh exiting 32

Architecture

amd64

OS

HAos

alexbelgium commented 3 months ago

Hi, indeed this can't work with spaces in the name as "space" is used as separator between fields. I do see how this is inconvenient but given for how long this has been like that there is a very high risk of breaking other users' installations if I change this behavior...

Would changing the label name be an option? Or add a "_" instead of the blank ?

josiah-eichelman commented 3 months ago

I'll try that - in my case its a bit inconvenient because other applications are currently referencing the label with a space, so there is a chance I may break those other applications. But I'll go through them to try an catch it.

alexbelgium commented 3 months ago

Wait I'll post another solution later

alexbelgium commented 3 months ago

So, you can mount the drive by removing the value from the add-on options and mounting it manually.

For that, using the Filebrowser addon, you go in /homeassistant/addons_autoscripts/transmission- ls.sh

Inside, just add this code then reboot

#!/bin/bash
type="auto"
disk="TOSHIBA EXT"
devpath="/dev/disk/by-label"
dirpath="/mnt"
options="nosuid,relatime,noexec"
mount -t $type "$devpath"/"$disk" "$dirpath"/"$disk" -o $options
echo "Disk mounted"
josiah-eichelman commented 3 months ago

Sorry missed this, appreciate you putting this together. Will try it tonight!

josiah-eichelman commented 3 months ago

Getting closer, getting another error but it may be unrelated, not sure.

Originally I was getting "mount point does not exist". I added mkdir to your script above before the mount, seemed to fix. mkdir -p /mnt/"$disk"`

But after that I'm getting this error, ... script found, executing mount: /mnt/TOSHIBA EXT: special device /dev/disk/by-label/TOSHIBA EXT does not exist. dmesg(1) may have more information after failed mount system call. Disk mounted

I'm trying out some other mount options - will come back later with an update. I think I can figure this out

alexbelgium commented 3 months ago

Hi, according to this https://superuser.com/questions/527495/how-to-mount-partition-with-spaces-in-path you could try using \040 instead of a space in the name

josiah-eichelman commented 3 months ago

Got it to work! Thanks for your help