PG1X WIKI

My Knowledge Base

User Tools

Site Tools


tech:server:linux:ubuntu:install-ubuntu-server-18.04-lts:install-ubuntu-server-18.04-lts

Install Ubuntu Server 18.04 LTS

Install Dependent Packages

sudo apt -y install syslinux mtools mbr genisoimage dvd+rw-tools

Create Working Directories

mkdir -p /var/tmp/ubuntu/{dvd-from,dvd-to}
cd /var/tmp/ubuntu/

sudo mount -t iso9660 -o loop,ro /var/tmp/ubuntu-18.04-server-amd64.iso /var/tmp/ubuntu/dvd-from

cd /var/tmp/ubuntu/dvd-from
time find . ! -type l | cpio -pdum ../dvd-to/

ls /var/tmp/ubuntu/dvd-to -F

cd /var/tmp/ubuntu

/var/tmp/ubuntu/dvd-to/isolinux/isolinux.cfg

SYSLINUX - Syslinux Wiki

default install
prompt 0
timeout 150
label install
  menu label ^Install Ubuntu Server
  kernel /install/vmlinuz
  append DEBCONF_DEBUG=5 auto=true locale=en_US.UTF-8 console-setup/charmap=UTF-8 console-setup/layoutcode=us console-setup/ask_detect=false pkgsel/language-pack-patterns=pkgsel/install-language-support=false interface=ens33 hostname=localhost domain=localdomain url=http://192.168.10.21:8080/preseed/openstack-queens/controller.cfg vga=normal initrd=/install/initrd.gz quiet --
label hd
  menu label ^Boot from first hard disk
  localboot 0x80
cd /var/tmp/ubuntu
time sudo genisoimage -N -J -R -D -V "PRESEED" -o ubuntu-18.04-server-amd64-preseed-over-http-cfg.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table dvd-to

prescript.sh

#!/bin/sh
killall.sh; netcfg

preseed.cfg

#===========================================================================================
# BOOT SEQUENCE CONFIGURATIONS START
# ENDの設定のところまではDVDメディア、USBメディアに同梱している場合にのみ有効になる設定。
# PXEブートの場合はこのセクションは無視される。
# この場合はpxelinuxのconfigのappendに直接記述する必要がある。
#===========================================================================================
d-i debian-installer/language string en
d-i debian-installer/country string US
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/supported-locales en_US.UTF-8
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
d-i console-setup/charmap select UTF-8

# キーボードレイアウトの特性の設定(日本語キーボード)
d-i keyboard-configuration/layoutcode string jp
d-i keyboard-configuration/modelcode jp106

#===========================================================================================
# ネットワークまわりの設定
#-------------------------------------------------------------------------------------------
# 静的IP
#-------------------------------------------------------------------------------------------
# preseed.cfgを外から持ってこようとするとどうしてもいったんDHCP解決しないといけない。
# そして以下の netcfg 項目は一回目は無視されるので d-i preseed/run のところで
# ネットワーク設定をリセットするハックが必要になる。
# そうすると静的IPとして設定を直してくれるようになる。
#
# 詳しくは以下:
# - https://help.ubuntu.com/lts/installation-guide/i386/preseed-contents.html
# - http://debian.2.n7.nabble.com/Bug-688273-Preseed-netcfg-use-autoconfig-and-netcfg-disable-dhcp-doesn-t-work-td1910023.html
#
# 以下の2項目を設定しないと静的IPとして処理されないので重要
d-i netcfg/use_autoconfig boolean false 
d-i netcfg/disable_autoconfig boolean true 

d-i netcfg/choose_interface select ens33 
d-i netcfg/disable_dhcp boolean true 
d-i netcfg/get_nameservers string 8.8.8.8 8.8.4.4 1.1.1.1 
d-i netcfg/get_ipaddress string 192.168.1.201 
d-i netcfg/get_netmask string 255.255.255.0 
d-i netcfg/get_gateway string 192.168.1.1 
d-i netcfg/confirm_static boolean true 
d-i netcfg/get_hostname string stack01 
d-i netcfg/get_domain string example.com 
d-i netcfg/wireless_wep string 
#-------------------------------------------------------------------------------------------
# DHCPのとき
#-------------------------------------------------------------------------------------------
#d-i netcfg/choose_interface select ens33 
#d-i netcfg/disable_autoconfig boolean false
#d-i netcfg/get_hostname string openstack 
#d-i netcfg/get_domain string sv.example.com 
#d-i netcfg/wireless_wep string 

# いったんリセット
d-i preseed/run string http://192.168.10.21:8080/preseed/prescript.sh
#===========================================================================================
# BOOT SEQUENCE CONFIGURATIONS END
#===========================================================================================

# インストーラパッケージをダウンロードするミラーを選択する
#d-i mirror/protocol http
d-i mirror/country string manual
d-i mirror/http/hostname string jp.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu/
d-i mirror/http/proxy string

# インストールするスイートを選択
#d-i mirror/suite xenial
d-i mirror/suite bionic

