openeuler系统定制

自定义kickstart安装修改网卡名为eth

ks文件定制

# Generated by pykickstart v3.34
#version=DEVEL
# Use graphical install
graphical
cdrom

%packages
@Base
@Core
@development
@network-tools
kexec-tools
vim
gcc
gcc-c++
bind-utils
lrzsz
lsof
ftp
traceroute
ncurses-devel
openssl-devel

%end
# Keyboard layouts
keyboard --xlayouts='us'
# System language
lang en_US.UTF-8
bootloader  --append="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0" 
zerombr
# Network information
network  --hostname=localhost.localdomain

# Run the Setup Agent on first boot
firstboot --enable
# System services
services --enabled="chronyd"

# Partition clearing information
%include "/tmp/os_disk"
clearpart --all --initlabel
# Disk partitioning information
%include "/tmp/part_info"
firstboot --disable       
selinux --disabled        
firewall --disabled     
logging --level=info
reboot
# System timezone
timezone Asia/Shanghai --utc

# Root password
rootpw --iscrypted $6$ExeLWpVYD2EXM6Vz$OQTlABFXM2CjJZHP0hMzM.fwUq/szxa7bLZWZOsbYct4uykEV/TMdar9w5qb/yTuMFsuJZqNXQmWfh2XRuYmc0
user --name=manage --password=$6$Iwc7qTYpiOz.Oye.$S22dqS0OtR/teSd8u73W7bgyiLbTOoeJJMHb92feDEq.H5.PrqLPhBevo9kPzIgD6Wi/KKgtodl3RmRNzd7vS/ --iscrypted --gecos="manage"

%addon com_redhat_kdump --disable --reserve-mb='128'

%end

%pre
echo "pre script" |tee /tmp/pre.txt
bash /mnt/install/repo/ks/pre_script.sh |tee -a /tmp/pre.txt
%end

pre_script 脚本

#!/bin/bash
#author:cc
OS_DEV=""
OS_DEV_NAME=""
#获取最小磁盘作为系统盘,大于100G,小于500G
function get_os_disk() 
{
  fdisk -l &>disk.txt
  local disk_os_size=""
  local disk_os_label=""

  if [ $(cat disk.txt |grep 'Disk /dev/' |wc -l) -eq 1 ]
  then
    disk_os_label=$(cat disk.txt |grep 'Disk /dev/' |egrep -o '/dev/sd[a-z]{1,2}')
  else
    for disk_min in $(cat disk.txt |grep 'Disk /dev/' |awk '{print $5}' |sort -un)
    do
      if [[ $disk_min -gt 100022480896 ]] && [[ $disk_min -lt 500592982016 ]]
						  								 
      then
        disk_os_size=$disk_min
        break
      fi
    done
    disk_os_label=$(cat disk.txt |grep $disk_os_size |egrep -o '/dev/sd[a-z]{1,2}' |sort |head -n1)
  fi

  if [ -z "$disk_os_label" ]
  then
    disk_os_label="/dev/sda"
  fi
  export OS_DEV="$disk_os_label"
  echo "$disk_os_label" >/tmp/os_disk.txt\

  local os_disk=$(echo "$OS_DEV" |cut -d '/' -f3)
  export OS_DEV_NAME="$os_disk"
  echo "ignoredisk --only-use=$os_disk" >/tmp/os_disk
}
function std_disk_part()
{
  parted -s "$OS_DEV" mklabel msdos


  cat << EOF >/tmp/part_info
part /boot --fstype="ext4" --ondisk=$OS_DEV_NAME --size=1024
part pv.508 --fstype="lvmpv" --ondisk=$OS_DEV_NAME --size=416776
volgroup openeuler --pesize=4096 pv.508
logvol /opt --fstype="ext4" --size=10240 --name=opt --vgname=openeuler
logvol /zctt --fstype="ext4" --size=102400 --name=zctt --vgname=openeuler
logvol / --fstype="ext4" --size=51200 --name=root --vgname=openeuler
logvol swap --fstype="swap" --size=32768 --name=swap --vgname=openeuler
logvol /usr --fstype="ext4" --size=51200 --name=usr --vgname=openeuler
logvol /ibnms --fstype="ext4" --size=5120 --name=ibnms --vgname=openeuler
logvol /var --fstype="ext4" --size=51200 --name=var --vgname=openeuler
logvol /tmp --fstype="ext4" --size=10240 --name=tmp --vgname=openeuler
logvol /home --fstype="ext4" --size=102400 --name=home --vgname=openeuler
EOF

}
function main(){

get_os_disk
std_disk_part
}

main

修改grub文件,EFI\BOOT\grub.cfg

set default="1"

function load_video {
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_cirrus
  insmod all_video
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=60
### END /etc/grub.d/00_header ###

search --no-floppy --set=root -l 'openEuler-22.03-LTS-SP1-x86_64'

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install openEuler 22.03-LTS-SP1' --class openEuler --class gnu-linux --class gnu --class os {
	linuxefi /images/pxeboot/vmlinuz inst.ks=cdrom:/ks/ks.cfg net.ifnames=0 biosdevname=0   inst.stage2=hd:LABEL=CDROM fpi_to_tail=off
	initrdefi /images/pxeboot/initrd.img
}
menuentry 'Test this media & install openEuler 22.03-LTS-SP1' --class openEuler --class gnu-linux --class gnu --class os {
	linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64 net.ifnames=0 biosdevname=0 rd.live.check fpi_to_tail=off
	initrdefi /images/pxeboot/initrd.img
}
submenu 'Troubleshooting -->' {
	menuentry 'Install openEuler 22.03-LTS-SP1 in basic graphics mode' --class openEuler --class gnu-linux --class gnu --class os {
		linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64 nomodeset fpi_to_tail=off
		initrdefi /images/pxeboot/initrd.img
	}
	menuentry 'Rescue a openEuler system' --class openEuler --class gnu-linux --class gnu --class os {
		linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64 inst.rescue fpi_to_tail=off
		initrdefi /images/pxeboot/initrd.img
	}
}

定制isolinux.cfg

isolinux\isolinux.cfg

default vesamenu.c32
timeout 60

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title openEuler 22.03-LTS-SP1
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.


label linux
  menu label ^Install openEuler 22.03-LTS-SP1
  kernel vmlinuz
  menu default
  append initrd=initrd.img inst.stage2=hd:LABEL=CDROM inst.ks=cdrom:/ks/ks.cfg  biosdevname=0
  #append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-SP1-x86_64 quiet

label local
  menu label Boot from ^local drive
  localboot 0xffff


label returntomain
  menu label Return to ^main menu
  menu exit

menu end

openeuler系统定制
http://www.jcwit.com/article/49/
作者
Carlos
发布于
2023年10月31日
许可协议