Ubuntu Server 20.04.1 Autoinstall with USB boot

Summary The Ubuntu PC server in my parents' house went wrong due to a power outage, and I needed to set up the OS again. Since the data is on the NAS, we do not retrieve the data. Since it is difficult to get various things done remotely, I used Autoinstall.

--Start installation with USB boot --The settings are fetched from the local web server, so you don't have to recreate the USB every time you change the settings. --IP address is fixed --Preparation is local Linux ――The work of burning USB is a Windows PC at home

Place user-data and meta-data on your local web server

meta-data is an empty file. The user-data Ethernet I/F is a static IP, not DHCP. If you don't know the I/F name in advance, it feels useless. You may want to set some suggestions and use match. The encrypted-password was created below. I put whois in my local Linux Mint for mkpasswd.

 mkpasswd -m sha-512 <password>

user-data


#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: us
    variant: ''
  identity:
    hostname: <hostname>
    username: <usrname>
    password: "<encrypted-password>"
    realname: <username>
  storage:
    layout:
      name: lvm
  network:
    network:
      version: 2
      ethernets:
        enp1s0:
          addresses:
            - <ip-address>/24
          gateway4: <gw-ip-address>
          nameservers:
            addresses: [<dns-ip-address>]
  ssh:
    install-server: true
    authorized-keys:
      - "ssh-rsa <local-pc-public-key>"
  packages:
    - build-essential
    - net-tools
    - lm-sensors
  user-data:
    timezone: Asia/Tokyo

Create an ISO image on your local Linux Mint

Mount the Ubuntu Server 20.04.1 Live ISO image and copy it to your working folder (iso_root)

sudo mount -o ro,loop ~/Downloads/ubuntu-20.04.1-live-server-amd64.iso /cdrom/
mkdir iso_root
cd iso_root/
sudo rsync -av /cdrom/. .
sudo chown -R $(id -un) .

For UEFI: rewrite boot/grub/grub.cfg

If you use wq! In vi, you can write to it, so you don't need chmod. .. ..

chmod 744 iso_root/boot/grub/grub.cfg
vi iso_root/boot/grub/grub.cfg
chmod 444 iso_root/boot/grub/grub.cfg

There are user-data and meta-data under http: // \ <web-server-ip >/path/to /. If you start USB on the wrong PC, you will be in trouble, so autoinstall is prevented from running automatically with timeout = -1. It seems that it will be cut off with a semicolon, so the command options are enclosed in ".

diff -u /cdrom/boot/grub/grub.cfg iso_root/boot/grub/grub.cfg 
--- /cdrom/boot/grub/grub.cfg	2020-08-01 03:35:16.000000000 +1000
+++ iso_root/boot/grub/grub.cfg	2021-01-16 20:49:10.272872571 +1100
@@ -10,7 +10,12 @@
 set menu_color_normal=white/black
 set menu_color_highlight=black/light-gray
 
-set timeout=5
+set timeout=-1
+menuentry "Auto Install Ubuntu Server" {
+	set gfxpayload=keep
+	linux	/casper/vmlinuz   autoinstall "ds=nocloud-net;s=http://<web-server-ip>/path/to/" quiet  ---
+	initrd	/casper/initrd
+}
 menuentry "Install Ubuntu Server" {
 	set gfxpayload=keep
 	linux	/casper/vmlinuz   quiet  ---

For MBR: Rewrite isolinux/txt.cfg

If you use wq! In vi, you can write to it, so you don't need chmod. .. ..

chmod 744 iso_root/isolinux/txt.cfg 
vi iso_root/isolinux/txt.cfg 
chmod 444 iso_root/isolinux/txt.cfg

There are user-data and meta-data under http: // \ <web-server-ip >/path/to /. Again, I wanted to prevent Autoinstall from running automatically because it would be a problem if I booted the USB on the wrong PC, but as shown below, auto-install runs automatically even if it is set to default live. It will end up. By default, the menu is not displayed and the first label is executed without permission? .. .. For the time being, I removed autoinstall from the command options, so "label auto-install" will run automatically, but just before I try to autoinstall, I'll be asked a Yes/No question.

diff -u /cdrom/isolinux/txt.cfg iso_root/isolinux/txt.cfg 
--- /cdrom/isolinux/txt.cfg	2020-08-01 03:35:16.000000000 +1000
+++ iso_root/isolinux/txt.cfg	2021-01-17 18:16:50.052299812 +1100
@@ -1,4 +1,8 @@
 default live
+label auto-install
+  menu label ^Auto Install Ubuntu Server
+  kernel /casper/vmlinuz
+  append   initrd=/casper/initrd ds=nocloud-net;s=http://<web-server-ip>/path/to/ quiet  ---
 label live
   menu label ^Install Ubuntu Server
   kernel /casper/vmlinuz

Create an ISO image

Install the required packages on your local Linux Mint.

sudo apt install isolinux xorriso

Create an ISO image with the following command.

xorriso -as mkisofs -o u20.04_autoinstall.iso -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
 -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot \
 -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat iso_root

Creating a USB memory for booting

Created using Etcher by remote desktop to a Windows PC in my parents' house.

Autoinstall Have the target PC insert the created USB memory and perform USB Boot. After completing Autoinstall, confirm that you can log in as the user specified in user-data by SSH.

that's all.

bonus

For the time being, install Docker/Docker-compose using local Ansible. https://github.com/skwsk/docker_playbook

After this, I will use Ansible to put in everything else I need.

Referenced page

https://ubuntu.com/server/docs/install/autoinstall https://ubuntu.com/server/docs/install/autoinstall-quickstart https://ubuntu.com/server/docs/install/autoinstall-reference https://netplan.io/reference/ https://wiki.syslinux.org/wiki/index.php?title=Isohybrid https://qiita.com/sakai00kou/items/7ce4a8a410251b98b2ac https://qiita.com/YasuhiroABE/items/637f1046a15938f9d3e9

Recommended Posts

Ubuntu Server 20.04.1 Autoinstall with USB boot
Build Ubuntu 18.04.5 with dual boot
Prepare a LEMP Ubuntu 18 server with Ansible Galaxy
Create Spring Cloud Config Server with security with Spring Boot 2.0
raspberry pi 4: Both Raspberry Pi OS and ubuntu boot with just a USB hard disk
Server construction procedure Ubuntu18.04 server
Install Gradle with ubuntu16.04
Download with Spring Boot
Wifi adapter not recognized on Ubuntu with Windows dual boot
Generate barcode with Spring Boot
Hello World with Spring Boot
Build VNC Server on Ubuntu 20.04
Implement GraphQL with Spring Boot
Install Docker on Ubuntu Server 20.04
Get started with Spring boot
Hello World with Spring Boot!
Update gitlab-runner with Ubuntu automatic update
File upload with Spring Boot
Spring Boot starting with copy
Spring Boot starting with Docker
Hello World with Spring Boot
Set cookies with Spring Boot
Use Spring JDBC with Spring Boot
Add module with Spring Boot
Getting Started with Spring Boot
Install Ubuntu Server 20.04 on Btrfs
Create microservices with Spring Boot
Send email with spring boot
Creating a dual boot environment for Ubuntu Server 20.04.1 LTS and Windows 10
Install Ubuntu Server 20.04 in VirtualBox on Mac and connect with SSH