3 # copied from x86's platform.sh
5 mbl_do_platform_check
() {
6 local diskdev partdev
diff
8 [ "$#" -gt 1 ] && return 1
10 export_bootdevice
&& export_partdevice diskdev
0 ||
{
11 echo "Unable to determine upgrade device"
15 get_partitions
"/dev/$diskdev" bootdisk
17 #extract the boot sector from the image
18 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
2>/dev
/null
20 get_partitions
/tmp
/image.bs image
23 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
25 rm -f /tmp
/image.bs
/tmp
/partmap.bootdisk
/tmp
/partmap.image
27 if [ -n "$diff" ]; then
28 echo "Partition layout has changed. Full image will be written."
29 ask_bool
0 "Abort" && exit 1
37 local diskdev partdev
diff
39 export_bootdevice
&& export_partdevice diskdev
0 ||
{
40 echo "Unable to determine upgrade device"
46 if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
47 get_partitions
"/dev/$diskdev" bootdisk
49 #extract the boot sector from the image
50 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
52 get_partitions
/tmp
/image.bs image
55 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
60 if [ -n "$diff" ]; then
61 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=4096 conv
=fsync
63 # Separate removal and addtion is necessary; otherwise, partition 1
64 # will be missing if it overlaps with the old partition 2
65 partx
-d - "/dev/$diskdev"
66 partx
-a - "/dev/$diskdev"
71 #iterate over each partition from the image and write it to the boot disk
72 while read part start size
; do
73 if export_partdevice partdev
$part; then
74 echo "Writing image to /dev/$partdev..."
75 get_image
"$@" |
dd of
="/dev/$partdev" ibs
="512" obs
=1M skip
="$start" count
="$size" conv
=fsync
77 echo "Unable to find partition $part device, skipped."
79 done < /tmp
/partmap.image
82 echo "Writing new UUID to /dev/$diskdev..."
83 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=1 skip
=440 count
=4 seek
=440 conv
=fsync
89 if export_partdevice partdev
1; then
90 mount
-t ext4
-o rw
,noatime
"/dev/$partdev" /mnt
91 cp -af "$CONF_TAR" "/mnt/$BACKUP_FILE"