Difference between revisions of "User:Pnoecker/Undead USB Install/undead2live"

From Funtoo
Jump to navigation Jump to search
(fix wording about tmpfs vs overlay filesystems, and note overlays fstab is usually implemented from the upper filesystem.)
(remove genkernel next, move slim to lightdm since slim doesn't support unpassworded root login.)
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{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.}}
{{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.}}


https://help.ubuntu.com/community/LiveCDCustomization#Assembling_the_file_system
{{warning|at the time of writing this document lacks a working kernel initramfs, i am using [[Cd_remastering]] of gentoo minimal as a temporary work around.
}}
 
*on your host funtoo system emerge tools for cd mastering:
 
{{console|body=
###i## emerge cdrtools squashfs-tools isomaster libisoburn mtools
}}
 
{{note|catalyst uses virtual/cdrtools}}


make an undead usb from a stage 3 containing networkmanager, xfce4, x11-xorg, fchroot, slim, with auto login 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.
make an undead usb from a stage 3 containing networkmanager, xfce4, x11-xorg, fchroot, lightdm, mtools, virtualbox guest additions, and set to auto login as root terminals.  setup lightdm to boot root so the entire undead key does not have to 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.


{{console|body=
{{console|body=
###i## sed '/MODULES_FS/ s/\"$/ autofs4 loop hfsplus isofs overlay squashfs\"/' -i /usr/share/genkernel/arch/$(arch)/modules_load
###i## emerge livecd-tools && rc-update add autoconfig default
###i## sed '/MODULES_FS/ s/\"$/ loop hfsplus isofs overlay squashfs\"/' -i /usr/share/genkernel/arch/$(arch)/modules_load
###i## genkernel initramfs --clean --disklabel --ramdisk-modules --fullname=debian-sources-x86_64-5.10.28_p1
###i## genkernel initramfs --clean --disklabel --ramdisk-modules --fullname=debian-sources-x86_64-5.10.28_p1
}}
====automated grub setup====
*setup grub to pass the kernel parameters:
{{file|name=/etc/default/grub|desc=bootlive|body=
GRUB_CMDLINE_LINUX="dokeymap overlayfs cdroot 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.
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.


a fstab using tmpfs statements could possibly work but most documentation points to using overlay filesystems.
{{console|body=
{{console|body=
###i## echo "overlay / overlay rw 0 0" > /etc/fstab
###i## echo "overlay / overlay rw 0 0" > /etc/fstab
Line 18: Line 33:
or
or
###i## echo 'tmpfs / tmpfs defaults 0 0' > /etc/fstab
###i## echo 'tmpfs / tmpfs defaults 0 0' > /etc/fstab
}}
on your host funtoo system emerge tools for cd mastering:
{{console|body=
###i## emerge cdrtools squashfs-tools isomaster libisoburn
}}
}}


Line 33: Line 42:
}}
}}


edit /mnt/funtoo/etc/fstab file system's from ext4 & vfat to auto so we can have it auto load squashfs.
edit /mnt/funtoo/etc/fstab


{{console|body=
{{console|body=
Line 39: Line 48:
}}
}}


using isomaster you can insert /mnt/filesystem.squashfs into an xubuntu live cd.  virtualbox will boot it, real hardware will not.  it probably needs eltorito.img or isolinux.bin setup to chainload grub or whatever.  the idea is were inserting our chroot into another live cd's chroot location.
* unmount before pushing squash image to be the new root:


xubuntu has a casper/ directory in the iso that contains a file called filesystem.squashfs, delete their chroot, insert ours.  write iso.  cheat to win has drawbacks, they're using overlayfs so they're overlaying files on the filesystem somewhere so another choice of live cd to modify is probably a good idea.
{{console|body=
###i## umount -lr funtoo
}}


maybe we can get our grub loading the squashed image with a command like this.
*copy the squash image to the cd root:
{{console|body=
{{console|body=
###i## dd if=/mnt/filesystem.squashfs of=/dev/funtoo2
###i## mkdir /mnt/funtoo/live
###i## cp /mnt/filesystem.squashfs /mnt/funtoo/image.squashfs
}}
}}


Line 63: Line 75:
}}
}}


update boot entries so grub boots squashfs:
evaluate autogenerated configuration:
{{console|body=
{{console|body=
###i## cd /boot
###i## grub-mkconfig
###i## ego boot update
}}
###i## grub-mkconfig -o /boot/grub/grub.cfg
 
====basic grub====
*write basic grub config:
{{file|name=/mnt/funtoo/boot/grub/grub.cfg|desc=basic grub configuration|body=
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 /boot/vmlinuz root=/dev/ram0 dokeymap init=/linuxrc overlayfs looptype=squashfs loop=/image.squashfs cdroot quiet --
initrd /boot/amd-uc.img /boot/early_ucode.cpio /boot/initramfs
}
}}
}}


