Difference between revisions of "Undead USB Install/undead2live"

From Funtoo
Jump to navigation Jump to search
(setup page for next phase, initramfs generation, and post backup work around, booting debian kernel from the debian live cds which already load up overlay etc.)
(almost got er booting.)
Line 120: Line 120:
menuentry "funtoo" {
menuentry "funtoo" {
set gfxpayload=keep
set gfxpayload=keep
linux /live/vmlinuz boot=live quiet --
linux /live/vmlinuz boot=live root=/dev/ram0 real_root=/dev/loop0 looptype=squashfs loop=/live/filesystem.squashfs cdroot quiet --
initrd /live/amd-uc.img /live/early_ucode.cpio /live/initramfs
initrd /live/amd-uc.img /live/early_ucode.cpio /live/initramfs
}
}
}}
}}


*just like we load multiple initramfs images, we need to build a 4th initramfs image to load the overlay file system and mount things.
*it seems like it wants the loop to be at /livecd.squashfs
https://wiki.gentoo.org/wiki/Custom_Initramfs#Init


*exit chroot, remount without the /dev & sys so on directories so we can write the iso output:
*exit chroot, remount without the /dev & sys so on directories so we can write the iso output:

Revision as of 22:33, June 4, 2021

   Warning

this is an experimental page without resolving conclusion. this is just exploration and experimentation with the goal of making live media. the grubiso drop in replacement for isolinux within this document is functional, and tested working.


  • on your host funtoo system emerge tools for cd mastering:
root # emerge cdrtools squashfs-tools isomaster libisoburn

make an undead usb from a stage 3 containing networkmanager, xfce4, x11-xorg, fchroot, slim, mtools, and set to auto login as root terminals. setup slim to boot root so the entire undead key does not have a password. tidy up the undead key delete the stage3 tarball, delete the sources directory. insert auto as root's file system in /etc/fstab so it will load in both ext2 & squashfs modes. partuuid survives the dd procedure so label by that. patch and rebuild your initramfs to support loading squashfs and rebuild your initramfs. change the sources version number to reflect your installation.

root # emerge livecd-tools && rc-update add autoconfig default
root # sed '/MODULES_FS/ s/\"$/ autofs4 loop hfsplus isofs overlay squashfs\"/' -i /usr/share/genkernel/arch/$(arch)/modules_load
root # genkernel initramfs --clean --disklabel --ramdisk-modules --fullname=debian-sources-x86_64-5.10.28_p1
  • setup grub to pass the boot=live kernel parameter:
   /etc/default/grub - bootlive
GRUB_CMDLINE_LINUX="boot=live live-media-path=/live quiet"

squashfs is read only and requires a tmpfs or overlay filesystem to run properly. the overlay fstab statement is usually implemented from the overlay upper file system.

root # echo "overlay / overlay rw 0 0" > /etc/fstab
root # echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> /etc/fstab
or
root # echo 'tmpfs / tmpfs defaults 0 0' > /etc/fstab

mount your undead usb key, but not dev sys or any of the other stuff because were going to package it with squashfs.

root # mount /dev/funtoo2 /mnt/funtoo
root # mount /dev/funtoo1 /mnt/funtoo/boot

edit /mnt/funtoo/etc/fstab

root # mksquashfs /mnt/funtoo /mnt/filesystem.squashfs
  • unmount before pushing squash image to be the new root:
root # umount -lr funtoo

make a directory named live and have filesystem.squashfs in the directory. for now just copy a debian live cd's /live/vmlinuz & /live/initramfs

root # mkdir /mnt/funtoo/live
root # cp /mnt/filesystem.squashfs /mnt/funtoo/live
root # cp /mnt/funtoo/boot/kernel-debian-sources-x86_64-5.10.28_p1 /mnt/funtoo/live/vmlinuz
root # cp /mnt/funtoo/boot/initramfs-debian-sources-x86_64-5.10.28_p1 /mnt/funtoo/live/initramfs
root # cp /mnt/funtoo/boot/amd-uc.img /mnt/funtoo/live
root # cp /mnt/funtoo/boot/early_ucode.cpio /mnt/funtoo/live
root # mount /dev/funtoo2 /mnt/funtoo
root # mount /dev/funtoo1 /mnt/funtoo/boot

chroot into the squashfs image to manipulate grub on the read write fat partition.

root # cd /mnt/funtoo
mount -t proc none /mnt/funtoo/proc
mount --rbind /sys /mnt/funtoo/sys
mount --rbind /dev /mnt/funtoo/dev
env -i HOME=/root TERM=$TERM $(which chroot) /mnt/funtoo bash -l

update boot entries so grub boots squashfs:

root # cd /boot
root # ego boot update
root # grub-mkconfig -o /boot/grub/grub.cfg
  • generate mbr/bios eltorito boot image:
  • make grubiso, the isolinux drop in replacement:
root # grub-mkimage -p /boot -o tmp_core.img -O i386-pc biosdisk iso9660 multiboot normal ls cat help
root # cat /usr/lib/grub/i386-pc/cdboot.img tmp_core.img > /boot/grubiso.img
  • generate uefi eltorito alternate boot image:
root # dd if=/dev/zero of=EFI/BOOT/efiboot.img bs=512 count=2880
root # mkfs.msdos -F 12 -n 'FUNTOO' EFI/BOOT/efiboot.img
root # mmd -i EFI/BOOT/efiboot.img ::EFI
root # mmd -i EFI/BOOT/efiboot.img ::EFI/BOOT
root # mcopy -i EFI/BOOT/efiboot.img EFI/BOOT/bootx64.efi ::EFI/BOOT/bootx64.efi
root # mv EFI/BOOT/efiboot.img uefi.img
  • write basic grub config:
   /mnt/funtoo/boot/grub/grub.cfg - basic grub configuration
if loadfont /boot/grub/font.pf2 ; then
	insmod all_video
	else
	set gfxmode=auto
	insmod efi_gop
	insmod efi_uga
	insmod gfxterm
	terminal_output gfxterm
	insmod ieee1275_fb
	insmod vbe
	insmod vga
	insmod video_bochs
	insmod video_cirrus
fi

menuentry "funtoo" {
	set gfxpayload=keep
	linux /live/vmlinuz boot=live root=/dev/ram0 real_root=/dev/loop0 looptype=squashfs loop=/live/filesystem.squashfs cdroot quiet --
	initrd /live/amd-uc.img /live/early_ucode.cpio /live/initramfs
}
  • it seems like it wants the loop to be at /livecd.squashfs
  • exit chroot, remount without the /dev & sys so on directories so we can write the iso output:
root # exit
root # umount -lr funtoo
root # mount /dev/funtoo2 /mnt/funtoo
root # mount /dev/funtoo1 /mnt/funtoo/boot
root # cd /mnt/funtoo

generate iso image, and make it hybrid mode so it can be read from both cd/dvd, and usb key.

root # xorrisofs -D -r -V "FUNTOO" -cache-inodes -J -l -b boot/grubiso.img -c boot/boot.cat -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/uefi.img -no-emul-boot -o ../custom.iso .
root # isohybrid --uefi ../custom.iso

or use grubs framework to generate the ISO image.

root # grub-mkrescue -J -R -V "${ISO_VOLUME}" -quiet -o ../output.iso .

Testing

Test your iso booting in both bios and uefi mode in virtualbox, or qemu or vmware virtualization. Once you're satisfied that it works well under virtualization, burn it to a usb key using etcher and test booting on real hardware.

sources used

https://help.ubuntu.com/community/LiveCDCustomization#Assembling_the_file_system alternate boot image osdev guide https://github.com/syzdek/efibootiso