1 platform_check_image
() {
2 [ "$#" -gt 1 ] && return 1
4 case "$(get_magic_word "$1")" in
7 echo "Invalid image type"
13 platform_copy_config
() {
16 if export_partdevice partdev
1; then
17 mount
-t ext4
-o rw
,noatime
"/dev/$partdev" /mnt
18 cp -af "$CONF_TAR" /mnt
/
23 platform_do_upgrade
() {
24 local diskdev partdev
diff
26 if export_bootdevice
&& export_partdevice diskdev
0; then
28 if [ "$SAVE_PARTITIONS" = "1" ]; then
29 get_partitions
"/dev/$diskdev" bootdisk
31 #extract the boot sector from the image
32 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
34 get_partitions
/tmp
/image.bs image
37 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
38 if [ -n "$diff" ]; then
39 echo "Partition layout is changed. Full image will be written."
40 ask_bool
0 "Abort" && exit
42 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=4096 conv
=fsync
46 #iterate over each partition from the image and write it to the boot disk
47 while read part start size
; do
48 if export_partdevice partdev
$part; then
49 echo "Writing image to /dev/$partdev..."
50 get_image
"$@" |
dd of
="/dev/$partdev" ibs
="512" obs
=1M skip
="$start" count
="$size" conv
=fsync
52 echo "Unable to find partition $part device, skipped."
54 done < /tmp
/partmap.image
57 echo "Writing new UUID to /dev/$diskdev..."
58 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=1 skip
=440 count
=4 seek
=440 conv
=fsync
60 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=4096 conv
=fsync