Skip to content

Commit

Permalink
Fix Ubuntu bootloader for removable devices
Browse files Browse the repository at this point in the history
  • Loading branch information
sebanc committed Jan 26, 2025
1 parent a82af91 commit 3d6ee43
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Linuxloops is a generic / declarative linux distribution installer that also sup

Linuxloops GUI installer can be run from most linux ditributions live images as long as they provide a desktop environment (according to the instructions in the next section), however the available space is often limited in live images and some distros (Bazzite, BlissOS, Brunch, ChromeOS-Flex, Fedora-Atomic, Qubes, Tails) will not be installable due to the lack of storage. As such, it is recommended to use the linuxloops live disk instead.

* Download the linuxloops live 7z archive in the release section of this Github repository, extract it with your archive manager and write it to a USB flashdrive using your favorite image writer (Gnome Disk Utility / KDE ISO Image Writer for Linux or balenaEtcher for Windows).
* Download the linuxloops live 7z archive in the release section of this Github repository, extract it with your archive manager and write it to a USB flashdrive using an image writer (Gnome Disk Utility / KDE ISO Image Writer for Linux or Rufus for Windows).

* Reboot your computer and select the USB flashdrive from the UEFI boot menu.

Expand All @@ -45,12 +45,12 @@ Detailed instructions:
Note: Windows WSL does not allow to write directly to a disk but you can create disk images and write them to a USB flashdrive / SD card using Rufus/Etcher or boot them using [Grub2Win][Grub2Win link].

* Install the below packages depending on your distribution:
* Debian / Ubuntu based distributions: `sudo apt install curl libxcb-cursor0 libxcb-ewmh2 libxcb-icccm4 libxcb-keysyms1 libxkbcommon-x11-0 python3-venv xz-utils`
* Arch based distributions: `sudo pacman -Syu curl libxkbcommon-x11 python-virtualenv xcb-util-cursor xcb-util-keysyms xcb-util-wm xz`
* RHEL based distributions: `sudo dnf install curl libatomic libxkbcommon-x11 python-virtualenv xcb-util-cursor xcb-util-keysyms xcb-util-wm xz`
* Gentoo: `sudo emerge app-arch/xz-utils dev-lang/python net-misc/curl x11-libs/libxkbcommon x11-libs/xcb-util-cursor x11-libs/xcb-util-keysyms x11-libs/xcb-util-wm`
* OpenSUSE: `sudo zypper in curl libatomic1 libgthread-2_0-0 libxcb-cursor0 libxcb-keysyms1 libxcb-ewmh2 libxcb-icccm4 libxkbcommon-x11-0 python3-virtualenv xz`
* Void: `sudo xbps-install curl libxkbcommon xcb-util-cursor xcb-util-keysyms xcb-util-wm xz`
* Debian / Ubuntu based distributions: `sudo apt install curl fontconfig libasound2t64 libatomic1 libnss3 libxcb-cursor0 libxcb-ewmh2 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0 libxkbcommon-x11-0 libxkbfile1 python3-venv xz-utils`
* Arch based distributions: `sudo pacman -Syu curl fontconfig libxkbcommon-x11 nss python-virtualenv xcb-util-cursor xcb-util-keysyms xcb-util-wm xz`
* RHEL based distributions: `sudo dnf install curl fontconfig libatomic libxkbcommon-x11 nss python-virtualenv xcb-util-cursor xcb-util-keysyms xcb-util-wm xz`
* Gentoo: `sudo emerge app-arch/xz-utils dev-lang/python dev-libs/nss media-libs/fontconfig net-misc/curl x11-libs/libxkbcommon x11-libs/xcb-util-cursor x11-libs/xcb-util-keysyms x11-libs/xcb-util-wm`
* OpenSUSE: `sudo zypper in curl fontconfig libatomic1 libgthread-2_0-0 libxcb-cursor0 libxcb-ewmh2 libxcb-keysyms1 libxcb-icccm4 libxcb-shape0 libxkbcommon-x11-0 libxkbfile1 mozilla-nss python3-virtualenv xz`
* Void: `sudo xbps-install curl fontconfig libxkbcommon nss xcb-util-cursor xcb-util-keysyms xcb-util-wm xz`
* NixOS: No packages to install (the necessary packages will be installed by linuxloops for use in nix-shell environment)