generate mbr/bios eltorito boot image:
*generate mbr/bios eltorito boot image:


*make grubiso, the isolinux drop in replacement:
{{console|body=
{{console|body=
###i## grub-mkimage -p /boot -o tmp_core.img -O i386-pc biosdisk iso9660 multiboot normal ls cat help
###i## grub-mkimage -p /boot -o tmp_core.img -O i386-pc biosdisk iso9660 multiboot normal ls cat help
Line 77: Line 113:
}}
}}


generate uefi eltorito alternate boot image:
*make boot efi image.
[https://wiki.osdev.org/UEFI#Creating_disk_images alternate boot image osdev guide]
 
https://github.com/syzdek/efibootiso
{{console|body=
###i## grub-mkimage -o bootx64.efi -O x86_64-efi -p /boot/grub boot linux linux16 normal configfile part_gpt part_msdos fat iso9660 udf test keystatus loopback regexp probe efi_gop efi_uga all_video gfxterm font echo read help ls cat halt reboot
}}
 
*generate uefi eltorito alternate boot image:


xorriso requires the uefi disk image to be either 1.2Mb, 1.4Mb, or 2.8Mb.
{{console|body=
###i## dd if=/dev/zero of=EFI/BOOT/efiboot.img bs=512 count=2880
###i## mkfs.msdos -F 12 -n 'FUNTOO' EFI/BOOT/efiboot.img
###i## mmd -i EFI/BOOT/efiboot.img ::EFI
###i## mmd -i EFI/BOOT/efiboot.img ::EFI/BOOT
###i## mcopy -i EFI/BOOT/efiboot.img EFI/BOOT/bootx64.efi ::EFI/BOOT/bootx64.efi
###i## mv EFI/BOOT/efiboot.img uefi.img
}}


exit chroot
*exit chroot, remount without the /dev & sys so on directories so we can write the iso output:
{{console|body=
{{console|body=
###i## exit
###i## exit
###i## umount -lr funtoo
###i## mount /dev/funtoo2 /mnt/funtoo
###i## mount /dev/funtoo1 /mnt/funtoo/boot
###i## cd /mnt/funtoo
###i## cd /mnt/funtoo
}}
}}
Line 91: Line 141:
generate iso image, and make it hybrid mode so it can be read from both cd/dvd, and usb key.
generate iso image, and make it hybrid mode so it can be read from both cd/dvd, and usb key.
{{console|body=
{{console|body=
###i## 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 .
###i## 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 .
###i## isohybrid --uefi ../custom.iso
###i## isohybrid --uefi ../custom.iso
}}
}}


or use grubs framework to generate the ISO image.
====or use grubs framework to generate the ISO image.====


{{console|body=
{{console|body=
Line 103: Line 153:
== Testing ==
== 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.
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
[https://wiki.osdev.org/UEFI#Creating_disk_images alternate boot image osdev guide]
https://github.com/syzdek/efibootiso

Latest revision as of 17:35, June 16, 2023

   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.

   Warning

at the time of writing this document lacks a working kernel initramfs, i am using Cd_remastering of gentoo minimal as a temporary work around.

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

catalyst uses virtual/cdrtools

make an undead usb from a stage 3 containing networkmanager, xfce4, x11-xorg, fchroot, lightdm, mtools, virtualbox guest additions, and set to auto login as root terminals. setup lightdm to boot root so the entire undead key does not have to 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/\"$/ 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

automated grub setup

  • setup grub to pass the kernel parameters:
   /etc/default/grub - bootlive
GRUB_CMDLINE_LINUX="dokeymap overlayfs cdroot 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
  • copy the squash image to the cd root:
root # mkdir /mnt/funtoo/live
root # cp /mnt/filesystem.squashfs /mnt/funtoo/image.squashfs
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

evaluate autogenerated configuration:

root # grub-mkconfig

basic grub

  • 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 /boot/vmlinuz root=/dev/ram0 dokeymap init=/linuxrc overlayfs looptype=squashfs loop=/image.squashfs cdroot quiet --
	initrd /boot/amd-uc.img /boot/early_ucode.cpio /boot/initramfs
}
  • 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
  • make boot efi image.
root # grub-mkimage -o bootx64.efi -O x86_64-efi -p /boot/grub boot linux linux16 normal configfile part_gpt part_msdos fat iso9660 udf test keystatus loopback regexp probe efi_gop efi_uga all_video gfxterm font echo read help ls cat halt reboot
  • 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
  • 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