If the newimg partition is not found just log a message and carry on.

This commit is contained in:
jumperfly 2016-11-16 19:54:24 +00:00 committed by Sam Liddell
parent 4c7d6fcfa8
commit 4017e4178b
2 changed files with 20 additions and 10 deletions

View file

@ -18,11 +18,15 @@ This is used as the writeable area of the overlay and consists of three director
* /persistent: Used as an additional 'lowerdir' of the overlayfs. As the 'upperdir' is cleared, this read-only lower dir allows customisations to be made compared to the read-only OS image. eg. SSH keys. * /persistent: Used as an additional 'lowerdir' of the overlayfs. As the 'upperdir' is cleared, this read-only lower dir allows customisations to be made compared to the read-only OS image. eg. SSH keys.
### The image partition ### The image partition
This must contain a single file, root-squashfs.img which contains the full operating system. This must contain a single file, root-squashfs.img which contains the full operating system. This is mounted read-only.
If the overlayfs module is found within the image under /lib/modules/<kernel-version> it is loaded, otherwise it is assumed overlayfs support is build into the kernel.
### The new image partition. ### The new image partition.
If the partition is detected and contains an image file with the same name as the one that will be mounted from the image partition it will be moved into the image partition. The previous image will be renamed <name>-old.img If the partition is detected and contains an image file with the same name as the one that will be mounted from the image partition it will be moved into the image partition. The previous image will be renamed <name>-old.img
If this partition is used, then the 'image' partition should be at least double the size in order to hold old and new images.
## Project structure ## Project structure
The build.sh script will generate two initramfs files per architecture into a 'target' directory. The build.sh script will generate two initramfs files per architecture into a 'target' directory.
* init-<version>-<arch>.gz - The 'standard' initramfs. This should be used in most cases. * init-<version>-<arch>.gz - The 'standard' initramfs. This should be used in most cases.

View file

@ -35,16 +35,22 @@ if [[ $ATTEMPTS -eq $MAX_WAIT ]]; then
fi fi
# Mount device containing updated image (if any) # Mount device containing updated image (if any)
if findfs $NEWIMG_DEVICE &> /dev/null; then
mount -t ext4 $NEWIMG_DEVICE /mnt/newimg mount -t ext4 $NEWIMG_DEVICE /mnt/newimg
if [[ -e /mnt/newimg/$OS_IMAGE ]]; then if [[ -e /mnt/newimg/$OS_IMAGE ]]; then
# Mount device containing current image RW and replace with updated image # Mount device containing current image RW and replace with updated image
echo "Detected a new OS image, copying to image partition..."
mount -t ext4 $IMG_DEVICE /mnt/img mount -t ext4 $IMG_DEVICE /mnt/img
mv -f /mnt/newimg/$OS_IMAGE /mnt/img/$OS_IMAGE-new mv -f /mnt/newimg/$OS_IMAGE /mnt/img/$OS_IMAGE-new
mv -f /mnt/img/$OS_IMAGE /mnt/img/$OS_IMAGE-old mv -f /mnt/img/$OS_IMAGE /mnt/img/$OS_IMAGE-old
mv /mnt/img/$OS_IMAGE-new /mnt/img/$OS_IMAGE mv /mnt/img/$OS_IMAGE-new /mnt/img/$OS_IMAGE
umount /mnt/img umount /mnt/img
echo "New image copied."
fi fi
umount /mnt/newimg umount /mnt/newimg
else
echo "The 'newimg' partition was not detected, not checking for updated images."
fi
# Mount device containing current image RO # Mount device containing current image RO
mount -t ext4 -o ro $IMG_DEVICE /mnt/img mount -t ext4 -o ro $IMG_DEVICE /mnt/img