1 platform_check_image() {
5 platform_copy_config() {
8 if export_partdevice partdev -1; then
9 mount -t vfat -o rw,noatime "/dev/$partdev" /mnt
10 cp -af "$CONF_TAR" /mnt/
15 platform_do_upgrade() {
16 local diskdev partdev ibs diff
18 if export_bootdevice && export_partdevice diskdev -2; then
20 if [ "$SAVE_PARTITIONS" = "1" ]; then
21 get_partitions "/dev/$diskdev" bootdisk
24 if [ -f "/sys/block/$diskdev/queue/physical_block_size" ]; then
25 ibs="$(cat "/sys/block/$diskdev/queue/physical_block_size")"
30 #extract the boot sector from the image
31 get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
33 get_partitions /tmp/image.bs image
36 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
37 if [ -n "$diff" ]; then
38 echo "Partition layout is changed. Full image will be written."
39 ask_bool 0 "Abort" && exit
41 get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
46 get_image "$@" | dd of="$diskdev" bs=1024 skip=8 seek=8 count=1016 conv=fsync
47 #iterate over each partition from the image and write it to the boot disk
48 while read part start size; do
50 if export_partdevice partdev $part; then
51 echo "Writing image to /dev/$partdev..."
52 get_image "$@" | dd of="/dev/$partdev" ibs="$ibs" obs=1M skip="$start" count="$size" conv=fsync
54 echo "Unable to find partition $part device, skipped."
56 done < /tmp/partmap.image
59 echo "Writing new UUID to /dev/$diskdev..."
60 get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
62 get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync