public inbox for discuss@lists.illumos.org (since 2011-08)
 help / color / mirror / Atom feed
* Re: [discuss] Pureboot-like scripts
       [not found] <17497509050.6B12f.27632@composer.illumos.topicbox.com>
@ 2025-06-15 20:50 ` Peter Tribble
  0 siblings, 0 replies; only message in thread
From: Peter Tribble @ 2025-06-15 20:50 UTC (permalink / raw)
  To: illumos-discuss

[-- Attachment #1: Type: text/plain, Size: 6540 bytes --]

On Thu, Jun 12, 2025 at 6:57 PM jalil.hessane via illumos-discuss <
discuss@lists.illumos.org> wrote:

> Hi,
> I wanted to make a small image out of the proto directory built from
> illumos-gate, heavily inspired by pureboot (
> https://ptribble.blogspot.com/2015/09/illumos-pureboot.html).
>

That version of pureboot is getting on a bit. The current (sort of
maintained) version
of that is the mvi.sh script in the mvi repo

https://github.com/ptribble/mvi

(Specifically, look down to the ${DESTDIR}/boot/conf.d/livemedia piece, at
a guess.)



> I made two (not working) scripts, the first one boots and give this output
> while doing so:
>
> Loading unix...
> Loading /platform/i86pc/amd64/boot_archive...
> Loading /platform/i86pc/amd64/boot_archive.hash...
> Booting...
> No rootfs module provided, aborting
>
> Hit [Enter] to boot immediately, or any other key command prompt.
> Booting [/platform/i86pc/kernel/amd64/unix]
> warning: 'environment' is already loaded
> warning: 'console-font' is already loaded
> No rootfs module provided, aborting
>
>
> The second script uses bootadm to create the boot_archive, but it doesn't
> go past bootadm:
>
> Creating boot_archive for /var/tmp/purebuild.19661
> svccfg: Pattern 'system/boot-archive' doesn't match any instances or services
> updating /var/tmp/purebuild.19661/platform/i86pc/amd64/boot_archive (UFS)
>
> gzip: stdout: No space left on device
> [A lot of gzip errors]
> gzip: stdout: No space left on device
>
> gzip: stdout: No space left on device
> GNU xorriso 1.5.6.pl02 : RockRidge filesystem manipulator, libburnia project.
>
> Drive current: -outdev 'stdio:/dev/fd/1'
> Media current: stdio file, sequential
> Media status : is blank
> Media summary: 0 sessions, 0 data blocks, 0 data, 4096g free
> xorriso : FAILURE : Cannot determine attributes of source file '/var/tmp/purebuild.19661/       ' : No such file or directory
> xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE'
>
>
> First script:
>
> #!/bin/bash
> set -e
>
> # === CONFIGURATION ===
> PROTO_DIR=/xor/illumos-gate/proto/root_i386
> ISO_NAME=/var/tmp/illumos-loader.iso
> DESTDIR=/tmp/purebuild.$$
> MRSIZE=1024M
> NBPI=4096
>
> # === SETUP ===
> mkdir -p "$DESTDIR"
> cd "$PROTO_DIR"
> tar cf - . | ( cd "$DESTDIR" && tar xf - )
>
> # === INIT SETUP ===
> cat > "$DESTDIR/etc/pureboot.rc" <<EOF
> #!/sbin/sh
> echo " *** illumos boot via loader ***" > /dev/console
> /bin/ksh93 >/dev/console 2>&1 </dev/console
> EOF
> chmod a+x "$DESTDIR/etc/pureboot.rc"
>
> mv "$DESTDIR/etc/inittab" "$DESTDIR/etc/inittab.bak"
> grep -v startd "$DESTDIR/etc/inittab.bak" > "$DESTDIR/etc/inittab"
> echo "smf::sysinit:/etc/pureboot.rc" >> "$DESTDIR/etc/inittab"
>
> # === KERNEL STATE FILES FROM RUNNING SYSTEM ===
> for kfile in driver_classes minor_perm name_to_major driver_aliases; do
>     cp "/etc/$kfile" "$DESTDIR/etc/"
> done
>
> # === CREATE BOOT ARCHIVE ===
> BOOTBLOCK=$(mktemp /var/tmp/bootblock.XXXXXX)
> mkfile $MRSIZE $BOOTBLOCK
> chmod o-t $BOOTBLOCK
> LOFI=$(lofiadm -a $BOOTBLOCK)
> LOFINUM=$(basename $LOFI)
>
> echo "y" | newfs -o space -m 0 -i $NBPI /dev/rlofi/$LOFINUM
>
> MNT=/tmp/nb.$$
> mkdir $MNT
> mount -Fufs -o nologging $LOFI $MNT
> cd "$DESTDIR"
> tar cf - . | pv | ( cd $MNT ; tar xvf - )
> touch "$MNT/reconfigure"
> $DESTDIR/usr/sbin/devfsadm -r $MNT
>
> rm -f $MNT/dev/dsk/* $MNT/dev/rdsk/*
> rm -f $MNT/dev/removable-media/dsk/* $MNT/dev/removable-media/rdsk/*
>
> # === UMOUNT AND ARCHIVE ===
> umount $MNT
> lofiadm -d $LOFI
> pv $BOOTBLOCK | gzip --fast > ${BOOTBLOCK}.gz
> cp ${BOOTBLOCK}.gz "$DESTDIR/platform/i86pc/boot_archive"
> rm ${BOOTBLOCK}.gz
> rmdir $MNT
>
> # === REMOVE EVERYTHING EXCEPT /boot and /platform ===
> cd "$DESTDIR"
> find . -mindepth 1 -maxdepth 1 ! -name boot ! -name platform -exec rm -rf {} +
>
> # === CREATE ISO ===
> xorriso -as mkisofs \
>     -o "$ISO_NAME" \
>     -b boot/cdboot \
>     -no-emul-boot -boot-load-size 4 -boot-info-table \
>     -R -J -V "illumos" "$DESTDIR"
>
>
> echo "[*] ISO built at: $ISO_NAME"
> ls -lh "$ISO_NAME"
>
> # === CLEANUP ===
> rm -rf "$DESTDIR"
>
>
> Second script:
>
> #!/bin/bash
> set -e
>
> # === CONFIGURATION ===
> PROTO_DIR=/xor/illumos-gate/proto/root_i386
> ISO_NAME=/var/tmp/illumos-loader.iso
> DESTDIR=/var/tmp/purebuild.$$
> NBPI=4096
>
> # === SETUP ===
> mkdir -p "$DESTDIR"
> cd "$PROTO_DIR"
> tar cf - . | ( cd "$DESTDIR" && tar xf - )
>
> # === INIT SETUP ===
> cat > "$DESTDIR/etc/pureboot.rc" <<EOF
> #!/sbin/sh
> echo " *** illumos boot  ***" > /dev/console
> /bin/ksh93 >/dev/console 2>&1 </dev/console
> EOF
> chmod a+x "$DESTDIR/etc/pureboot.rc"
>
> mv "$DESTDIR/etc/inittab" "$DESTDIR/etc/inittab.bak"
> grep -v startd "$DESTDIR/etc/inittab.bak" > "$DESTDIR/etc/inittab"
> echo "smf::sysinit:/etc/pureboot.rc" >> "$DESTDIR/etc/inittab"
>
> # === KERNEL STATE FILES FROM RUNNING SYSTEM ===
> for kfile in driver_classes minor_perm name_to_major driver_aliases; do
>     cp "/etc/$kfile" "$DESTDIR/etc/"
> done
>
> # === CREATE BOOT ARCHIVE ===
> $PROTO_DIR/usr/sbin/bootadm update-archive -R "$DESTDIR"
>
> # === REMOVE EVERYTHING EXCEPT /boot and /platform ===
> cd "$DESTDIR"
> find . -mindepth 1 -maxdepth 1 ! -name boot ! -name platform -exec rm -rf {} +
>
> # === CREATE ISO  ===
> xorriso -as mkisofs \
>     -o "$ISO_NAME" \
>     -b boot/cdboot \
>     -no-emul-boot -boot-load-size 4 -boot-info-table \
>     -R -J -V "illumos" "$DESTDIR"
>
> echo "[*] ISO built at: $ISO_NAME"
> ls -lh "$ISO_NAME"
>
> # === CLEANUP ===
> rm -rf "$DESTDIR"
>
>
> It's not really to serve any purpose, just for fun.
> Thanks in advance for any help.
> *illumos <https://illumos.topicbox.com/latest>* / illumos-discuss / see
> discussions <https://illumos.topicbox.com/groups/discuss> + participants
> <https://illumos.topicbox.com/groups/discuss/members> + delivery options
> <https://illumos.topicbox.com/groups/discuss/subscription> Permalink
> <https://illumos.topicbox.com/groups/discuss/Tb104b7199f0b0468-M20f76ef894620f7acb88542a>
>


-- 
-Peter Tribble
http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/

------------------------------------------
illumos: illumos-discuss
Permalink: https://illumos.topicbox.com/groups/discuss/Tb104b7199f0b0468-M222fa0e409abab0d6b4c5ff0
Delivery options: https://illumos.topicbox.com/groups/discuss/subscription

[-- Attachment #2: Type: text/html, Size: 9051 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-06-15 20:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <17497509050.6B12f.27632@composer.illumos.topicbox.com>
2025-06-15 20:50 ` [discuss] Pureboot-like scripts Peter Tribble

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).