From 57ed283dc22e650e87293854cea6f5a4e4fa9e6c Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sat, 23 Jan 2016 15:59:31 +0000 Subject: Support btrfs filesystem Sunil Mohan Adapa - Do not pass errors=remount-ro mount flag for btrfs filesystems. Btrfs has this behavior by default and does not support the flag. - Add test scenario for btrfs. Check filesystem type and fstab entry. - Expand ext4 test to check for expected fstab entry. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741223 --- vmdebootstrap/filesystem.py | 15 +++++++++++++-- yarns/300-slow-build-tests.yarn | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/vmdebootstrap/filesystem.py b/vmdebootstrap/filesystem.py index d17663e..0898de9 100644 --- a/vmdebootstrap/filesystem.py +++ b/vmdebootstrap/filesystem.py @@ -164,14 +164,25 @@ class Filesystem(Base): fstab = os.path.join(str(rootdir), 'etc', 'fstab') with open(fstab, 'w') as fstab: fstab.write('proc /proc proc defaults 0 0\n') - fstab.write('%s / %s errors=remount-ro 0 1\n' % (rootdevstr, roottype)) + fstab.write('%s / %s %s 0 1\n' % + (rootdevstr, roottype, self.get_mount_flags(roottype))) if bootdevstr: - fstab.write('%s /boot %s errors=remount-ro 0 2\n' % (bootdevstr, boottype)) + fstab.write('%s /boot %s %s 0 2\n' % + (bootdevstr, boottype, self.get_mount_flags(boottype))) if self.settings['swap'] > 0: fstab.write("/dev/sda3 swap swap defaults 0 0\n") elif self.settings['swap'] > 0: fstab.write("/dev/sda2 swap swap defaults 0 0\n") + @staticmethod + def get_mount_flags(fstype): + """Return the fstab mount flags for a given file system type.""" + flags = ['errors=remount-ro'] + if fstype == 'btrfs': + flags = [] + + return ','.join(flags) or 'defaults' + def squash_rootfs(self): """ Run squashfs on the rootfs within the image. diff --git a/yarns/300-slow-build-tests.yarn b/yarns/300-slow-build-tests.yarn index 2ceae72..74d999f 100644 --- a/yarns/300-slow-build-tests.yarn +++ b/yarns/300-slow-build-tests.yarn @@ -28,6 +28,7 @@ These tests are slow, since building images is slow. AND partition 1 has the boot flag set AND partition 1 has an ext4 filesystem AND partition 1 has file /boot/grub/grub.cfg matching ^### BEGIN /etc/grub.d/00_header ###$ + AND partition 1 has file /etc/fstab matching ^\S+\s+\/\s+ext4\s+errors=remount-ro\s+\d\s+\d$ SCENARIO build a Debian 8 image with uefi ASSUMING build tests are requested @@ -37,3 +38,13 @@ These tests are slow, since building images is slow. AND the partition count of the image is 2 AND partition 1 has an vfat filesystem AND partition 2 has file /boot/grub/grub.cfg matching ^### BEGIN /etc/grub.d/00_header ###$ + + SCENARIO build a Debian 8 image with btrfs + ASSUMING build tests are requested + GIVEN user wants to build an image FOO.img that is 2GiB in size + WHEN the user runs vmdebootstrap --roottype=btrfs + THEN the image has the correct size + AND the partition count of the image is 1 + AND partition 1 has the boot flag set + AND partition 1 has an btrfs filesystem + AND partition 1 has file /etc/fstab matching ^\S+\s+\/\s+btrfs\s+defaults\s+\d\s+\d$ -- cgit v1.2.1