Skip to content
Snippets Groups Projects
Commit 0a6ddb76 authored by Thomas Preisner's avatar Thomas Preisner
Browse files

Merge remote-tracking branch 'origin/efi' into cip.cs.fau.de

parents 23d17dbc ad932a62
Branches cip.cs.fau.de
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ for i in $(cat /proc/cmdline); do
done
# TODO update comment
# * zsh is the default shell for root, so we want it before the first
# salt-highstate's pkgsync is finished (takes several hours) to enable ssh
# while installation is in progress
......@@ -41,7 +42,7 @@ done
# files/usr_local_bin_cip-installer for details.
# * eatmydata possible speed-up during installation
DEBOOTSTRAP_INCLUDE_PKGS=ntpdate,util-linux,wpasupplicant,salt-minion,python3-apt,apt-transport-https,openssh-server,linux-image-amd64,ipxe,zsh,htop,dbus,libcap2-bin,lsb-release,extlinux,syslinux-common,eatmydata
DEBOOTSTRAP_INCLUDE_PKGS=ntpdate,util-linux,wpasupplicant,salt-minion,python3-apt,apt-transport-https,openssh-server,linux-image-amd64,ipxe,zsh,htop,dbus,libcap2-bin,lsb-release,eatmydata,grub-efi
# not strictly config, but this is where people search for global, allcaps
# variables so it's defined here
......
password_pbkdf2 root grub.pbkdf2.sha512.10000.B5C2AFAAD8835D1FBC84C09234AE9C2F161A62E5142160C17A0522E569C659F0A0B4A021BB280E36657D732FBD65B1999759394946F28FC5EBE8598AE07A00C5.C5CF2EE2B00EC399C713A8AC64690BCF6FD373A486DBC54220A53B8ADE32932C488BBEC2AD7C00A845358205E63BF3EE21D60007CA280DF43C21424163FFF7AB
set superusers="root"
insmod all_video
insmod part_gpt
insmod ext2
# Make everything pink to make the installer boot menu easily recognizable
set color_normal="light-magenta/black"
set color_highlight="black/light-magenta"
set menu_color_normal="black/light-magenta"
set menu_color_highlight="light-magenta/black"
set timeout_style=menu
set timeout=5
menuentry 'CIP Linux' --unrestricted {
echo 'Loading kernel ...'
# blacklist noveau to avoid debconf emails about conflicts when installing proprietary nvidia driver
linux /vmlinuz root=__PARTITION__ net.ifnames=0 biosdevname=0 modprobe.blacklist=nouveau
echo 'Loading initial ramdisk ...'
initrd /initrd.img
}
menuentry 'iPXE' --hotkey='i' {
echo 'Chainloading iPXE ...'
chainloader /boot/ipxe.efi
}
menuentry 'System setup' --unrestricted --hotkey='s' {
fwsetup
}
deb http://ftp.fau.de/debian/ buster main non-free contrib
deb-src http://ftp.fau.de/debian/ stable main non-free contrib
deb-src http://ftp.fau.de/debian/ testing main non-free contrib
deb-src http://ftp.fau.de/debian/ unstable main non-free contrib
deb-src http://ftp.fau.de/debian/ experimental main non-free contrib
deb http://security.debian.org/ buster/updates main contrib non-free
deb-src http://security.debian.org/ buster/updates main contrib non-free
......
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
__DISK__1 / ext4 defaults,acl 0 1
__DISK__2 none swap sw 0 0
__DISK_ROOT__ / ext4 defaults,acl 0 1
__DISK_EFI__ /boot/efi vfat umask=0077 0 1
__DISK_SWAP__ none swap sw 0 0
__DISK__1 / ext4 defaults,acl 0 1
__DISK_ROOT__ / ext4 defaults,acl 0 1
__DISK_EFI__ /boot/efi vfat umask=0077 0 1
......@@ -27,8 +27,6 @@ if ! test -e "${DISK}"; then
exit 1
fi
PARTITION="${DISK}${partition_prefix}1"
# Just to be safe.
head -c $(( 1024 * 1024 )) /dev/zero >"${DISK}"
......@@ -42,32 +40,33 @@ log "starting cipinstall on host ${HOSTNAME}"
##########################################
## disk setup
disksize=$(parted --machine ${DISK} unit MB print | grep ^${DISK}: | cut -d ':' -f 2 | sed s/MB$//)
swapsize=32000 # 32G swap
if [ "$ENABLE_SWAP" == "no" ]; then
swapsize=0
fi
rootend=$(( disksize - swapsize ))
swapsize="32GiB" # 32G swap
PART_ESP="${DISK}${partition_prefix}2"
PART_ROOT="${DISK}${partition_prefix}3"
PART_SWAP="${DISK}${partition_prefix}4"
# mklabel in a separate step or parted does weird things.
parted --script ${DISK} mklabel msdos
echo "unit MB mkpart primary 1 $rootend" | parted ${DISK}
if [ "$ENABLE_SWAP" != "no" ]; then
echo "unit MB mkpart primary $rootend -1" | parted ${DISK}
if [ "$ENABLE_SWAP" == "no" ]; then
parted --script -a optimal -- "$DISK" mklabel gpt mkpart primary ext2 1MiB 2MiB set 1 bios_grub on mkpart primary fat32 2MiB 200MiB set 2 esp on mkpart primary ext2 200MiB 100%
else
parted --script -a optimal -- "$DISK" mklabel gpt mkpart primary ext2 1MiB 2MiB set 1 bios_grub on mkpart primary fat32 2MiB 200MiB set 2 esp on mkpart primary ext2 200MiB -32GiB mkpart primary linux-swap -32GiB 100%
fi
parted -l # just debug output
if [ "$ENABLE_SWAP" != "no" ]; then
mkswap ${DISK}2
swapon ${DISK}2
mkswap $PART_SWAP
swapon $PART_SWAP
fi
mkfs.vfat -F32 "$PART_ESP"
# Disable lazy initialization as it slows down I/O during installation.
mkfs.ext4 -O '^64bit' -F -E lazy_itable_init=0,lazy_journal_init=0 -L root ${PARTITION}
mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0 -L root ${PART_ROOT}
install --directory "${TARGET}"
mount -t ext4 ${PARTITION} ${TARGET}
mount -t ext4 ${PART_ROOT} ${TARGET}
mkdir -p "$TARGET/boot/efi"
mount "${PART_ESP}" "$TARGET/boot/efi"
log "successfully created and mounted partitions"
......@@ -163,34 +162,36 @@ log "installer prepared"
## install fstab with correct disk stanza
if [ "$ENABLE_SWAP" != "no" ]; then
sed -e "s,__DISK__,${DISK},g" /files/etc_fstab > ${TARGET}/etc/fstab
sed -e "s,__DISK_ROOT__,${PART_ROOT},g;s,__DISK_EFI__,${PART_ESP},g;__DISK_SWAP__,${PART_SWAP},g" /files/etc_fstab > ${TARGET}/etc/fstab
else
sed -e "s,__DISK__,${DISK},g" /files/etc_fstab_no_swap > ${TARGET}/etc/fstab
sed -e "s,__DISK_ROOT__,${PART_ROOT},g;s,__DISK_EFI__,${PART_ESP},g" /files/etc_fstab_no_swap > ${TARGET}/etc/fstab
fi
## doesn't get set anywhere else
printf "%s\n" "${HOSTNAME}" > ${TARGET}/etc/hostname
##########################################
## install grub
chroot ${TARGET} debconf-set-selections << EOF
grub-efi-amd64 grub2/update_nvram boolean false
EOF
mkdir -p "${TARGET}/boot/cip/grub"
sed -e "s,__PARTITION__,${PART_ROOT},g" /files/boot_cip_grub_grub.cfg > "${TARGET}/boot/cip/grub/grub.cfg"
chmod 600 "${TARGET}/boot/cip/grub/grub.cfg"
chroot ${TARGET} grub-install --bootloader-id=CIP-GRUB --target=x86_64-efi --boot-directory=/boot/cip --efi-directory=/boot/efi
## we need to setup this, because we want to reboot from disk
sed -e "s,__PARTITION__,${PARTITION},g" /files/boot_extlinux_extlinux.conf > ${TARGET}/boot/extlinux/extlinux.conf
chmod 600 ${TARGET}/boot/extlinux/extlinux.conf
install -D -m 0600 /files/extlinux/modules/bios/* ${TARGET}/boot/extlinux
# unmounting flushes the ext4 journal, which might rearrange blocks on disk so
# that extlinux's ldlinux.sys isn't found if we install it before, so we unmount
# everything, then setup MBR, then mount it again just for extlinux installation
# in the hopes that that doesn't change a lot about the journal
umount ${TARGET}/dev
umount ${TARGET}/proc
umount ${TARGET}/run
umount ${TARGET}/sys
umount ${TARGET}
printf '\001' | cat /files/extlinux/altmbr.bin - | dd of=${DISK} bs=440 count=1
mount -t ext4 ${PARTITION} ${TARGET}
extlinux --device ${PARTITION} --install ${TARGET}/boot/extlinux
umount ${TARGET}
log "extlinux successfully installed"
umount "${TARGET}/dev"
umount "${TARGET}/proc"
umount "${TARGET}/run"
umount "${TARGET}/sys"
umount "${TARGET}/boot/efi"
umount "${TARGET}"
......@@ -64,6 +64,7 @@ copy_exec_checked /usr/bin/host
copy_exec_checked /sbin/parted
copy_exec_force /sbin/mke2fs
copy_exec_checked /sbin/mkfs.ext4
copy_exec_checked /sbin/mkfs.vfat
copy_exec_checked /usr/bin/extlinux
# eatmydata for faster installs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment