Chrismurphy (talk | contribs) No edit summary |
Chrismurphy (talk | contribs) (account for recent deference to /etc/kernel/cmdline when creating new BLS entries) |
||
Line 4: | Line 4: | ||
* Fedora 36, any live desktop media, has been installed using default Automatic partitioning. | * Fedora 36, any live desktop media, has been installed using default Automatic partitioning. | ||
* Freshen your backups, just in case | * Freshen your backups, just in case | ||
* Consider disabling GRUB menu autohide. How to use grubby to switch back and forth is shown below, but if you're not familiar with how to reveal the hidden GRUB menu, now is a good time to configure always showing it: | * Consider disabling GRUB menu autohide. How to use grubby to switch back and forth is shown below, but if you're not familiar with how to reveal the hidden GRUB menu, now is a good time to configure always showing it: | ||
`grub2-editenv - unset menu_auto_hide` | `grub2-editenv - unset menu_auto_hide` | ||
Line 23: | Line 21: | ||
# Make it the default, use the filename of the configuration file, removing the `.conf*` ending, e.g. `grub2-set-default 64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64-upgrade` | # Make it the default, use the filename of the configuration file, removing the `.conf*` ending, e.g. `grub2-set-default 64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64-upgrade` | ||
* Optional: You could skip all the above by choosing to reveal the hidden GRUB menu, edit the default entry, modifying `rootflags=subvol=root` to match the name you used for the snapshot, e.g. `root37`. You'd do this twice: once to boot the `root37` snapshot to download the upgrade RPMs; and the following boot after that so it boots root37 thus initiating the offline upgrade. | * Optional: You could skip all the above by choosing to reveal the hidden GRUB menu, edit the default entry, modifying `rootflags=subvol=root` to match the name you used for the snapshot, e.g. `root37`. You'd do this twice: once to boot the `root37` snapshot to download the upgrade RPMs; and the following boot after that so it boots root37 thus initiating the offline upgrade. | ||
====Modify the rootflags argument in the snapshot's `/etc/kernel/cmdline` file==== | |||
# nano /mnt/root37/etc/kernel/cmdline | |||
# Find the option `rootflags=subvol=root` changing it to match your snapshot, e.g. `rootflags=subvol=root37` | |||
====Reboot==== | ====Reboot==== | ||
* Following boot, confirm `/` is actually using the snapshot you made: `mount | grep btrfs` e.g. | * Following boot, confirm `/` is actually using the snapshot you made: `mount | grep btrfs` e.g. |
Revision as of 19:44, 23 August 2022
Description
Instructions for creating a reversible dual-boot test station. We create a dual boot system with two Fedoras of different release versions, using btrfs snapshots, and otherwise normal system upgrade method. It's reversible, meaning it can easily be switched from dual boot back to single boot by deleting the snapshot. A key element is no (re)partitioning is needed either.
Setup
- Fedora 36, any live desktop media, has been installed using default Automatic partitioning.
- Freshen your backups, just in case
- Consider disabling GRUB menu autohide. How to use grubby to switch back and forth is shown below, but if you're not familiar with how to reveal the hidden GRUB menu, now is a good time to configure always showing it:
grub2-editenv - unset menu_auto_hide
Actions
Make snapshots
- Use the
df
command to find the/dev
node+partition for your/
mount point, e.g. $BTRFSPOOL = "/dev/nvme0n1p5" mount $BTRFSPOOL /mnt
; cd /mnt; ls -l- You should see two directories,
root
andhome
. These are Btrfs subvolumes, which we can snapshot. btrfs subvolume snapshot root root37
#any name will do
Create a bootloader entry
cd /boot/loader/entries;ls -l;grubby --default-kernel
- Duplicate the file matching the current default kernel (should be the most recent), e.g.
cp 64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64.conf 64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64-upgrade.conf
- Edit it
nano 64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64-upgrade.conf
- On the title line, append
UPGRADE
to the end of the line. - Find the option
rootflags=subvol=root
changing it to match your snapshot, e.g.rootflags=subvol=root37
- Save the file
- On the title line, append
- Make it the default, use the filename of the configuration file, removing the
.conf*
ending, e.g.grub2-set-default 64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64-upgrade
- Optional: You could skip all the above by choosing to reveal the hidden GRUB menu, edit the default entry, modifying
rootflags=subvol=root
to match the name you used for the snapshot, e.g.root37
. You'd do this twice: once to boot theroot37
snapshot to download the upgrade RPMs; and the following boot after that so it boots root37 thus initiating the offline upgrade.
Modify the rootflags argument in the snapshot's /etc/kernel/cmdline
file
- nano /mnt/root37/etc/kernel/cmdline
- Find the option
rootflags=subvol=root
changing it to match your snapshot, e.g.rootflags=subvol=root37
Reboot
- Following boot, confirm
/
is actually using the snapshot you made:mount | grep btrfs
e.g.
/dev/vda3 on / type btrfs (rw,relatime,seclabel,compress=zstd:1,space_cache=v2,subvolid=257,subvol=/root)
you should see subvol=/root37
or whatever you named the snapshot. If you see root
as in this example, oops! You're still working on your original root, and need to figure out what went wrong.
One bootloader
As each Fedora performs updates, it'll occasionally update the bootloaders on /boot/efi
. This shouldn't be a problem. But then there's sometimes bugs, so if you don't want to be testing Rawhide bootloaders, consider addingexclude=grub2-*
in the test instance's dnf.conf
. The time to do this is after the first boot into root37
snapshot, before starting upgrade download.
Initiate the system upgrade
Either of these, just like you normally would:
- https://fedoraproject.org/wiki/QA:Testcase_upgrade_dnf_current_workstation
- https://fedoraproject.org/wiki/QA:Testcase_upgrade_gnome-software_current_workstation
Post-upgrade
cat /etc/fedora-release
to confirm the upgrade happened, and it's booted.
rm /boot/loader/entries/64db766697e04179a6d3f7a67c2941e1-5.18.16-200.fc36.x86_64-upgrade.conf
this file is no longer needed and confuses grubby, preventing boot back into Fedora 36.
Switching between the two roots
- Either reveal the GRUB hidden menu (Esc or Tab or see the TIP below) to make manual choices, OR
ls -l /boot
to see a list of kernels so you can complete the path based on which release version you want to boot, e.g.grubby --set-default=/boot/vmlinuz-5.18.15-200.fc36.x86_64
to boot Fedora 36grubby --set-default=/boot/vmlinuz-5.19.0-65.fc37.x86_64
to boot Fedora 37
Limitations
How many Fedoras?
/boot
is only 1GiB by default. This is the limiting factor for how many Fedoras you can have installed at one time. Two is safe. Three is iffy unless:
- configure the test Fedora instances' dnf.conf such
exclude=kernel-*
; - consider deleting the "rescue" initramfs and kernel for the test instances, and the "rescue" snippet in
/boot/loader/entries/
, and removingdracut-config-rescue-056-1.fc36.x86_64
from them so these files aren't recreated.
Fedoras of the same release version?
It's possible. The caveat is you need to either keep them both consistently up to date, or never update them, or be prepared for some minor bootloader+kernel related breakage. Since same release versions have the same kernel packages, Fedora A could remove Fedora B's kernel+initramfs files from boot. So it's doable but really depends on individual comfort level with such details.
How to delete the test instance
- Boot the menu entry for the instance you want to keep
- Confirm you've booted it
mount | grep btrfs
does the subvolume name match what you want to keep? btrfs subvolume list -t /
##find the ID in the left column that matches the subvolume snapshot name you want to deletebtrfs subvolume delete --subvolid $ID /
##Note that/
is the mountpoint for the file system, it's not going to delete your currently running root, it'll delete the ID you specify.- Check
/boot
for no longer needed files, e.g.ls -l | grep fc37
, and remove them. - Check
/boot/loader/entries
for no longer needed files using the same command, and remove them.
Tips
- Use
grub2-editenv - unset menu_auto_hide
to always show the menu at boot. - Use
grub2-editenv - set menu_auto_hide=1
to conditionally hide the menu at boot.
Built-in Btrfs command shortcuts
The btrfs
command will accept arbitrarily shortened sub-commands so long as they're unambiguous, e.g. these commands are equivalent:
btrfs subvolume snapshot
,btrfs sub snap
,btrfs su sn
btrfs filesystem usage
,btrfs fi us
No configuration is needed, just try out your own shortened subcommands. If you make it too short, you'll get a hint why it's ambiguous.
What if Windows is already installed?
I tested on a system with Windows 10 and Fedora 36 already installed, and it's now triboot. So it's OK.
What about /etc/fstab?
Right! There's no step for changing the subvolume in /etc/fstab
. And that's because it doesn't matter. The /
entry in fstab is unique in that it's a "remount" operation rather than a first time mount operation, like all the other lines in fstab. Because it's a remount of an already mounted subvolume, we can't change the subvolume being mounted, so the subvol
mount option is ignored. The reason why subvol
is on the /
line at all is a side-effect of how the installer creates /etc/fstab
. If it's confusing, you can modify it accordingly but it's not necessary.