d-i clock-setup/utc boolean false 
d-i time/zone string Japan 
d-i clock-setup/ntp boolean false 

#===========================================================================================
# PARTMAN PARTITIONING SECTION START
#===========================================================================================
# すべてのRAIDデバイス構成を破棄する
d-i partman-md/device_remove_md boolean true
# すべてのLVMデバイス構成を破棄する
d-i partman-lvm/device_remove_lvm boolean true

d-i partman/confirm_nooverwrite boolean true

d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular

# Partition Design
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Disk size: 80GiB
#---------------------------------------------------------------
# Mount Point           Min Size           Max Size
#---------------------------------------------------------------
# /boot                     1GiB               1GiB
# /                        50GiB       unlimited
# swap                     32GiB              32GiB
#---------------------------------------------------------------
# <limits>::=<minimal size>_<priority>_<maximal size>_<parted fs>
#
d-i partman-auto/expert_recipe string      \
           root ::                         \
             1024 10 1024 ext2             \
                $primary{ }                \
                $bootable{ }               \
                format{ }                  \
                use_filesystem{ }          \
                filesystem{ ext2 }         \
                mountpoint{ /boot }        \
             .                             \
             51200 30 -1 ext4              \
                $primary{ }                \
                method{ format }           \
                format{ }                  \
                use_filesystem{ }          \
                filesystem{ ext4 }         \
                mountpoint{ / }            \
             .                             \
             4000 20 4000 linux-swap     \
                $primary{ }                \
                method{ swap }             \
                format{ }                  \
            .                              

d-i partman-auto/choose_recipe select root
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select Finish partitioning and write changes to disk
d-i partman/confirm boolean true
#===========================================================================================
# PARTMAN PARTITIONING SECTION END
#===========================================================================================

d-i base-installer/install-recommends boolean true 
d-i base-installer/kernel/image string linux-generic 

d-i passwd/root-login boolean true 
d-i passwd/make-user boolean false 
d-i passwd/root-password password password 
d-i passwd/root-password-again password password 
d-i passwd/user-fullname string testuser 
d-i passwd/username string testuser 
d-i passwd/user-password password insecure 
d-i passwd/user-password-again password insecure 
d-i user-setup/allow-password-weak boolean true 
d-i user-setup/encrypt-home boolean false 

d-i apt-setup/use_mirror boolean true 

d-i debian-installer/allow_unauthenticated boolean true 
tasksel tasksel/first multiselect none 
# select additional install packages
d-i pkgsel/include string openssh-server \
                          build-essential \
                          vim tmux
d-i pkgsel/upgrade select none 
d-i pkgsel/update-policy select none 
d-i pkgsel/install-language-support boolean true 
popularity-contest popularity-contest/participate boolean false 
d-i pkgsel/updatedb boolean true 

# GRUBインストーラー
d-i grub-installer/grub2_instead_of_grub_legacy boolean true 
d-i grub-installer/only_debian boolean true 
d-i grub-installer/bootdev string /dev/sda

# インストールが終了したらサーバー再起動
d-i finish-install/reboot_in_progress note
% sudo apt -y install whois

% mkpasswd -m sha-512
Password: foobarblah
$6$32b4yZWXb6zgTb$RxIcuUYzYRMMHrq7jOCGTDQiVLoYxVbsiW2vgwb1GBrVo.0PAs/2bUM7wAWdBTaU9mQzri/YqEYvIuNXl6Gxv1

ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBNIviQj85GjH2SShQKy5VY67aAnNWBhtpvmaALyeJuDkuzWKn/roTj90k/yMJLrDlwSFBBgepiOB21wZEL3j03DccKVCVnyVrLVPUGYaU5d9gQroMPT5pcjlZJgqtmV+Kg== wnoguchi-lsathope-win-desk

nick@controller:~$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      addresses: [ 192.168.200.195/24 ]
      gateway4: 192.168.200.2
      nameservers:
          search: [ example.com ]
          addresses:
              - "8.8.8.8"
              - "8.8.4.4"
              - "1.1.1.1"
#!/bin/bash

mkdir /home/nick/.ssh
cat <<EOF >/home/nick/.ssh/authorized_keys
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBNIviQj85GjH2SShQKy5VY67aAnNWBhtpvmaALyeJuDkuzWKn/roTj90k/yMJLrDlwSFBBgepiOB21wZEL3j03DccKVCVnyVrLVPUGYaU5d9gQroMPT5pcjlZJgqtmV+Kg== wnoguchi-lsathope-win-desk
EOF
chmod 700 /home/nick/.ssh
chmod 600 /home/nick/.ssh/authorized_keys
chown -R nick:nick /home/nick/.ssh

cat <<EOF >/etc/sudoers.d/nick
nick ALL=(ALL) NOPASSWD:ALL
EOF
chmod 400 /etc/sudoers.d/nick
tech/server/linux/ubuntu/install-ubuntu-server-18.04-lts/install-ubuntu-server-18.04-lts.txt · Last modified: 2018/05/09 07:13 by wnoguchi