https://www.funtoo.org/index.php?title=User:Apple/projects/ISOMetro&feed=atom&action=historyUser:Apple/projects/ISOMetro - Revision history2024-03-29T09:18:31ZRevision history for this page on the wikiMediaWiki 1.36.2https://www.funtoo.org/index.php?title=User:Apple/projects/ISOMetro&diff=657&oldid=prevApple: /* Testing checklist */ update2011-01-06T01:26:53Z<p><span dir="auto"><span class="autocomment">Testing checklist: </span> update</span></p>
<p><b>New page</b></p><div>==Abstract==<br />
Funtoo needs to be able to create bootable media.<br />
<br />
''Needs? We seem to be doing fine without our own branded media.''<br />
<br />
<br />
Anyway, it shouldn't be hard to add ISO/image generation to Metro.<br />
<br />
''I should say I get really confuzed when figuring out bootloader->kernel->init, so this might get messy.''<br />
<br />
<br />
The following is some pseudosteps which I think would create an ISO.<br />
<br />
# Create a stage4, but instead of tar compression, use squashfs.<br />
#* From brief exploration, it seems <tt>targets/gentoo/stage/capture</tt> will be the place to edit.<br />
# Make an kernel w/ genkernel; should be able to handle squashfs.<br />
#* If not with genkernel, get a generic kernel (monolithic or modular), make initramfs with better-initramfs.<br />
# Prepare isolinux.<br />
#* ISOLINUX's documentation is a little arcane, and I have no idea how gentoo's livedvd handles EFI.<br />
#...<br />
# Profit!<br />
<br />
==LiveCD/DVD Generation==<br />
===Squashfs compression in Metro===<br />
Taking a look at <tt>etc/builds/funtoo/build.conf</tt>, there is no reference to what type to capture (see <tt>targets/gentoo/stage/capture/</tt>). I have no idea where to specify <tt>ami</tt> (and therefore any other capture method).<br />
<br />
Metro would need to create a stage4, then use that as a seed for an ISO (or, shall we do something completely different?).<br />
<br />
====Update 1====<br />
Metro comes bundled with a stage4 target. The stage4 collects <tt>targets/gentoo/stage/capture/tar.spec</tt>; some quick edits later it should be squashfs-compressed.<br />
<br />
{{Info|I kept the stage4 as-is as emerge/packages is done in that step, and split genkernel and squashing into "stage5".}}<br />
<br />
This stage contains a full dev-environment (gcc, portage etc.) which usually doesn't go onto installation media. I like them there, but others may want a way to prune.<br />
<br />
{{Root|<nowiki># ROOT=/mnt/gentoo emerge system # anyone?</nowiki>}}<br />
<br />
====Update 2====<br />
Apart from fine-tuning <tt>init</tt> (and pruning), this is pretty much done.<br />
<br />
=====Init=====<br />
Autodetection, MOTD, autologin all need to be done (currently it boots into a regular login which hasn't been setup).<br />
<br />
Waiting for [[Funtoo Startup]] to get written.<br />
<br />
====Update 3====<br />
Autologin works (not like gentoo livecd, but it drops to a root shell which is what we want). Autodetection goes under OpenRC tweaking.<br />
<br />
===Bootable kernel===<br />
I'm pretty sure a genkernel kernel can be put on a livecd as-is, but by now the squashfs is set in stone; too late for the modules to be placed in <tt>/lib/modules</tt>.<br />
<br />
I seem to remember a gentoo<sub>or maybe it was ubuntu...</sub> livecd with grub. How?<br />
<br />
====Update 1====<br />
With "stage5", we actually have the kernel and modules inside the squashfs (so no problem there); the problem is now we need it _outside_...<br />
<br />
Probably not a major problem. <tt>unsquashfs</tt> can selectively extract any necessaries from it.<br />
<br />
The final part of the process is bringing it altogether. I can't imagine that metro can take a stage5.sqfs and make funtoo-${subarch}.iso.<br />
<br />
====Update 2====<br />
Using a shell script, it can be quite easy to collect the pieces for a livecd. I'm not sure what metro can run after <tt>steps/capture</tt>, but that might be able to do it at some point after.<br />
<br />
isolinux and its config are pretty static on an arch, but I would like to see a dynamic way of creating them.<br />
<br />
Other than that, just some init (loads of openrc errors) tweaking.<br />
<br />
====Update 3====<br />
I'm using <tt>cdupdate.sh</tt> to apply a workaround for init/openrc.<br />
<br />
Just tweaking left.<br />
<br />
==LiveUSB==<br />
Now, this is slightly easier yet more difficult. A liveUSB image should be the product of:<br />
{{Root|<nowiki># dd bs=4096 if=/dev/sda of=funtoo-liveusb.img</nowiki>}}<br />
<br />
However, boot-loaders (EXTLINUX, GRUB) need a real mounted device, which is $DIFFICULTY; especially when considering automating it: metro can (if your portage snapshot is already made) run many instances at the same time without problem; otherwise you'd need a spare partition and fast drives so you can <tt>dd</tt> off many images (I suspect it would be several hours per image).<br />
<br />
Mounting an empty image via loop and writing to it doesn't work AFAIK:<br />
{{Root|<nowiki>#</nowiki> mount -o loop blank.img /mnt/gentoo}}<br />
<br />
===LVM===<br />
Some of us are loud proponents for lvm, and installing a gentoo/funtoo instance on an LVM on a USB has the possibility of being '''*very*''' practical.<br />
<br />
Basically, instead of the squashfs, we have a (compressed or not) lvm image that we mount as our rootfs in the live environment; the "stage 5" (stage 4 + kernel stuff).<br />
<br />
To install it, just <tt>dd</tt> the lvm to the hdd (as long as the hdd has the capacity to hold the lvm image).<br />
<br />
This should put a very small partition onto the hdd with the rest zeroed and unused. In the live environment: fdisk in and change the end cylinder of the partition (max it out), then pvresize to get the lvm filling the disk.<br />
<br />
====Update 1====<br />
Unix's "everything is a file" falls down here (just saying).<br />
<br />
====Update 2====<br />
isolinux's documentation mentions isohybrid, which can make the the same livecd also bootable from keys.<br />
<br />
Two updates down, I haven't looked at this yet (LiveCD first).<br />
<br />
===References===<br />
[http://edoceo.com/liber/gentoo-live-usb http://edoceo.com/liber/gentoo-live-usb] - Unfortunately, in this case, pretty much all of the work has already been done by catalyst.<br />
<br />
[http://muzso.hu/2009/07/28/how-to-resize-an-lvm-physical-volume-without-a-reboot http://muzso.hu/2009/07/28/how-to-resize-an-lvm-physical-volume-without-a-reboot]<br />
<br />
==Current Issues==<br />
===Read-only file system===<br />
The live CD environment is completely read-only, which is a<br />
problem most of the time but very inconvenient if you download<br />
a stage without preparing a hard disk (or tmpfs) first.<br />
<br />
Until a suitable workaround is found and implemented, please try the following.<br />
<br />
====Workaround 1====<br />
Prepare a temporary directory in ram:<br />
{{Root|<nowiki># mount -t tmpfs tmpfs /tmp<br />
# cd /tmp<br />
# wget ...stage3...</nowiki>}}<br />
<br />
====Workaround 2====<br />
Prepare your hard disk on <tt>/mnt/gentoo</tt> and download it there:<br />
{{Root|<nowiki># fdisk /dev/...<br />
# cfdisk /dev/...<br />
<br />
# mkfs.... /dev/...<br />
# mount /dev/... /mnt/gentoo<br />
# cd /mnt/gentoo<br />
# wget ...stage3...</nowiki>}}<br />
<br />
====Workaround 3====<br />
Pipe wget into tar:<br />
{{Root|<nowiki># fdisk /dev/...<br />
# cfdisk /dev/...<br />
<br />
# mkfs.... /dev/...<br />
# mount /dev/... /mnt/gentoo<br />
# wget -O- ...stage3... | tar xvjpf - -C /mnt/gentoo</nowiki>}}<br />
<br />
==Usage==<br />
{{Info|Edit line 1 for your architecture. If your arch is amd64, just copy and paste (without the '#'s).}}<br />
<br />
The following block only needs to be run once, the first time you use metro.<br />
{{Root|<nowiki># arch=amd64 export arch<br />
# startdate=$(date +%Y.%m.%d) export startdate<br />
# cd /home<br />
# mkdir -p mirror/linux/funtoo/$arch/{.control/{version,strategy},funtoo-$arch-current}<br />
# cd /home/mirror/linux/funtoo/$arch/.control<br />
# echo current > version/stage3<br />
# echo local > strategy/build<br />
# echo stage3 > strategy/seed<br />
# wget -O /home/mirror/linux/funtoo/$arch/funtoo-$arch-current/stage3-$arch-current.tar.xz \<br />
ftp://ftp.nluug.nl/pub/metalab/distributions/funtoo/funtoo/$arch/stage3-$arch-current.tar.xz<br />
# cd /root<br />
# git clone git://github.com/theappleman/metro.git<br />
# cd metro<br />
# git checkout -b squashfs origin/squashfs<br />
# ln -s /root/metro/metro /usr/bin/metro<br />
# ln -s /root/metro /usr/lib/metro<br />
# emerge -1 app-cdr/cdrtools sys-boot/syslinux sys-fs/squashfs-tools</nowiki>}}<br />
<br />
{{Root|<nowiki># /usr/lib/metro/scripts/ezbuild.sh iso $arch $startdate<br />
# cdrecord dev=/dev/cdrom /home/mirror/linux/funtoo/$arch/funtoo-$arch-$startdate/stage5-$arch-$startdate.iso</nowiki>}}<br />
<br />
==Testing checklist==<br />
Due to the complexity, '''many''' things are likely to go wrong. Potential testers should be asked to nohup or tee their output for debugging.<br />
<br />
* stage 1, 2 and 3 should be exactly like using the original funtoo/~funtoo build targets.<br />
* stage 4 is a stage 3 with some extra packages (no configuration).<br />
* stage 5 is the complex step<br />
** stage 5 installs an extra package (because of its special USE flag), compiles a kernel and compresses it into a squashfs-image instead of a tarball.<br />
** Then, it takes the squashfs image and wraps an ISO around it.<br />
**# ISO 9660 boot code binary data (7zip hides this in <nowiki>[BOOT]</nowiki>)<br />
**# kernel, initramfs etc<br />
**# isolinux config<br />
**# cdupdate.sh<br />
**# /livecd marker<br />
**# memtest<br />
**# extra files<br />
**# <s>Volume ID</s> (disabled for now)<br />
**# Hybrid booting<br />
**# GPG signature<br />
* Booting<br />
*# Main kernel<br />
*# Memtest kernel<br />
*# Hardware detection<br />
*# Media discovery<br />
*# <s>unionfs</s> (kernel support included, disabled by default)<br />
*# cdupdate.sh (before openrc init)<br />
*# OpenRC<br />
*# fstab<br />
*# Autologin<br />
* Main sequence<br />
*# Packages<br />
*#* git<br />
*#* dhcpcd, wireless, ppp/pptp<br />
*#* portage<br />
*#* filesystem utils<br />
*#* luks, dmraid, lvm<br />
*#* gcc (etc.)<br />
*# Installation<br />
*#* Downloading a stage tarball to the live environment.<br />
*#* (Downloading a portage tree in the live environment.)<br />
*#* (<code># ROOT=/mnt/gentoo emerge -e system</code>)<br />
*# Shutdown<br />
*## LiveCD unmount<br />
*## <s>Ejection</s></div>Apple