Skip to content

Commit ba54b04

Browse files
committed
Allow /boot to be a btrfs subvolume
In a btrfs based design, allow to put /boot as subvolume. This required a small fix in the mount order in a way that boot/efi gets mounted after the subvolume mounts are done. The respective integration test has been updated to test this functionality. This Fixes #2824
1 parent b4389ac commit ba54b04

File tree

3 files changed

+24
-41
lines changed

3 files changed

+24
-41
lines changed

build-tests/x86/fedora/test-image-live-disk/appliance.kiwi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
</type>
3131
</preferences>
3232
<preferences profiles="Virtual">
33-
<type image="oem" filesystem="btrfs" kernelcmdline="console=ttyS0" firmware="uefi" format="qcow2" btrfs_root_is_subvolume="true" btrfs_set_default_volume="false" rootfs_label="fedora" bootpartition="true" bootfilesystem="ext4">
33+
<type image="oem" filesystem="btrfs" kernelcmdline="console=ttyS0" firmware="uefi" format="qcow2" btrfs_root_is_subvolume="true" btrfs_set_default_volume="false" rootfs_label="fedora" bootpartition="false">
3434
<systemdisk name="fedora">
3535
<volume name="@root=root"/>
36+
<volume name="boot" parent="/"/>
3637
<volume name="home" parent="/"/>
3738
<volume name="var" parent="/"/>
3839
</systemdisk>

kiwi/bootloader/config/base.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -397,21 +397,21 @@ def get_boot_path(self, target='disk'):
397397
# according to the mount path.
398398
bootpath = '/'
399399

400-
if target == 'disk':
401-
if not need_boot_partition:
402-
filesystem = self.xml_state.build_type.get_filesystem()
403-
volumes = self.xml_state.get_volumes()
404-
if filesystem == 'btrfs' and volumes:
405-
# grub boot data paths must not be in a subvolume
406-
# otherwise grub won't be able to find its config file
407-
grub2_boot_data_paths = ['boot', 'boot/grub', 'boot/grub2']
408-
for volume in volumes:
409-
if volume.name in grub2_boot_data_paths:
410-
raise KiwiBootLoaderTargetError(
411-
'{0} must not be a subvolume'.format(
412-
volume.name
413-
)
414-
)
400+
# if target == 'disk':
401+
# if not need_boot_partition:
402+
# filesystem = self.xml_state.build_type.get_filesystem()
403+
# volumes = self.xml_state.get_volumes()
404+
# if filesystem == 'btrfs' and volumes:
405+
# # grub boot data paths must not be in a subvolume
406+
# # otherwise grub won't be able to find its config file
407+
# grub2_boot_data_paths = ['boot', 'boot/grub', 'boot/grub2']
408+
# for volume in volumes:
409+
# if volume.name in grub2_boot_data_paths:
410+
# raise KiwiBootLoaderTargetError(
411+
# '{0} must not be a subvolume'.format(
412+
# volume.name
413+
# )
414+
# )
415415

416416
if target == 'iso':
417417
bootpath = '/boot/' + self.arch + '/loader'
@@ -541,9 +541,6 @@ def _mount_system(
541541
if not self.root_mount.device == self.boot_mount.device:
542542
self.boot_mount.mount()
543543

544-
if efi_device:
545-
self.efi_mount.mount()
546-
547544
if volumes:
548545
for volume_path in Path.sort_by_hierarchy(
549546
sorted(volumes.keys())
@@ -557,6 +554,9 @@ def _mount_system(
557554
options=[volumes[volume_path]['volume_options']]
558555
)
559556

557+
if efi_device:
558+
self.efi_mount.mount()
559+
560560
if self.root_filesystem_is_overlay:
561561
# In case of an overlay root system all parts of the rootfs
562562
# are read-only. However tools like grub's mkconfig creates
@@ -600,6 +600,10 @@ def _umount_system(self):
600600
setup = SystemSetup(self.xml_state, self.root_mount.mountpoint)
601601
setup.setup_selinux_file_contexts()
602602
# Umount system
603+
if self.efi_mount:
604+
self.efi_mount.umount()
605+
if self.boot_mount:
606+
self.boot_mount.umount()
603607
for volume_mount in reversed(self.volumes_mount):
604608
volume_mount.umount()
605609
if self.device_mount:
@@ -608,14 +612,10 @@ def _umount_system(self):
608612
self.proc_mount.umount()
609613
if self.sys_mount:
610614
self.sys_mount.umount()
611-
if self.efi_mount:
612-
self.efi_mount.umount()
613615
if self.tmp_mount:
614616
self.tmp_mount.umount()
615617
if self.etc_kernel_mount:
616618
self.etc_kernel_mount.umount()
617-
if self.boot_mount:
618-
self.boot_mount.umount()
619619
if self.root_mount:
620620
self.root_mount.umount()
621621
self.system_is_mounted = False

test/unit/bootloader/config/base_test.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -247,24 +247,6 @@ def test_get_boot_path_raises(self):
247247
with raises(KiwiBootLoaderTargetError):
248248
self.bootloader.get_boot_path('foo')
249249

250-
@patch('kiwi.bootloader.config.base.DiskSetup')
251-
@patch('kiwi.xml_parse.type_.get_filesystem')
252-
@patch('kiwi.xml_state.XMLState.get_volumes')
253-
def test_get_boot_path_btrfs_boot_is_a_volume_error(
254-
self, mock_volumes, mock_fs, mock_disk_setup
255-
):
256-
volume = Mock()
257-
volume.name = 'boot'
258-
mock_volumes.return_value = [volume]
259-
mock_fs.return_value = 'btrfs'
260-
disk_setup = Mock()
261-
disk_setup.need_boot_partition = Mock(
262-
return_value=False
263-
)
264-
mock_disk_setup.return_value = disk_setup
265-
with raises(KiwiBootLoaderTargetError):
266-
self.bootloader.get_boot_path()
267-
268250
@patch('kiwi.bootloader.config.base.DiskSetup')
269251
@patch('kiwi.xml_parse.type_.get_filesystem')
270252
@patch('kiwi.xml_parse.type_.get_btrfs_root_is_snapper_snapshot')

0 commit comments

Comments
 (0)