@@ -640,22 +640,24 @@ get_src_disk()
640
640
# Fix PARTUUID/UUID or device name references in cmdline.txt
641
641
fixup_boot_partition ()
642
642
{
643
- src_mount=$1
644
- dst_mount=$2
643
+ partition=$1
644
+ src_mount=$2
645
+ dst_mount=$3
645
646
646
647
# Just try all flavors
647
648
# Paths are below the /boot directory/mountpoint
648
- fixup_cmdline_txt " ${src_mount} " " ${dst_mount} " /cmdline.txt /cmdline.boot
649
- fixup_cmdline_txt " ${src_mount} " " ${dst_mount} " /armbianEnv.txt /armbianEnv.boot
650
- fixup_cmdline_txt " ${src_mount} " " ${dst_mount} " /firmware/cmdline.txt /firmware/cmdline.boot # Ubuntu
649
+ fixup_cmdline_txt " ${partition} " " ${ src_mount}" " ${dst_mount} " /cmdline.txt /cmdline.boot
650
+ fixup_cmdline_txt " ${partition} " " ${ src_mount}" " ${dst_mount} " /armbianEnv.txt /armbianEnv.boot
651
+ fixup_cmdline_txt " ${partition} " " ${ src_mount}" " ${dst_mount} " /firmware/cmdline.txt /firmware/cmdline.boot # Ubuntu
651
652
}
652
653
653
654
fixup_cmdline_txt ()
654
655
{
655
- src_mount=$1
656
- dst_mount=$2
657
- cmdline_txt=$3
658
- cmdline_boot=$4
656
+ partition=$1
657
+ src_mount=$2
658
+ dst_mount=$3
659
+ cmdline_txt=$4
660
+ cmdline_boot=$5
659
661
660
662
if [ -f " ${dst_mount}${cmdline_txt} " ]
661
663
then
@@ -666,7 +668,7 @@ fixup_cmdline_txt()
666
668
cmdline_txt=${cmdline_boot}
667
669
fi
668
670
669
- fixup_device_references_in_file " ${dst_mount}${cmdline_txt} "
671
+ fixup_device_references_in_file " ${partition} " " ${ dst_mount}" " ${cmdline_txt} "
670
672
671
673
if (( leave_sd_usb_boot && SD_slot_boot))
672
674
then
@@ -680,29 +682,31 @@ fixup_cmdline_txt()
680
682
}
681
683
682
684
fixup_device_references_in_file () {
683
- file=$1
684
- if grep -q $src_disk_ID $file
685
+ partition=$1
686
+ dst_mount=$2
687
+ file=$3
688
+ if grep -q " ${src_disk_ID} " " ${dst_mount}${file} "
685
689
then
686
- qecho " Editing $file PARTUUID to use $dst_disk_ID "
687
- sed -i " s/${src_disk_ID} /${dst_disk_ID} /g" " $file "
688
- elif grep -q UUID= $ file
690
+ qecho " Editing $partition $file PARTUUID to use $dst_disk_ID "
691
+ sed -i " s/${src_disk_ID} /${dst_disk_ID} /g" " ${dst_mount}${ file} "
692
+ elif grep -q UUID= " ${dst_mount}${ file} "
689
693
then
690
694
for (( p = 1 ; p <= n_src_parts; p++ ))
691
695
do
692
696
old_fsuuid=${src_fsuuid[p]}
693
697
new_fsuuid=${dst_fsuuid[p]}
694
- if [ " $old_fsuuid " == " " -o " $new_fsuuid " == " " ] || ! grep -q " $old_fsuuid " " $file " ;
698
+ if [ " $old_fsuuid " == " " -o " $new_fsuuid " == " " ] || ! grep -q " $old_fsuuid " " ${dst_mount}${ file} " ;
695
699
then
696
700
continue
697
701
fi
698
702
699
- qecho " Editing $file partition $p UUID to use $new_fsuuid "
700
- sed -i " s/$old_fsuuid /${new_fsuuid} /" " $file "
703
+ qecho " Editing $partition$file UUID to use $new_fsuuid for partition $p "
704
+ sed -i " s/$old_fsuuid /${new_fsuuid} /" " ${dst_mount}${ file} "
701
705
done
702
- elif [ " $edit_fstab_name " != " " ] && grep -q ${src_part_base} $ file
706
+ elif [ " $edit_fstab_name " != " " ] && grep -q ${src_part_base} " ${dst_mount}${ file} "
703
707
then
704
- qecho " Editing $file references from $src_part_base to $edit_fstab_name "
705
- sed -i " s/${src_part_base} /${edit_fstab_name} /" " $file "
708
+ qecho " Editing $partition $file references from $src_part_base to $edit_fstab_name "
709
+ sed -i " s/${src_part_base} /${edit_fstab_name} /" " ${dst_mount}${ file} "
706
710
fi
707
711
}
708
712
1856
1860
done
1857
1861
qecho " "
1858
1862
1859
- fixup_boot_partition /boot " ${clone} /boot"
1860
- fixup_device_references_in_file " ${clone} /etc/fstab"
1863
+ fixup_boot_partition /boot /boot " ${clone} /boot"
1864
+ fixup_device_references_in_file " " " ${clone} " /etc/fstab
1861
1865
1862
1866
rm -f $clone /etc/udev/rules.d/70-persistent-net.rules
1863
1867
0 commit comments