* Download the Linuxloops script:
Expand Down
2 changes: 1 addition & 1 deletion Readme/Live-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Once the live image has booted, set your keyboard layout (Preferences -> Keyboar

Install 7zip, download the linuxloops live 7z archive in the release section of this Github repository and extract the linuxloops live 7z archive.

Write the resulting image file to your USB flashdrive using balenaEtcher.
Write the resulting image file to your USB flashdrive using Rufus.

Reboot your computer and select the USB flashdrive from the UEFI boot menu.

Expand Down
24 changes: 12 additions & 12 deletions linuxloops
Original file line number Diff line number Diff line change
Expand Up @@ -10716,9 +10716,6 @@ esac
cat >"${bootstrapdir}"/tmp/linuxloops/install_user <<INSTALL_USER
sudo nixos-enter << 'NIXOSCHROOT'
set -e
nix-channel --remove nixos
nix-channel --add https://nixos.org/channels/nixos-$(echo ${nixos_version} | tr A-Z a-z) nixos
nix-channel --update
useradd -m '${useraccount_name}'
usermod -aG wheel,networkmanager '${useraccount_name}'
NIXOSCHROOT
Expand Down Expand Up @@ -10922,9 +10919,6 @@ esac
cat >"${bootstrapdir}"/tmp/linuxloops/install_user <<INSTALL_USER
sudo nixos-enter << 'NIXOSCHROOT'
set -e
nix-channel --remove nixos
nix-channel --add https://nixos.org/channels/nixos-$(echo ${nixos_version} | tr A-Z a-z) nixos
nix-channel --update
useradd -m '${useraccount_name}'
usermod -aG wheel,networkmanager '${useraccount_name}'
NIXOSCHROOT
Expand Down Expand Up @@ -16482,7 +16476,7 @@ add_linuxloops_post
echo -e "LINUXLOOPSBINARY" >> "${bootstrapdir}"/tmp/linuxloops/install_initramfs
echo -e "chmod 0755 /boot/linuxloops/linuxloops" >> "${bootstrapdir}"/tmp/linuxloops/install_initramfs
echo -e "(cd /boot/linuxloops && find . | cpio -o -H newc | gzip > /boot/linuxloops/linuxloops-recovery.img)" >> "${bootstrapdir}"/tmp/linuxloops/install_initramfs
echo -e "if grep -q '^hostonly=' /etc/dracut.conf; then sed -i '@^hostonly=@d' /etc/dracut.conf; fi; echo 'hostonly=\"yes\"' >> /etc/dracut.conf" >> "${bootstrapdir}"/tmp/linuxloops/install_initramfs
echo -e "echo 'hostonly=\"no\"' > /etc/dracut.conf.d/99-linuxloops.conf" >> "${bootstrapdir}"/tmp/linuxloops/install_initramfs
echo -e "dracut --regenerate-all --force" >> "${bootstrapdir}"/tmp/linuxloops/install_initramfs
chmod 0755 "${bootstrapdir}"/tmp/linuxloops/install_initramfs
}
Expand Down Expand Up @@ -16880,8 +16874,9 @@ if [ "${distribution}" == "Bazzite" ] || [ "${distribution}" == "Fedora-Atomic"
for i in \$(echo \${cmdline_root} \${cmdline} \${cmdline_extra} | sed -e 's@ @\n@g'); do kargs="\${kargs} --append-if-missing=\${i}"; done
cat >>/boot/linuxloops/reinstall-bootloader <<REINSTALLBOOTLOADER
rpm-ostree kargs \${kargs}
echo -e 'add_drivers+=" 8250_dw aes amdgpu atkbd btrfs cbc dm-crypt exfat ext4 fuse i8042 i915 intel_lpss intel_lpss_pci loop nouveau nvme quota_v1 quota_v2 serio sha256 surface_aggregator surface_aggregator_registry surface_hid surface_hid_core usbhid xhci_pci "' > /etc/dracut.conf.d/linuxloops.conf
echo -e 'install_items+=" /etc/vconsole.conf /usr/bin/bash /usr/sbin/blkid /usr/sbin/cryptsetup /usr/bin/cut /usr/sbin/e2fsck /usr/bin/find /usr/bin/grep /usr/sbin/losetup /usr/bin/lsblk /usr/bin/ntfs-3g /usr/bin/ntfsfix /usr/bin/ps /usr/bin/setfont /usr/bin/setsid /usr/lib/systemd/systemd-sysroot-fstab-check "' >> /etc/dracut.conf.d/linuxloops.conf
echo -e 'add_drivers+=" 8250_dw aes amdgpu atkbd btrfs cbc dm-crypt exfat ext4 fuse i8042 i915 intel_lpss intel_lpss_pci loop nouveau nvme quota_v1 quota_v2 serio sha256 surface_aggregator surface_aggregator_registry surface_hid surface_hid_core usbhid xhci_pci "' > /etc/dracut.conf.d/99-linuxloops.conf
echo -e 'install_items+=" /etc/vconsole.conf /usr/bin/bash /usr/sbin/blkid /usr/sbin/cryptsetup /usr/bin/cut /usr/sbin/e2fsck /usr/bin/find /usr/bin/grep /usr/sbin/losetup /usr/bin/lsblk /usr/bin/ntfs-3g /usr/bin/ntfsfix /usr/bin/ps /usr/bin/setfont /usr/bin/setsid /usr/lib/systemd/systemd-sysroot-fstab-check "' >> /etc/dracut.conf.d/99-linuxloops.conf
echo 'hostonly=\"no\"' >> /etc/dracut.conf.d/99-linuxloops.conf
rpm-ostree initramfs --enable
if [ "${install_type}" == "image" ]; then
sed "s#ostree admin instutil grub2-generate#ostree admin instutil grub2-generate | sed 's|linux16 |linux |g' | sed 's|initrd16 |initrd $(if [ "${root_fstype}" == "btrfs" ]; then echo /@boot; fi)/linuxloops/linuxloops.img |g'$(if [ "${root_fstype}" == "btrfs" ]; then echo " | sed 's| /ostree| /@boot/ostree|g'"; fi)#g" /etc/grub.d/15_ostree > /etc/grub.d/15_ostree_linuxloops
Expand Down Expand Up @@ -16922,6 +16917,8 @@ REINSTALLBOOTLOADER
else
cat >>/boot/linuxloops/reinstall-bootloader <<REINSTALLBOOTLOADER
dnf reinstall -y shim-* grub2-efi-* grub2-common
cp /boot/efi/EFI/"${bootloader_id}"/grubx64.efi /boot/efi/EFI/BOOT/grubx64.efi
cp /boot/efi/EFI/"${bootloader_id}"/grub.cfg /boot/efi/EFI/BOOT/grub.cfg
REINSTALLBOOTLOADER
fi
cat >>/boot/linuxloops/reinstall-bootloader <<REINSTALLBOOTLOADER
Expand Down Expand Up @@ -16949,7 +16946,10 @@ REINSTALLBOOTLOADER
cat >/usr/sbin/grub-install <<'GRUBINSTALL'
#!/bin/sh
grub-install.real "\\\$@" --bootloader-id="${bootloader_id}"
grub-install.real "\\\$@" --removable
# Do not use removable as Ubuntu will install the live iso version in that case which has a specific GRUB configuration path
grub-install.real "\\\$@" --bootloader-id="BOOT"
rm -f /boot/efi/EFI/BOOT/BOOTX64.EFI
mv /boot/efi/EFI/BOOT/shimx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
find /boot/efi -type f -iname fbx64.efi -exec rm {} \;
find /boot/efi -type f -iname bootx64.csv -exec rm {} \;
GRUBINSTALL
Expand Down Expand Up @@ -19355,7 +19355,7 @@ until false; do
done
destination=$(gui_launch -m disk -t "Drive selection" -p "${list}" -q "Select the target drive:" | cut -d' ' -f1)
if [ -z "${destination}" ]; then exit 1; elif [ "${destination}" == "refresh" ]; then continue; fi
if [ "${destination}" == "return" ]; then break; continue; fi
if [ ! -z "${wsl}" ] && [ "${destination}" == "return" ]; then break; continue 2; elif [ "${destination}" == "return" ]; then break; continue; fi
fullpath="${destination}"
if [ "${distribution}" == "BlissOS" ] || [ "${distribution}" == "Brunch" ] || [ "${distribution}" == "ChromeOS-Flex" ] || [ "${distribution}" == "Tails" ]; then
if [ $(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) - 14 )) -eq 0 ]; then
Expand Down Expand Up @@ -19533,7 +19533,7 @@ else
if [ ${return_value} -eq 1 ]; then exit_with_error "Failed to perform the installation of ${distribution} in chroot."; fi
grub_config
if [ ! -z "${wsl}" ]; then
grubinstall="The ${distribution} disk image has been created at $(echo ${fullpath:5:1} | tr a-z A-Z):\\\\$(echo ${fullpath:7} | sed 's@\/@\\\\@g'). You can either write this disk image to a usb flashdrive / sdcard with a tool like rufus/etcher or boot it directly using Grub2Win.<br><br>********************************************************************************************<br>If you want to boot the image directly using Grub2Win:<br>The grub config needed to boot ${distribution} has been generated in the file $(echo ${fullpath:5:1} | tr a-z A-Z):\\\\$(echo ${fullpath:7} | sed 's@\/@\\\\@g').grub.txt<br>You need to install Grub2Win and launch it, click on \"Manage Boot Menu\" -> \"Add a new entry\" -> set \"Type\" as \"Create user section\", open the file $(echo ${fullpath:5:1} | tr a-z A-Z):\\\\$(echo ${fullpath:7} | sed 's@\/@\\\\@g').grub.txt and copy its content in the Grub2Win notepad window, save and close the Grub2Win notepad window then click \"Apply\" and \"OK\".<br>Please note that ${distribution} will not be bootable and / or stable if you do not perform the below actions (Refer to Windows online resources if needed):<br>- Ensure that bitlocker is disabled on the drive which contains the ${distribution} image or disable it.<br>- Disable fast startup.<br>- Disable hibernation.<br><br>Once done, reboot your computer and select ${distribution} from the Grub2Win menu.<br>********************************************************************************************"
grubinstall="The ${distribution} disk image has been created at $(echo ${fullpath:5:1} | tr a-z A-Z):\\$(echo ${fullpath:7} | sed 's@\/@\\@g'). You can either write this disk image to a usb flashdrive / sdcard with a tool like rufus/etcher or boot it directly using Grub2Win.<br><br>********************************************************************************************<br>If you want to boot the image directly using Grub2Win:<br>The grub config needed to boot ${distribution} has been generated in the file $(echo ${fullpath:5:1} | tr a-z A-Z):\\$(echo ${fullpath:7} | sed 's@\/@\\@g').grub.txt<br>You need to install Grub2Win and launch it, click on \"Manage Boot Menu\" -> \"Add a new entry\" -> set \"Type\" as \"Create user section\", open the file $(echo ${fullpath:5:1} | tr a-z A-Z):\\$(echo ${fullpath:7} | sed 's@\/@\\@g').grub.txt and copy its content in the Grub2Win notepad window, save and close the Grub2Win notepad window then click \"Apply\" and \"OK\".<br>Please note that ${distribution} will not be bootable and / or stable if you do not perform the below actions (Refer to Windows online resources if needed):<br>- Ensure that bitlocker is disabled on the drive which contains the ${distribution} image or disable it.<br>- Disable fast startup.<br>- Disable hibernation.<br><br>Once done, reboot your computer and select ${distribution} from the Grub2Win menu.<br>********************************************************************************************"
gui_launch -m finished -t "Grub configuration" -q "${grubinstall}"
elif [ ! -z "${brunch}" ]; then
grubinstall="The grub config needed to boot ${distribution} has been generated in the file \"${fullpath}.grub.txt\".<br><textarea cols=\"80\" rows=\"14\" style=\"font-size: 14px;\">${config}</textarea><br><br>Now copy the above grub config, run \"sudo edit-brunch-config -g\" and paste it (lines between stars) at the end of the file.<br><br>Once done, press CTRL+X and then ENTER to save, reboot your computer and start ${distribution}"
Expand Down

0 comments on commit 3d6ee43

Please sign in to comment.