------------------------------------------------------------------------------- Install a newer Fedora onto a new partition from Fedora These instructions is for installing fedora onto a second 'root' partition. While the 'old' one is running and left as is! This lets you update your OS without too much 'downtime' as the system remains running while you are upgrading. ------------------------------------------------------------------------------- Summery... The upgrade in this way will require a new 'separate' root partition. This can be on the on the same disk, or a different disk. This lets you have two or more OS's on the same machine, and lets you complete the installation of a new OS before committing yourself to using the new OS. Basically you can continue to use the old system while upgrading, OR go back to the old system should you find the new system or not ready, due to some critical component is not working YET. During upgrade, you have full access to the previous systems configuration files, allowing you to examine, compare, and transfer missing configuration as you discover you need them. That is you will not get 'stuck' being unable to use a machine, while you are installing the new OS. And even after it is complete you still have the old OS to fall back on. To help with this my own systems always use separate partitions for HOME and DATA, and when creating machines I always set up two root partitions, specifically for upgrading. This is NOT necessary, but I recommend it as it makes upgrades a lot easier. If your home/data is part of the root partition, consider taking the opportunity to separate home from root, though you could copy your home to the new root (or new disk) as part of the upgrade process. November 2016, Anthony Thyssen Successful updates made using this method Nov 2016 FC22 -> FC23 May 2018 FC25 -> FC28 Oct 2019 FC28 -> FC31 May 2021 FC31 -> FC34 Aug 2023 FC35 -> FC38 Nov 2023 FC36 -> FC39 Jan 2024 FC37 -> FC39 ------------------------------------------------------------------------------- Upgrade via DNF into the Alternative Root This was developed after discovering a "--installroot" option for "dnf" ... http://dnf.readthedocs.io/en/latest/command_ref.html?highlight=installroot NOTES: /dev/sda1 -- current root partition, mounted as '/', and running /dev/sda2 -- new root partition to be mounted as /mnt/alt during upgrade Install New Root Partition Software # The release you are upgrading too. RL=39 # Clear the alternative root partition (normally mounted /mnt/alt) # used /dev/sdaX as a precaution - set as appropriate # This is the ONLY place actual disk devices are used. # You can make the partition either XFS or EXT4 as you like umount /mnt/alt #mkfs.xfs -f -m crc=0,finobt=0 -L Fedora$RL /dev/sdaX mkfs.ext4 /dev/sdaX vi /etc/fstab :" set file system for /dev/sdaX to correct FS type (xfs or ext4) mount /mnt/alt # If /boot is a seperate mount to root then mkdir /mnt/alt/boot mount --bind /boot /mnt/alt/boot # Adjust location and repos being used for system install # After system is installed you can edit you yum.repos.d files DNF_OPTS="--installroot=/mnt/alt --disablerepo=* --releasever=$RL" DNF_OPTS="$DNF_OPTS --enablerepo=fedora --enablerepo=updates" DNF_OPTS="$DNF_OPTS --setopt=install_weak_deps=False" # Make sure variables are set! echo Fedora Release $RL echo DNF_OPTS="$DNF_OPTS" # set server release version for the new root partition (159 packages) # Use -v to trouble shoot the exact URL being used. dnf -y $DNF_OPTS --releasever=$RL --refresh --nogpgcheck \ install system-release coreutils # optionally add redhat-release-server # Fix up the public keys (on local system - for later steps) rsync -ai /mnt/alt/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$RL-* \ /etc/pki/rpm-gpg rm /etc/pki/rpm-gpg/RPM-GPG-KEY ln -s RPM-GPG-KEY-fedora-$RL-primary /etc/pki/rpm-gpg/RPM-GPG-KEY rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* # Information about that packages available for that system # dnf $DNF_OPTS list installed # dnf $DNF_OPTS grouplist # Install Base Environment - selected from the group list dnf -y $DNF_OPTS groupinstall 'Fedora Workstation' # (approx 1650 packages) # Other Packages, but not in Base Environment dnf -y $DNF_OPTS install lvm2 # for lvm mounts (which I use) dnf -y $DNF_OPTS install redhat-lsb # user level perl,gcc (275 packages) dnf -y $DNF_OPTS install efibootmgr dnf -y $DNF_OPTS install grub2 grubby grub2-efi-x64-modules dnf -y $DNF_OPTS install grub2-efi-x64 shim-x64 dnf -y $DNF_OPTS install vim-{enhanced,X11} # the full editor dnf -y $DNF_OPTS install kernel kernel-{core,modules} # install kernel dnf -y $DNF_OPTS install kernel-{headers,devel} # Double check directory "/mnt/alt/boot" has approprite kernel files # such as: "System.map", "config", "initramfs", "vmlinuz" ls /mnt/alt/boot/*fc$RL* Additional Configuration (Optional) # set disk devices -- swap root partition mount points cat /etc/fstab >> /mnt/alt/etc/fstab vi /mnt/alt/etc/fstab :" swap the 'root' and "/mnt/alt" partitons for new system # Copy root password (if any) vi /mnt/alt/etc/shadow :1r !head -1 /etc/shadow :1d :w! :q # Copy my user account (home is a seperate shared mount)... # Adding myself to 'wheel' is especially important. user=anthony grep ^$user: /etc/passwd >>/mnt/alt/etc/passwd grep ^$user: /etc/shadow >>/mnt/alt/etc/shadow grep ^$user: /etc/group >>/mnt/alt/etc/group perl -i -ple 'next unless /^wheel/;$_.='$user /mnt/alt/etc/group # check and sort password and group files pwck -R /mnt/alt -s grpck -R /mnt/alt -s # Turn off SELinux - before system even starts (optional) vi /mnt/alt/etc/selinux/config :/^SELINUX=/s/=.*/=disabled/ :wq # Preserve original hostname and ssh host keys cp -p /etc/hostname /mnt/alt/etc/hostname cp -p /etc/ssh/ssh_host_* /mnt/alt/etc/ssh chown root:root /mnt/alt/etc/ssh/ssh_host_* chmod 644 /mnt/alt/etc/ssh/ssh_host_*.pub chmod 600 /mnt/alt/etc/ssh/ssh_host_*_key # Configure network (optional - adjust for local requirements) # no longer needed as network manager now does all this. # cp -p /etc/sysconfig/network-scripts/* \ # /mnt/alt/etc/sysconfig/network-scripts # Configure Time setup for new OS (Optional) cp /etc/chrony.conf /mnt/alt/etc/chrony.conf # OR vi /mnt/alt/etc/chrony.conf :" comment out fedora 'pool' :%s/^pool/#pool/ :" copy the servers up use from the old machine :r !grep ^server /etc/chrony.conf # Copy TimeZone symlink cp -P /etc/localtime /mnt/alt/etc/localtime # copy repo setup (Optional) # rsync -aHSi /etc/yum.repos.d/ /mnt/alt/etc/yum.repos.d # vi /mnt/alt/etc/yum.repos.d/* # :" make sure versions are correct --- More Personal Configuration # Copy the "lightdm" login method (if present) cp -rp /var/cache/lightdm/dmrc \ /mnt/alt/var/cache/lightdm # Crontabs cp -rp /var/spool/cron \ /mnt/alt/var/spool/ Set up Boot of new OS from current (old) grub # Prepare new system (even if we don't use it at first) # Grab the grub configuration you previously used #vi /etc/default/grub # :" adjust if nessarary # GRUB_PRELOADED_MODULES="xfs" cp /etc/default/grub /mnt/alt/etc/default/grub # Insure grub understands how to read a XFS filesystem #mkdir /mnt/alt/boot/grub2/i386-pc #cp -p /mnt/alt/usr/lib/grub/i386-pc/*.mod /mnt/alt/boot/grub2/i386-pc # Is new OS visible? os-prober # Make sure boot flag is set for partition fdisk -l /dev/sda # set flag if needed # Add New system to the current (old) boot menu grub2-mkconfig -o /boot/grub2/grub.cfg grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg grub2-install /dev/sda grub2-install --root-directory=/mnt/alt /dev/sda efibootmgr Try booting to new system Reboot again to go back to the old OS. For example if there are problems, or want to do more installs before switching over to new OS completely. When satisfied new system is working you can boot to it then set it as the default boot OS using. A link to the old OS should still be available if you need it. Check Results efibootmgr # and check 'BootOrder:" Add entry efibootmgr -c --disk /dev/{disk} --part {partition} -L {name} Delete Boot Order efibootmgr -O Delete Entry efibootmgr -b 0001 -B Delete all entried except Boot0000* UEFI PC SN530 NVMe WDC 512GB 20328E805576 1 PciRoot Add the prefered disk and partition and the rest will be populated on next boot. ------------------------------------------------------------------------------- Additional things... Curtisy of Jay Guerette Package from Old system... Try to install all packages, install on current (old) system, into the new root partition... rpms=$(dnf repoquery --userinstalled --queryformat "%{NAME}") dnf $dnf_opts --assumeyes install $rpms NOTE: DNF does keep a record (somewhere) of what packages were 'requested' to be installed, and what were 'dependants' of those. That way it can removed all dependants, unless they were specifically requested when removing packages. As such it would be better to install a edited list of 'wanted' packages... rpms=$(grep -v '#' /home/system/system.rpms) dnf $dnf_opts --assumeyes install $rpms WARNING: Some packages may not be available on new system. That is they have been: depreciated, no longer maintained, security issues Copy services... Capture the current services... systemctl --no-legend list-unit-files --type=service \ --state=enabled,disabled,masked | sed -r 's/(^.+service)\s+(\w+).+$/\1 \2/g' \ > /home/system/systemctl.state ON new (running) system, prompt for changes... while read line; do service=${line/ *} ; state=${line/* } current=$(systemctl show $service --value --property UnitFileState 2>&1) [[ $current =~ ^Failed ]] && continue [[ $current =~ $state ]] && continue read -n1 -p "$service $current => $state ? " ; echo [[ ${REPLY^^} = Y ]] || continue state=${state%d} ; state=${state/ke/k} systemctl --now $state $service done enabled ? y Created symlink /etc/.../shellinaboxd.service → .../shellinaboxd.service. I admit it's a bit crude in it's initial incarnation. I'll definitely refine it. I hope any of this is helpful. I'll be working on my master script a bit more, and then likely do a trial boot to my new Fedora 32 partition in the next week. Copy ALL Users, Groups, and root Password This is the code I'm using to completely automate the copy of local users, groups, and the root password, to the new install. # location of new install new_dir=/mnt/alt # get GID for users group users_gid=$(grep -Po '^users:x:\K\d+' /etc/group) # interate over members of the users group that have a home directory for user in \ $(grep -Po "[^:]+(?=:.:\d+:$users_gid:[^:]*:/home)" /etc/passwd) do for file in passwd shadow; do # remove any pre-existing entries sed -ri "/^$user:/d" $new_dir/etc/$file # append user grep -P "^$user:" /etc/$file >> $new_dir/etc/$file done done # copy root password sed -i '/^root:/c'$(grep -P '^root:' /etc/shadow) $new_dir/etc/shadow # copy selected group membership; add groups specific to your setup for group in wheel; do for user in $(groupmems -lg $group); do groupmems --root $new_dir -g $group -a $user done done # check and repair files pwck --root $new_dir grpck --root $new_dir 22 June 2020, Jay Guerette -------------------------------------------------------------------------------