CentOS/Ubuntu production automatic installation iso practice

First, the purpose

The human-computer interaction process in the operating system installation process is reduced, and the installation of the operating system can be automatically completed without any other human-computer interaction process after the CD-ROM is selected for installation.

2. Environment and software tools

Environment: Linux Ubuntu/CentOS operating system (other distributions have not been tried)

Software: mkisofs, xorriso

Software Installation:

CentOS : yum install mkisofs xorriso -y

Ubuntu: sudo apt install -y mkisofs xorriso

Three, iso repackaging

1.Ubuntu

1.1 Raw materials

I used ubuntu-16.04.3-server-arm64.iso to mount it and make a copy. If there is an existing compilation environment, it is also possible.

$ mkdir mnt/ ubuntu/
$ ls -al
  mnt /
ubuntu/
ubuntu-16.04.3-server-arm64.iso
$ sudo mount ubuntu-16.04.3-server-arm64.iso mnt/
$ cp -rf ./mnt/* ./mnt/.disk/ ./ubuntu/
$ sudo umount ./mnt/

1.2 Modify / add configuration files

1.2.1.boot/grub/grub.cfg

$ vim ubuntu/boot/grub/grub.cfg
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
set timeout=60
insmod gzio
menuentry 'Install Ubuntu' {
    set background_color=black
    linux    /install/vmlinuz auto-install/enable=true file=/cdrom/preseed/ubuntu.seed
    initrd   /install/initrd.gz
}

(1) set timeout=60 ##Set 60 seconds without response and automatically select the default item

(2) auto-install/enable=true ##Allow automatic installation mode

(3) file=/cdrom/preseed/ubuntu.seed ##Specify the automatically installed preseed file.

(4) If you want to combine the normally issued iso and the one that can be automatically installed into one, you can add other menu items, but make sure that the above configuration is the default item, and configure the timeout operation.

1.2.2.preseed文件preseed/ubuntu.seed

 
 

$ vim ubuntu/preseed/ubuntu.seed

#########################################################################

## CDROM auto install

#########################################################################

# Continue install on "no kernel modules were found for this kernel"

#d-i anna/no_kernel_modules boolean true

 

d-i auto-install/enable boolean true

## Set country, language and keyboard map

d-i debian-installer/language string en

d-i debian-installer/country string US

d-i debain-install/locale string en_US.UTF-8

# Optionally specify additional locales to be generated.

#d-i localechooser/supported-locales multiselect zh_CH.UTF-8, C.UTF-8, en_US.UTF-8

 

#d-i keyboard-configuration/xkb-keymap select us

## Disable automatic (interactive) keymap detection.

d-i console-setup/ask_detect boolean false

d-i keyboard-configuration/layoutcode string us

## To select a variant of the selected layout (if you leave this out, the

## basic form of the layout will be used):

#d-i keyboard-configuration/variantcode string dvorak

 

##net config

d-i netcfg/choose_interface select auto

d-i netcfg/get_hostname string unassigned-hostname

d-i netcfg/get_domain string unassigned-domain

 

## set root password

d-i passwd/root-login boolean root

d-i passwd/root-password password root

d-i passwd/root-password-again password root

d-i user-setup/allow-password-weak boolean true

 

## creat user

d-i passwd/make-user boolean true

d-i passwd/user-fullname string User

d-i passwd/username string user

d-i passwd/user-password-crypted password userpassword

d-i passwd/user-password-again password userpassword

## Encrypt your home directory NO

d-i user-setup/encrypt-home boolean false

 

## Controls whether or not the hardware clock is set to UTC.

d-i clock-setup/utc boolean true

d-i time/zone string Asia/Shanghai

 

## Disk usage

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

#d-i partman-auto/method string lvm

#d-i partman-auto-lvm/guided_size string max

d-i partman-auto/method string regular

d-i partman-lvm/device_remove_lvm boolean true

d-i partman-md/device_remove_md boolean true

d-i partman-lvm/confirm boolean true

d-i partman-lvm/confirm_nooverwrite boolean true

d-i partman-auto/choose_recipe select atomic

d-i partman-partitioning/confirm_write_new_label boolean true

d-i partman/choose_partition select finish

d-i partman/confirm boolean true

d-i partman/confirm_nooverwrite boolean true

 

## umount /dev/sda

d-i partman/unmount_active boolean true

d-i preseed/early_command string umount /media || true

 

#set mirror CD installation does not require setting: mirror

#d-i mirror/country string manual

#d-i mirror/http/hostname string ports.ubuntu.com

#d-i mirror/http/directory string /ubuntu-ports/

#d-i mirror/http/proxy string

#d-i mirror/http/mirror select 192.168.50.122:8083

#d-i mirror/http/mirror select 192.168.1.107:80

 

## apt-setup

#d-i apt-setup/non-free boolean true

#d-i apt-setup/contrib boolean true

d-i apt-setup/use_mirror boolean false

d-i apt-setup/restricted boolean true

d-i apt-setup/universe boolean true

d-i apt-setup/backports boolean true

d-i apt-setup/services-select multiselect security

d-i apt-setup/security_host string security.ubuntu.com

d-i apt-setup/security_path string /ubuntu

d-i pkgsel/update-policy select none

 

##install software

tasksel tasksel/first multiselect standard

## Individual additional packages to install

d-i pkgsel/include string openssh-server vim 

d-i pkgsel/upgrade select none

popularity-contest popularity-contest/participate boolean false

 

##Grub and bootloder

## This is fairly safe to set, it makes grub install automatically to the MBR

## if no other operating system is detected on the machine.

d-i grub-installer/only_debian boolean true

d-i grub-installer/with_other_os boolean true

 

## Avoid that last message about the install being complete.

d-i finish-install/keep-consoles boolean true

d-i finish-install/reboot_in_progress note

d-i cdrom-detect/eject boolean false

1.3 Repackage iso

$ sudo xorriso -as mkisofs -r -checksum_algorithm_iso md5,sha1 -V 'Ubuntu-Server 16.04.3 LTS arm64' \
-o ./new-ubuntu-16.04.3-server-arm64.iso -J -joliet-long -cache-inodes -e boot/grub/efi.img \
-no-emul-boot -append_partition 2 0xef ubuntu/boot/grub/efi.img  -partition_cyl_align all ubuntu/


The generated iso is in the current directory.

2.CentOS

2.1 Raw materials

I used CentOS-7-aarch64-Everything.iso to mount it and make a copy. If there is a ready-made compilation environment, it is also possible. (using CentOS7.4-1708-ARM server version iso)

$ mkdir mnt/ centos/
$ ls -al
cents/
mnt /
CentOS-7-aarch64-Everything.iso
$ sudo mount CentOS-7-aarch64-Everything.iso mnt/
$ sudo cp -rf mnt/* mnt/.discinfo mnt/.treeinfo centos/
$ sudo umount ./mnt/

2.2 Modify/add configuration files

2.2.1grub menu EFI/BOOT/grub.cfg modify the default item content:

$ vim centos/EFI/BOOT/grub.cfg
set timeout=60
### END /etc/grub.d/00_header ###

search --no-floppy --set=root -l 'CentOS 7 aarch64'

### BEGIN /etc/grub.d/10_linux ###
menuentry 'install CentOS Linux AltArch 7' --class red --class gnu-linux --class gnu --class os {
	linux /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20aarch64 ip=dhcp acpi=force inst.ks=cdrom:/ks-iso.cfg
	initrd /images/pxeboot/initrd.img
}

(1) inst.stage2=hd:LABEL=CentOS\x207\x20aarch64 ##The parent directory location of the second execution space LiveOS.

(2) inst.ks=file:/ks-iso.cfg ##The path of the kickstart file used for automatic installation.

(3) The setting of acpi depends on the specific device, and some may need to be set to off

2.2.2.kickstart file

$ vim centos/ks-iso.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=''
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network  --bootproto=dhcp --device=eth1 --onboot=off --ipv6=auto
network  --bootproto=dhcp --device=eth2 --onboot=off --ipv6=auto
network  --bootproto=dhcp --device=eth3 --onboot=off --ipv6=auto
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$Kd3yxUtwpOk3fJ.M$KnTt/6pHJzXWYcKGQbqqkifavlMLrQcuOd6OAud97qD2IbFcWGtljsRVo9qWSSHj0Mcy.HmyLZ0JsDlq8mQ7B/
# System services
services --enabled="chronyd"
# Do not configure the X Window System
skipx
# System timezone
timezone US/Alaska --isUtc
user --groups=user,wheel --name=user --password=$6$aBUT2gAUGjmQEeKF$.y8qtYgDX0gZZyiAVbBwlCfsNgPUykgP9HP82vzAcRJMz2E0ynnHpthBaSVlJWk0a8EmUZJDD6marUZhH7mkG1 --iscrypted --gecos="user"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda
reboot

%post
#Operations after installation is complete
%end

%packages
#Required packages to be installed
%end

The above automatic installation configuration is only a solution.

2.3 Repackage iso

$ cd cents/

$ sudo genisoimage -e images/efiboot.img -no-emul-boot -T -J -R -c boot.catalog -hide boot.catalog -V "CentOS 7 aarch64"\
-o ../CentOS-7-aarch64-Everything.iso .









Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325810896&siteId=291194637