Comment 94 for bug 1922342

Revision history for this message
sudodus (nio-wiklund) wrote (last edit ):

Hi Thomas Schmitt,

> I wonder what is meant by "add some tweaks".

1. Made grub use UUID instead of device name to identify partition where to find the grub files

---
# create grub.cfg to match iso file's name

echo -e "$inversvid tweak grub ...$resetvid"

# tweak 3: search by UUID

sleep 2
partprobe
sleep 2
targ1=$(mktemp -d --tmpdir dus.XXXXXXXXXX)
uid2=$(lsblk -o uuid,label "$target" |grep -i 'usbboot'|sed "s% *usbboot%%")
uid3=$(lsblk -o uuid,label "$target" |grep 'isodevice'|sed "s% *isodevice%%")
echo "uid2=$uid2"
echo "uid3=$uid3"
mount -U "$uid2" "$targ1"
sleep 2
if [ "$uid3" != "" ]
then
 sed -i '/set isofile/'a" search --set=root --fs-uuid $uid3" "$targ1"/boot/grub/grub.cfg
 sed -i 's/(hd0,3)/($root)/' "$targ1"/boot/grub/grub.cfg
 if [ $? -ne 0 ]
 then
  error="$error - sed: tweak 3 grub.cfg"
  result="target drive might work, but setting 'search by UUID' failed :-("
  echo "$result"
 fi
fi
umount "$targ1"
rmdir "$targ1"
sleep 2
partprobe
sleep 1
}
---
# tweak 1: maybe modify label of partition for persistence

mntpt=$(mktemp -d --tmpdir dus.XXXXXXXXXX)
mount -o loop "$source" "$mntpt"
syslbl=$(lsblk -o label,mountpoint | grep "$mntpt"|sed "s% *$mntpt%%")
umount "$mntpt"
sleep 2
isover=$(<<< "$syslbl" grep -o ' [0-9]*\.'|grep -o '[0-9]*')
pptarg=$(lsblk -lo name,label "$target" |grep writable|sed -e 's/ .*//' -e 's#^#/dev/#')

if [ $isover -lt 20 ]
then
 tune2fs -L casper-rw "$pptarg"
 sleep 1
fi

# tweak 2:
# To make Firefox work in Jammy & newer:
# apparmor.service.d/30_live_mode.conf: ConditionPathExists=

if [ $isover -ge 22 ]
then
 targ1=$(mktemp -d --tmpdir dus.XXXXXXXXXX)
 /bin/echo -e "$inversvid To make Firefox work in Jammy & newer $resetvid
 apparmor.service.d/30_live_mode.conf: ConditionPathExists="
 umount "$targ1" 2>&1
 targ0=$(mktemp -d --tmpdir dus.XXXXXXXXXX)
 mount -o loop "$source" "$targ0" 2>&1
echo '$pptarg $targ1'": $pptarg $targ1"
 mount "$pptarg" "$targ1" 2>&1
 tghme=$(find "$targ0" -name '*ubuntu*.seed')
# echo "$tghme"
 tghme=${tghme##*/}
 tghme=${tghme%.seed}
 if [ "$tghme" == "ubuntustudio" ]
 then
  tghme='ubuntu-studio'
 elif [ "$tghme" == "" ]
 then
  tghme=$(grep -om1 'ubuntu-kylin' "$targ0"/casper/filesystem.manifest)
 fi
 echo "target's home directory: /home/$tghme"
 mkdir -p "$targ1"/upper/home/"$tghme"/.config/autostart
 mkdir -p "$targ1"/upper/usr/local/sbin
 cp /usr/share/mkusb/fixfox.desktop "$targ1"/upper/home/"$tghme"/.config/autostart
 cp /usr/share/mkusb/fixfox "$targ1"/upper/usr/local/sbin
 umount "$targ1" "$targ0" 2>&1
 rm -r "$targ1" "$targ0"
# read -p "press Enter to continue"
fi
---

I think tweak 3 is most relevant in this case (of this bug report).

I have also noticed that it is difficult to 'make all computers happy with the same configuration' even within the group that want an MSDOS partition table.

The bug of this report seems to be somewhat worked around by the version in dus-iso2usb version 22.0.1, but I think old HP computers with core2duo processors want a bootable flag on the partition where grub is located. However, adding that boot flag seems to stop booting in UEFI mode. I am trying to make a configuration work for all these test cases ...