From f995a749de844964f83795e862e114876042686a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Thu, 28 Dec 2023 21:45:34 +0100 Subject: [PATCH] Fix detection of device type (partition/full disk) in move_disk.sh The version of stat available at that point does not support %Lr, so use instead its hexadecimal counterpar (%T) --- steps/jump/move_disk.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/steps/jump/move_disk.sh b/steps/jump/move_disk.sh index ec721f3..2f9cb0c 100755 --- a/steps/jump/move_disk.sh +++ b/steps/jump/move_disk.sh @@ -22,7 +22,9 @@ while ! dd if=/dev/${DISK} of=/dev/null bs=512 count=1; do done # Create partition if it doesn't exist -if [ $(($(stat -c "%Lr" "/dev/${DISK}") % 8)) -eq 0 ]; then +# 'stat -c "%T"' prints the minor device type in hexadecimal. +# The decimal version (with "%Lr") is not available in this version of stat. +if [ $((0x$(stat -c "%T" "/dev/${DISK}") % 8)) -eq 0 ]; then echo "Creating partition table..." # Start at 1GiB, use -S32 -H64 to align to MiB rather than cylinder boundary echo "2097152;" | sfdisk -uS -S32 -H64 --force "/dev/${DISK}"