Skip to content

Commit

Permalink
Fix detection of device type (partition/full disk) in move_disk.sh
Browse files Browse the repository at this point in the history
The version of stat available at that point does not support %Lr, so use instead its hexadecimal counterpar (%T)
  • Loading branch information
eduardosm committed Jan 12, 2024
1 parent 3f41cab commit 5243d3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion steps/jump/move_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 5243d3b

Please sign in to comment.