注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

User:Apple/projects/ISOMetro

From Funtoo
Jump to navigation Jump to search

Abstract

Funtoo needs to be able to create bootable media.

Needs? We seem to be doing fine without our own branded media.


Anyway, it shouldn't be hard to add ISO/image generation to Metro.

I should say I get really confuzed when figuring out bootloader->kernel->init, so this might get messy.


The following is some pseudosteps which I think would create an ISO.

  1. Create a stage4, but instead of tar compression, use squashfs.
    • From brief exploration, it seems targets/gentoo/stage/capture will be the place to edit.
  2. Make an kernel w/ genkernel; should be able to handle squashfs.
    • If not with genkernel, get a generic kernel (monolithic or modular), make initramfs with better-initramfs.
  3. Prepare isolinux.
    • ISOLINUX's documentation is a little arcane, and I have no idea how gentoo's livedvd handles EFI.
  4. ...
  5. Profit!

LiveCD/DVD Generation

Squashfs compression in Metro

Taking a look at etc/builds/funtoo/build.conf, there is no reference to what type to capture (see targets/gentoo/stage/capture/). I have no idea where to specify ami (and therefore any other capture method).

Metro would need to create a stage4, then use that as a seed for an ISO (or, shall we do something completely different?).

Update 1

Metro comes bundled with a stage4 target. The stage4 collects targets/gentoo/stage/capture/tar.spec; some quick edits later it should be squashfs-compressed.

Template:Info

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.

Template:Root

Update 2

Apart from fine-tuning init (and pruning), this is pretty much done.

Init

Autodetection, MOTD, autologin all need to be done (currently it boots into a regular login which hasn't been setup).

Waiting for Funtoo Startup to get written.

Update 3

Autologin works (not like gentoo livecd, but it drops to a root shell which is what we want). Autodetection goes under OpenRC tweaking.

Bootable kernel

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 /lib/modules.

I seem to remember a gentooor maybe it was ubuntu... livecd with grub. How?

Update 1

With "stage5", we actually have the kernel and modules inside the squashfs (so no problem there); the problem is now we need it _outside_...

Probably not a major problem. unsquashfs can selectively extract any necessaries from it.

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.

Update 2

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 steps/capture, but that might be able to do it at some point after.

isolinux and its config are pretty static on an arch, but I would like to see a dynamic way of creating them.

Other than that, just some init (loads of openrc errors) tweaking.

Update 3

I'm using cdupdate.sh to apply a workaround for init/openrc.

Just tweaking left.

LiveUSB

Now, this is slightly easier yet more difficult. A liveUSB image should be the product of: Template:Root

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 dd off many images (I suspect it would be several hours per image).

Mounting an empty image via loop and writing to it doesn't work AFAIK: Template:Root

LVM

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.

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).

To install it, just dd the lvm to the hdd (as long as the hdd has the capacity to hold the lvm image).

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.

Update 1

Unix's "everything is a file" falls down here (just saying).

Update 2

isolinux's documentation mentions isohybrid, which can make the the same livecd also bootable from keys.

Two updates down, I haven't looked at this yet (LiveCD first).

References

http://edoceo.com/liber/gentoo-live-usb - Unfortunately, in this case, pretty much all of the work has already been done by catalyst.

http://muzso.hu/2009/07/28/how-to-resize-an-lvm-physical-volume-without-a-reboot

Current Issues

Read-only file system

The live CD environment is completely read-only, which is a problem most of the time but very inconvenient if you download a stage without preparing a hard disk (or tmpfs) first.

Until a suitable workaround is found and implemented, please try the following.

Workaround 1

Prepare a temporary directory in ram: Template:Root

Workaround 2

Prepare your hard disk on /mnt/gentoo and download it there: Template:Root

Workaround 3

Pipe wget into tar: Template:Root

Usage

Template:Info

The following block only needs to be run once, the first time you use metro. Template:Root

Template:Root

Testing checklist

Due to the complexity, many things are likely to go wrong. Potential testers should be asked to nohup or tee their output for debugging.

  • stage 1, 2 and 3 should be exactly like using the original funtoo/~funtoo build targets.
  • stage 4 is a stage 3 with some extra packages (no configuration).
  • stage 5 is the complex step
    • 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.
    • Then, it takes the squashfs image and wraps an ISO around it.
      1. ISO 9660 boot code binary data (7zip hides this in [BOOT])
      2. kernel, initramfs etc
      3. isolinux config
      4. cdupdate.sh
      5. /livecd marker
      6. memtest
      7. extra files
      8. Volume ID (disabled for now)
      9. Hybrid booting
      10. GPG signature
  • Booting
    1. Main kernel
    2. Memtest kernel
    3. Hardware detection
    4. Media discovery
    5. unionfs (kernel support included, disabled by default)
    6. cdupdate.sh (before openrc init)
    7. OpenRC
    8. fstab
    9. Autologin
  • Main sequence
    1. Packages
      • git
      • dhcpcd, wireless, ppp/pptp
      • portage
      • filesystem utils
      • luks, dmraid, lvm
      • gcc (etc.)
    2. Installation
      • Downloading a stage tarball to the live environment.
      • (Downloading a portage tree in the live environment.)
      • (# ROOT=/mnt/gentoo emerge -e system)
    3. Shutdown
      1. LiveCD unmount
      2. Ejection