# To start a VM to test this script out: ####PATHTOTHISFILE='/home/dustymabe/Desktop/Dropbox/www/web/DRAFTS/md-crypt-lv-btrfs/md-crypt-lv-btrfs.txt.forblog.f25.ks' ####sudo -E virt-install \ #### --name installtest --ram 2048 \ #### --disk path=/guests/storagepools/manual/foodisk.img,size=9 \ #### --location /guests/images/Fedora-Server-dvd-x86_64-25-1.3.iso \ #### --extra-args="inst.sshd text ks=file:///$(basename $PATHTOTHISFILE)" \ #### --initrd-inject $PATHTOTHISFILE install cdrom lang en_US.UTF-8 keyboard us timezone --utc America/New_York bootloader --location=mbr --driveorder=vda --append="crashkernel=auto" clearpart --all part / --size=3000 --fstype=ext4 --grow %packages @core %end %pre --erroronfail ( #!/bin/bash set -ex # The password for hard drive encryption ENCPASS='lukspass' # The root user password ROOTPASS='rootpass' # Format the hard drive fdisk /dev/sda < /etc/yum.repos.d/dvd.repo [dvd] name=dvd baseurl=file:///run/install/repo enabled=1 gpgcheck=0 EOF # Install the base system dnf install -y --releasever=25 --installroot=/mnt/sysimage filesystem # Mount special filesystems mount -v -o bind /dev /mnt/sysimage/dev/ mount -v -o bind /run /mnt/sysimage/run/ mount -v -t proc proc /mnt/sysimage/proc/ mount -v -t sysfs sys /mnt/sysimage/sys/ # Copy over the dvd repo into the new sysroot cp /etc/yum.repos.d/dvd.repo /mnt/sysimage/etc/yum.repos.d/ # Install more stuff now dnf install -y --installroot=/mnt/sysimage --disablerepo=* --enablerepo=dvd @core @standard kernel btrfs-progs lvm2 # Now install the special grub packages that I have compiled dnf install -y --installroot=/mnt/sysimage --disablerepo=* --enablerepo=dvd \ https://github.com/dustymabe/fedora-grub-boot-btrfs-default-subvolume/raw/master/fedora25/rpmbuild/RPMS/x86_64/grub2-2.02-0.38.fc25.dusty.x86_64.rpm \ https://github.com/dustymabe/fedora-grub-boot-btrfs-default-subvolume/raw/master/fedora25/rpmbuild/RPMS/x86_64/grub2-tools-2.02-0.38.fc25.dusty.x86_64.rpm # Remove the dvd repo. We don't want it to be on the installed system rm /mnt/sysimage/etc/yum.repos.d/dvd.repo # Set root user password echo -n $ROOTPASS | chroot /mnt/sysimage passwd --stdin root # Chroot into the system chroot /mnt/sysimage bash <<'ENDCHROOT' # Set up unlocking the encrypted device on boot UUID=$(blkid -s UUID -o value /dev/sda1) cat < /etc/crypttab cryptodisk /dev/disk/by-uuid/$UUID - EOF # Write fstab cat < /etc/fstab /dev/vgroot/lvroot / btrfs defaults 1 1 /dev/vgroot/lvswap swap swap defaults 0 0 EOF # Anaconda writes out /etc/sysconfig/kernel here: # https://github.com/rhinstaller/anaconda/blob/7477c6f7a1d22c2f107b66b0d906dfae91ac2117/pyanaconda/bootloader.py#L2355 # If we don't have this file then we have to update grub.cfg # everytime we do a kernel update: # https://bugzilla.redhat.com/show_bug.cgi?id=1242315 cat < /etc/sysconfig/kernel # UPDATEDEFAULT specifies if new-kernel-pkg should make # new kernels the default UPDATEDEFAULT=yes # DEFAULTKERNEL specifies the default kernel package type DEFAULTKERNEL=kernel-core EOF # configure relabel on first boot touch /.autorelabel # Write out some var for grub.conf and generate grub.cfg cat <> /etc/default/grub GRUB_ENABLE_CRYPTODISK=y SUSE_BTRFS_SNAPSHOT_BOOTING=true EOF grub2-mkconfig -o /boot/grub2/grub.cfg # Install grub grub2-install /dev/sda # Generate initramfs KERNELVRA=$(rpm -q kernel --qf %{V}-%{R}.%{ARCH}) dracut --kver $KERNELVRA --force ENDCHROOT # umount mounted filesystems and reboot umount /mnt/sysimage/{dev,run,sys,proc} umount /mnt/sysimage/ reboot ) | tee /tmp/dusty.log /dev/pts/0 %end