Skip to content

Commit

Permalink
Wait until device is exists for moving data (#680)
Browse files Browse the repository at this point in the history
* Wait until device is exists for moving data

* Update hassos-data

* Update hassos-data

* Update hassos-data
  • Loading branch information
pvizeli committed May 19, 2020
1 parent b410b70 commit 4eda8a1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions buildroot-external/rootfs-overlay/usr/libexec/hassos-data
Expand Up @@ -21,6 +21,18 @@ OLD_DEVICE_CHILD="$(findfs LABEL="hassos-data")"
OLD_DEVICE_ROOT="/dev/$(lsblk -no pkname "${OLD_DEVICE_CHILD}")"
OLD_PART_NUM="${OLD_DEVICE_CHILD: -1}"

# Wait for devices
timeout 90 \
ash -c \
"until [ -e \"${NEW_DEVICE_ROOT}\" ]; do sleep 5; done" \
> /dev/null 2>&1 || true;

# Check if block device is exists
if [ ! -b "${NEW_DEVICE_ROOT}" ]; then
echo "[ERROR] No block device ${NEW_DEVICE_ROOT}!"
exit 1
fi

# Create new partition
echo "[INFO] Create new hassos-data partition"
sgdisk -o "${NEW_DEVICE_ROOT}"
Expand Down

0 comments on commit 4eda8a1

Please sign in to comment.