2

I'm trying to install different linux distributions inside a single BTRFS filesystem, using a subvolume for each, in order to avoid wasting free space using different partitions.
I am using a laptop running UEFI, and I wanted to use the following partitioning scheme:

sda1: EFI boot, mounted on /boot/efi on all systems
sda2: swap
sda3: BTRFS volume

sda3 would then be "partitioned" in the following subvolumes:
/data: subvolume for data
/snapshots: subvolume for snapshots
/os/DISTID: subvolume for distro DIST (one for distro)

Every distro would install its GRUB2, and I would load the GRUB I need in UEFI, so that every distro does not need to be aware of the others.

I was able to install Arch and Funtoo, but I wasn't able to set OpenSUSE to install to the /os/suse subvolume.
I tried the following:

  • set the latter as default subvolume (as stated also here) and told OpenSUSE not to format the partition; the installation seemed to be successful, but it wasn't able to boot
  • mounted the subvolume to /mnt in the installation live system and told OpenSUSE to ignore the fact; the installation failed when it tried to remount the partition for the actual installation
  • installed OpenSUSE in a virtual machine resembling the laptop environment, then copied the whole system to the subvolume and made the needed adjustments to grub and its settings (the ones I had to do with Arch or Funtoo); grub was loaded, but the booted system went in kernel panic

The adjustments to GRUB I wrote about imply the following:

  • chroot in the subvolume (using arch-chroot or the procedure for gentoo/funtoo installation)
  • install grub in /boot/efi, the EFI system partition (but keep GRUB's data in /boot)
  • run grub-mkconfig -o /boot/grug/grub.cfg to update the bootloader

Has anyone any idea? Did I miss something?

2

From my experience, the handling of custom (e.g. other than the snapper / @-notation) subvolumes by the OpenSUSE Leap 42.2 / 42.3 installer does not work. Even worse, some tools, such as the bootloader installation, have problems with it. For instance, in my case the grub core was pointing to /boot/grub..., but it should be just /grub.. when updating from chroot. You can check the current settings with this tool: https://github.com/arvidjaar/bootinfoscript

Anyways, here is a way I use to setup after installation or for bootable backups.

Avoid creating the dozen of subvolumes by the installer, just install e.g. in the root of the partition / default subvolume (if that worked).

After installation, start the rescue system and

  1. Move the installed system directories to the desired subvolume, such that you have the usual Linux filesystem tree below that subvolume. Fix the home folder as well, if necessary.
  2. Fix the /etc/fstab, adding the proper subvol=/myrootsubvol options
  3. Mount the partition with the subvolume (future /), mount boot, and mount boot/efi
  4. Now create second directory outside of the mounted subvolume. Do bind-mount everything into that directory.

    mount -o bind "/mnt/partition_root/sysroot_subvol" "/mnt/temp_sys_prep" 
    mount -o bind "/mnt/partition_root/sysroot_subvol/boot" "/mnt/temp_sys_prep/boot" 
    mount -o bind "/mnt/partition_root/sysroot_subvol/boot/efi" "/mnt/temp_sys_prep/boot/efi" 
    mount -o bind /proc "/mnt/temp_sys_prep/proc"
    mount -o bind /sys "/mnt/temp_sys_prep/sys"
    mount -o bind /dev "/mnt/temp_sys_prep/dev"    
    
  5. Now use the usual chroot-approach for /mnt/temp_sys_prep. In the chroot you can use

    • grub2-install --no-nvram --recheck --efi-directory=/boot/efi /dev/disk/by-id/scsi-SATA...,
    • grub2-mkconfig -o /boot/grub2/grub.cfg,
    • mkinitrd

    I'm unsure about the correct order; mkinitrd probably also calls grub.

  6. Exit the chroot and unmount in reverse order. Check with the tool again, if grub2 core points to the correct path now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.