Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: extend compatibility to Ubuntu server image #3

Open
tachang opened this issue May 18, 2018 · 12 comments
Open

Feature request: extend compatibility to Ubuntu server image #3

tachang opened this issue May 18, 2018 · 12 comments
Assignees

Comments

@tachang
Copy link

tachang commented May 18, 2018

It works with netboot.iso perfectly thank you!

I tried to replace netboot.iso with ubuntu-18.04-server-amd64.iso but ran into two issues so far.

  1. The patching doesn't seem to work
  2. cat: /tmp/tmp.oEoTzfiQlV/initrd.gz: No such file or directory

Not sure what is going on.

@coreprocess
Copy link
Owner

coreprocess commented May 18, 2018

@tachang Sadly the structure of ubuntu-18.04-server-amd64.iso is not the same. The preseed file itself might work (not tested), but the scripts generating the ISO are not compatible at the moment. I will have a look and get back to you.

@coreprocess coreprocess changed the title Trying to get it to work with ubuntu-18.04-server-amd64.iso Feature request: extend compatibility to ubuntu-18.04-server-amd64.iso image May 18, 2018
@coreprocess coreprocess self-assigned this May 18, 2018
@coreprocess coreprocess changed the title Feature request: extend compatibility to ubuntu-18.04-server-amd64.iso image Feature request: extend compatibility to Ubuntu server image May 18, 2018
@tachang
Copy link
Author

tachang commented May 18, 2018

I'm also looking as well. I just want to speed things up a bit (I guess next thing to look at is hosting the packages locally). It would be really nice though to have them in the iso already.

Thanks so much!

@coreprocess
Copy link
Owner

@tachang I adjusted the script. It works fine. See the ubuntu/18.04/build-iso-server-image.sh script which is part of the feature/ubuntu-server-image branch.

# clone branch feature/ubuntu-server-image
git clone -b feature/ubuntu-server-image https://github.com/core-process/linux-unattended-installation.git

# build iso based on server image
./linux-unattended-installation/ubuntu/18.04/build-iso-server-image.sh

We do not need to apply the patch for the boot menu, because the server image has a boot timeout of 30 seconds by default. Do not be confused by the language selection dialog of the boot manager. The countdown gets triggered anyway.

Here you can see the differences between the build-iso.sh and the build-iso-server-image.sh script formatted as patch file:

--- ./linux-unattended-installation/ubuntu/18.04/build-iso.sh
+++ ./linux-unattended-installation/ubuntu/18.04/build-iso-server-image.sh
@@ -3,7 +3,7 @@
 
 # get parameters
 SSH_PUBLIC_KEY_FILE=${1:-"$HOME/.ssh/id_rsa.pub"}
-TARGET_ISO=${2:-"`pwd`/ubuntu-18.04-netboot-amd64-unattended.iso"}
+TARGET_ISO=${2:-"`pwd`/ubuntu-18.04-server-amd64-unattended.iso"}
 
 # check if ssh key exists
 if [ ! -f "$SSH_PUBLIC_KEY_FILE" ];
@@ -19,15 +19,11 @@
 TMP_DISC_DIR="`mktemp -d`"
 TMP_INITRD_DIR="`mktemp -d`"
 
-# download and extract netboot iso
-SOURCE_ISO_URL="http://archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/mini.iso"
+# download and extract server iso
+SOURCE_ISO_URL="http://cdimage.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-amd64.iso"
 cd "$TMP_DOWNLOAD_DIR"
-wget -4 "$SOURCE_ISO_URL" -O "./netboot.iso"
-7z x "./netboot.iso" "-o$TMP_DISC_DIR"
-
-# patch boot menu
-cd "$TMP_DISC_DIR"
-patch -p1 -i "$SCRIPT_DIR/custom/boot-menu.patch"
+wget -4 "$SOURCE_ISO_URL" -O "./server.iso"
+7z x "./server.iso" "-o$TMP_DISC_DIR"
 
 # prepare assets
 cd "$TMP_INITRD_DIR"
@@ -38,15 +34,15 @@
 
 # append assets to initrd image
 cd "$TMP_INITRD_DIR"
-cat "$TMP_DISC_DIR/initrd.gz" | gzip -d > "./initrd"
+cat "$TMP_DISC_DIR/install/initrd.gz" | gzip -d > "./initrd"
 echo "./preseed.cfg" | fakeroot cpio -o -H newc -A -F "./initrd"
 find "./custom" | fakeroot cpio -o -H newc -A -F "./initrd"
-cat "./initrd" | gzip -9c > "$TMP_DISC_DIR/initrd.gz"
+cat "./initrd" | gzip -9c > "$TMP_DISC_DIR/install/initrd.gz"
 
 # build iso
 cd "$TMP_DISC_DIR"
 rm -r '[BOOT]'
-mkisofs -r -V "ubuntu 18.04 netboot unattended" -cache-inodes -J -l -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -input-charset utf-8 -o "$TARGET_ISO" ./
+mkisofs -r -V "ubuntu 18.04 server unattended" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -input-charset utf-8 -o "$TARGET_ISO" ./
 
 # go back to initial directory
 cd "$CURRENT_DIR"

@tachang
Copy link
Author

tachang commented May 21, 2018

Wow. Trying this out now!

@tachang
Copy link
Author

tachang commented May 21, 2018

Is there a way to reduce the 30s? I assume it would be in the preseed?

@coreprocess
Copy link
Owner

@tachang in that case we need to add a slightly modified boot-menu.patch. The timeout is encoded in the isolinux/isolinux.cfg.

@jms1989
Copy link

jms1989 commented Sep 30, 2018

Quick question, is there any particular reason for building the server image? I find the netboot image works fine for creating servers where I install what I want and nothing more. Is it just to have the included deb packages included in the new image?

@tachang
Copy link
Author

tachang commented Oct 1, 2018

The server image saves bandwidth and gets the OS up and running much faster than having to download things. With the netboot one you if you have a bunch of machines you want to bring up at the same time it can really bring the network to it's knees (depending on how good your network is).

@jms1989
Copy link

jms1989 commented Oct 1, 2018

A proxy cache server can help the netboot image if you're doing a bunch at once, it also ensures you get the latest packages everytime the installer is ran. :)

rjw57 pushed a commit to rjw57/lecture-capture-agent-bootstrap that referenced this issue Nov 29, 2018
@coreprocess
Copy link
Owner

Consider this approach to lookup the newest server iso images: #11

@Meow-ops
Copy link

It would be nice to also extend the hybrid iso functionnality to this branch, I didn't find a way to use xorriso within the build-iso-server-image.sh script

@Meow-ops
Copy link

Meow-ops commented Feb 12, 2019

I managed to get xorriso working with the server image I had with those following commands added to the script

# create the mbr binary from the downloaded iso
sudo dd if=ubuntu-18.04.1-server-amd64.iso bs=512 count=1 of=custom_isohdpfx.bin
# use xorriso to create the iso
xorriso -as mkisofs -r -V "ubuntu_1804_netboot_unattended" -J -b isolinux/isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -input-charset utf-8 -isohybrid-mbr "$CURRENT_DIR"/custom_isohdpfx.bin -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -o "$TARGET_ISO" ./

# add the following block the to preseed.cfg file 
### Do NOT install on the USB stick(!)
#
# The Debian installer will install on the first disk it finds which can
# sometimes be the USB stick itself. Work around this by rolling our own auto
# detect logic which disallows installing on USB devices.
d-i partman/early_command string \
  USBDEV_LIST="$(mktemp)"; \
  list-devices usb-partition | sed "s/\(.*\)./\1/" > "$USBDEV_LIST"; \
  BOOTDEV="$(list-devices disk | grep -vf "$USBDEV_LIST" | head -n 1)"; \
  debconf-set partman-auto/disk "$BOOTDEV"; \
  debconf-set grub-installer/bootdev "$BOOTDEV"; \
  while /bin/true; do sleep 0.01; rm -f /target/etc/grub.d/30_os-prober; done &

Hopefully this will be useful for someone who wants to achieve the same goal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants