summaryrefslogtreecommitdiffstats
path: root/core/rootfs
diff options
context:
space:
mode:
authorSimon Rettberg2019-02-19 15:54:36 +0100
committerSimon Rettberg2019-02-19 15:54:36 +0100
commit093f1fde8bc98428898268a10a39cfe2a8f0b28e (patch)
tree3308bd85dd4471fe154ef3c8b40d860c400636cb /core/rootfs
parent[dbus/udisks] Ubuntu 18 config (diff)
downloadmltk-093f1fde8bc98428898268a10a39cfe2a8f0b28e.tar.gz
mltk-093f1fde8bc98428898268a10a39cfe2a8f0b28e.tar.xz
mltk-093f1fde8bc98428898268a10a39cfe2a8f0b28e.zip
[hardware-stats/rootfs-stage32] Improve HDD detection
Diffstat (limited to 'core/rootfs')
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions27
1 files changed, 19 insertions, 8 deletions
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
index 76afadf0..b767f677 100755
--- a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
@@ -126,34 +126,45 @@ mount_temp_fallback () {
}
wait_for_udev () {
- local upid ctr
+ local upid ctr hdd
+ hdd=
+ [ "x$1" = "x--hdd" ] && hdd=true
ctr=$(( "$1" * 10 ))
if ! [ "$ctr" -gt 0 ]; then # Negation to catch NaN
ctr=1
fi
udevadm trigger &
usleep 20000 # 20ms
- udevadm settle & # --timeout doesn't work reliably, sometimes the process just hangs
+ udevadm settle &> /dev/null & # --timeout doesn't work reliably, sometimes the process just hangs
upid=$!
while [ "$ctr" -gt 0 ] && [ -d "/proc/$upid" ]; do
+ [ -n "$hdd" ] && has_hdd && break
usleep 100000 # 100ms
ctr=$(( ctr - 1 ))
done
if [ -d "/proc/$upid" ]; then
- kill -9 "$upid" &
+ kill -9 "$upid" &> /dev/null &
fi
}
+has_hdd () {
+ [ -n "$( ls -U -1 /dev/disk/by-path/ )" ]
+}
+
wait_for_udev 2
-/opt/openslx/sbin/fdisk -l | grep '^/dev/' > "$PARTITION_FILE"
-if [ ! -s "$PARTITION_FILE" ]; then
- udevadm trigger &
+if ! has_hdd; then
sleep 1
- wait_for_udev 3
- /opt/openslx/sbin/fdisk -l | grep '^/dev/' > "$PARTITION_FILE"
+ wait_for_udev --hdd 4
fi
+for disk in /dev/disk/by-path/!(*-part*); do
+ [ -L "$disk" ] || continue
+ fdisk -l "$( readlink -f "$disk" )"
+done > "$PARTITION_FILE"
+if ! [ -s "$PARTITION_FILE" ]; then
+ echo "none" > "$PARTITION_FILE"
+fi
echo "Partitions:"
cat "$PARTITION_FILE"