mvallim / live-custom-ubuntu-from-scratch

This procedure shows how to create a bootable and installable Ubuntu Live (along with the automatic hardware detection and configuration) from scratch.
https://mvallim.github.io/live-custom-ubuntu-from-scratch/
GNU General Public License v3.0
389 stars 181 forks source link

Add preseed configuration #10

Open adamkrawczyk opened 3 years ago

adamkrawczyk commented 3 years ago

Hi,

It would be great to see here instructions on how to use preseed.cfg file to install image with provided username and password.

Best, Adam

asharrem commented 1 year ago

My solution was in function build_iso() : add after # create diskdefines

  # create preseed
cat <<EOF > image/preseed/nxos.seed
# Users
d-i passwd/user-fullname string MyUser
d-i passwd/username string myuser
d-i passwd/auto-login boolean true
d-i passwd/user-password password Passw0rd1!
d-i passwd/user-password-again password Passw0rd1!

# Custom Commands
# Must show slideshow to avoid installer crash
#
ubiquity ubiquity/success_command string \
  in-target dpkg -i /etc/skel/Downloads/nxwitness-client*.deb; \
  in-target rm /etc/lightdm/lightdm.conf; \
  in-target apt install -y avahi-discover; \
  in-target touch /opt/nxos/new_install;

EOF

and add the preseed path to build_iso() automatic-ubiquity is critcal to the preseed call

function build_iso() {
    echo "=====> running build_iso ..."
    rm -rf image
    mkdir -p image/{casper,isolinux,install,preseed}

    # copy kernel files
    sudo cp chroot/boot/vmlinuz-**-**-generic image/casper/vmlinuz
    sudo cp chroot/boot/initrd.img-**-**-generic image/casper/initrd

    # grub
    touch image/ubuntu
    cat <<EOF > image/isolinux/grub.cfg
search --set=root --file /ubuntu
insmod all_video
set default="0"
set timeout=30
menuentry "${GRUB_INSTALL_LABEL}" {
  linux /casper/vmlinuz file=/cdrom/preseed/nxos.seed boot=casper automatic-ubiquity ---
  initrd /casper/initrd
}
menuentry "${GRUB_LIVEBOOT_LABEL}" {
  linux /casper/vmlinuz file=/cdrom/preseed/nxos.seed boot=casper nopersistent toram ---
  initrd /casper/initrd
}
menuentry "Check disc for defects" {
  linux /casper/vmlinuz boot=casper integrity-check quiet splash ---
  initrd /casper/initrd
}
EOF