Skip to content

Fix detection of BootDrive in my Docker container #24

Description

@mhaas

Hi,

I am now running Storage.sh inside a Ubuntu Docker container on Home Assistant Operating System. It seems that Docker is introducing some extra output in the findmnt command used to detect the device:

root@a1910f57cf49:/# findmnt -n -o SOURCE --target /mnt/
/dev/sda8[/benchmark]

The following patch makes this work for me:

root@a1910f57cf49:/# diff -u Storage.sh.1 Storage.sh --- Storage.sh.1	2022-08-14 05:49:27.207017311 +0000
+++ Storage.sh	2022-08-14 05:50:27.025675373 +0000
@@ -339,7 +339,7 @@
BootDrive=$(df -H | grep -m 1 boot | awk 'NR==1{ print $1 }' | sed 's/\[\/\@\]//g')
fi
else
- BootDrive=$(findmnt -n -o SOURCE --target "$ChosenPartition" | sed 's/\[\/\@\]//g')
+ BootDrive=$(findmnt -n -o SOURCE --target "$ChosenPartition" | sed -e 's/\[\/.*\]//g')
fi
# Detect BootDrive suffix

This patch might be required also for other instances of that sed call.

For reference, this is how I start the container:

docker run --privileged -ti -v /mnt/data/benchmark/:/mnt/ -v /dev/:/dev/ ubuntu:jammy

And this is how mount looks like inside the container:

/dev/sda8 on /etc/resolv.conf type ext4 (rw,relatime)
/dev/sda8 on /etc/hostname type ext4 (rw,relatime)
/dev/sda8 on /etc/hosts type ext4 (rw,relatime)
root@a1910f57cf49:/# findmnt --version
findmnt from util-linux 2.37.2
root@a1910f57cf49:/# uname -a
Linux a1910f57cf49 5.15.32-v8 #1 SMP PREEMPT Sat Jul 23 18:06:19 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions