Hello mailinglist followers,
this first patchset will introduce basic BTRFS support in IPFire 2.x.
It allows to choose BTRFS during installation as filesystem, will install IPFire and bring it up as usual.
The main difference to the other file system will be displayed when showing the current mounted filesystems. When using BTRFS a lot of so called subvolumes will be created. They act as some kind of logical partition and are needed in two cases.
This kind of fragmentation allows to create snapshots of such a subvolume and only the stored data on it. The more important reason of using subvolumes is, that while creating a snapshot any files which are located on a different subvolume will not be part of it.
So, when creating a snaphot of the filesystem root and restoring it back later, no files which are part of a subvolume (logfile, database files etc) are rolled-back. This helps us debugging because the old logs are still there and mostly important prevents from data lost of altered databases or newly created files!
Currently there is still some work to do see:
Wiki-Roadmap: https://www.ipfire.org/docs/roadmap/btrfs Bugzilla: https://bugzilla.ipfire.org/show_bug.cgi?id=13606
Stefan Schantl (17): btrfs-progs: New package installer: Allow to install IPFire on BTRFS installer: Ensure to always create the /boot directory. installer: Disable seperate boot partition installer: Add code to create a BTRFS subvolume layout. installer: Correctly umount main BTRFS partition. installer: Add recurisve mkdir function installer: Mount BTRFS layout before installing the system installer: Add /var/tmp to the BTRFS layout installer: Fix using BTRFS mount options when mounting the layout installer: Add code to proper unmount the BTRFS layout installer: Add code to correctly write the fstab when installing on BTRFS installer: Define common mount options for BTRFS volumes inotify-tools: New package grub-btrfs: New package installer: Mark BTRFS support as experimental installer: Adjust BTRFS layout
config/rootfiles/common/btrfs-progs | 33 +++ config/rootfiles/common/grub-btrfs | 14 ++ config/rootfiles/common/inotify-tools | 19 ++ config/rootfiles/common/x86_64/initscripts | 4 + lfs/btrfs-progs | 85 ++++++++ lfs/grub-btrfs | 79 +++++++ lfs/initscripts | 3 + lfs/inotify-tools | 83 ++++++++ make.sh | 3 + src/initscripts/system/grub-btrfsd | 61 ++++++ src/installer/dracut-module/module-setup.sh | 4 +- src/installer/hw.c | 221 +++++++++++++++++++- src/installer/hw.h | 8 + src/installer/main.c | 1 + 14 files changed, 606 insertions(+), 12 deletions(-) create mode 100644 config/rootfiles/common/btrfs-progs create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 config/rootfiles/common/inotify-tools create mode 100644 lfs/btrfs-progs create mode 100644 lfs/grub-btrfs create mode 100644 lfs/inotify-tools create mode 100644 src/initscripts/system/grub-btrfsd
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- config/rootfiles/common/btrfs-progs | 33 +++++++++++ lfs/btrfs-progs | 85 +++++++++++++++++++++++++++++ make.sh | 1 + 3 files changed, 119 insertions(+) create mode 100644 config/rootfiles/common/btrfs-progs create mode 100644 lfs/btrfs-progs
diff --git a/config/rootfiles/common/btrfs-progs b/config/rootfiles/common/btrfs-progs new file mode 100644 index 000000000..04af32d3f --- /dev/null +++ b/config/rootfiles/common/btrfs-progs @@ -0,0 +1,33 @@ +lib/udev/rules.d/64-btrfs-dm.rules +lib/udev/rules.d/64-btrfs-zoned.rules +usr/bin/btrfs +usr/bin/btrfs-convert +usr/bin/btrfs-find-root +usr/bin/btrfs-image +usr/bin/btrfs-map-logical +usr/bin/btrfs-select-super +usr/bin/btrfsck +usr/bin/btrfstune +usr/bin/fsck.btrfs +usr/bin/mkfs.btrfs +#usr/include/btrfs +#usr/include/btrfs/ctree.h +#usr/include/btrfs/ioctl.h +#usr/include/btrfs/kerncompat.h +#usr/include/btrfs/list.h +#usr/include/btrfs/rbtree.h +#usr/include/btrfs/rbtree_types.h +#usr/include/btrfs/send-stream.h +#usr/include/btrfs/send-utils.h +#usr/include/btrfs/send.h +#usr/include/btrfs/version.h +#usr/include/btrfsutil.h +#usr/lib/libbtrfs.a +#usr/lib/libbtrfs.so +usr/lib/libbtrfs.so.0 +usr/lib/libbtrfs.so.0.1 +#usr/lib/libbtrfsutil.a +#usr/lib/libbtrfsutil.so +usr/lib/libbtrfsutil.so.1 +usr/lib/libbtrfsutil.so.1.2.0 +#usr/lib/pkgconfig/libbtrfsutil.pc diff --git a/lfs/btrfs-progs b/lfs/btrfs-progs new file mode 100644 index 000000000..caf8f0b96 --- /dev/null +++ b/lfs/btrfs-progs @@ -0,0 +1,85 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 6.7.1 + +THISAPP = btrfs-progs-v$(VER) +DL_FILE = $(THISAPP).tar.xz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_BLAKE2 = 4e05e9dd80e5531425490970318389aef280f61cc636a80aa2bbc630399afd4f1f3ce649d194822ff93ff4b1774d65a504e3bed6f1426ff60830e4c0d0ac87b0 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +b2 : $(subst %,%_BLAKE2,$(objects)) + +dist: + @$(PAK) + +############################################################################### +# Downloading, checking, b2sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_BLAKE2,$(objects)) : + @$(B2SUM) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + $(UPDATE_AUTOMAKE) + cd $(DIR_APP) && ./autogen.sh + cd $(DIR_APP) && ./configure \ + --prefix=/usr \ + --disable-documentation \ + --disable-python + cd $(DIR_APP) && make $(MAKETUNING) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index 7b56b7fc8..7e3ea09d1 100755 --- a/make.sh +++ b/make.sh @@ -1711,6 +1711,7 @@ buildipfire() { lfsmake2 perl-URI-Encode lfsmake2 rsnapshot lfsmake2 mympd + lfsmake2 btrfs-progs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty
Hello,
Did you consider that our initramdisk will grow a little bit more with these tools?
You probably want to enable the btrfs module in dracut, as we currently don’t ship this:
config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/80-btrfs.rules config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/btrfs_device_ready.sh config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/btrfs_finished.sh config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/btrfs_timeout.sh config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/module-setup.sh
-Michael
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
config/rootfiles/common/btrfs-progs | 33 +++++++++++ lfs/btrfs-progs | 85 +++++++++++++++++++++++++++++ make.sh | 1 + 3 files changed, 119 insertions(+) create mode 100644 config/rootfiles/common/btrfs-progs create mode 100644 lfs/btrfs-progs
diff --git a/config/rootfiles/common/btrfs-progs b/config/rootfiles/common/btrfs-progs new file mode 100644 index 000000000..04af32d3f --- /dev/null +++ b/config/rootfiles/common/btrfs-progs @@ -0,0 +1,33 @@ +lib/udev/rules.d/64-btrfs-dm.rules +lib/udev/rules.d/64-btrfs-zoned.rules +usr/bin/btrfs +usr/bin/btrfs-convert +usr/bin/btrfs-find-root +usr/bin/btrfs-image +usr/bin/btrfs-map-logical +usr/bin/btrfs-select-super +usr/bin/btrfsck +usr/bin/btrfstune +usr/bin/fsck.btrfs +usr/bin/mkfs.btrfs +#usr/include/btrfs +#usr/include/btrfs/ctree.h +#usr/include/btrfs/ioctl.h +#usr/include/btrfs/kerncompat.h +#usr/include/btrfs/list.h +#usr/include/btrfs/rbtree.h +#usr/include/btrfs/rbtree_types.h +#usr/include/btrfs/send-stream.h +#usr/include/btrfs/send-utils.h +#usr/include/btrfs/send.h +#usr/include/btrfs/version.h +#usr/include/btrfsutil.h +#usr/lib/libbtrfs.a +#usr/lib/libbtrfs.so +usr/lib/libbtrfs.so.0 +usr/lib/libbtrfs.so.0.1 +#usr/lib/libbtrfsutil.a +#usr/lib/libbtrfsutil.so +usr/lib/libbtrfsutil.so.1 +usr/lib/libbtrfsutil.so.1.2.0 +#usr/lib/pkgconfig/libbtrfsutil.pc diff --git a/lfs/btrfs-progs b/lfs/btrfs-progs new file mode 100644 index 000000000..caf8f0b96 --- /dev/null +++ b/lfs/btrfs-progs @@ -0,0 +1,85 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +###############################################################################
+############################################################################### +# Definitions +###############################################################################
+include Config
+VER = 6.7.1
+THISAPP = btrfs-progs-v$(VER) +DL_FILE = $(THISAPP).tar.xz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)
+############################################################################### +# Top-level Rules +###############################################################################
+objects = $(DL_FILE)
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+$(DL_FILE)_BLAKE2 = 4e05e9dd80e5531425490970318389aef280f61cc636a80aa2bbc630399afd4f1f3ce649d194822ff93ff4b1774d65a504e3bed6f1426ff60830e4c0d0ac87b0
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+b2 : $(subst %,%_BLAKE2,$(objects))
+dist:
- @$(PAK)
+############################################################################### +# Downloading, checking, b2sum +###############################################################################
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
- @$(CHECK)
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
- @$(LOAD)
+$(subst %,%_BLAKE2,$(objects)) :
- @$(B2SUM)
+############################################################################### +# Installation Details +###############################################################################
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
- @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
- $(UPDATE_AUTOMAKE)
- cd $(DIR_APP) && ./autogen.sh
- cd $(DIR_APP) && ./configure \
- --prefix=/usr \
- --disable-documentation \
- --disable-python
- cd $(DIR_APP) && make $(MAKETUNING)
- cd $(DIR_APP) && make install
- @rm -rf $(DIR_APP)
- @$(POSTBUILD)
diff --git a/make.sh b/make.sh index 7b56b7fc8..7e3ea09d1 100755 --- a/make.sh +++ b/make.sh @@ -1711,6 +1711,7 @@ buildipfire() { lfsmake2 perl-URI-Encode lfsmake2 rsnapshot lfsmake2 mympd
lfsmake2 btrfs-progs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty
-- 2.39.2
Hello Michael,
thanks for pointing this out.
I forgot to commit the changes in the initramdisk, which also should contain everything btrfs related.
I also need to double check if I correctly commited the include of mkfs.btrfs in the initramdisk of the installer.
- Stefan
Hello,
Did you consider that our initramdisk will grow a little bit more with these tools?
You probably want to enable the btrfs module in dracut, as we currently don’t ship this:
config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/80- btrfs.rules config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/btrf s_device_ready.sh config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/btrf s_finished.sh config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/btrf s_timeout.sh config/rootfiles/common/dracut:#usr/lib/dracut/modules.d/90btrfs/modu le-setup.sh
-Michael
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
config/rootfiles/common/btrfs-progs | 33 +++++++++++ lfs/btrfs-progs | 85 +++++++++++++++++++++++++++++ make.sh | 1 + 3 files changed, 119 insertions(+) create mode 100644 config/rootfiles/common/btrfs-progs create mode 100644 lfs/btrfs-progs
diff --git a/config/rootfiles/common/btrfs-progs b/config/rootfiles/common/btrfs-progs new file mode 100644 index 000000000..04af32d3f --- /dev/null +++ b/config/rootfiles/common/btrfs-progs @@ -0,0 +1,33 @@ +lib/udev/rules.d/64-btrfs-dm.rules +lib/udev/rules.d/64-btrfs-zoned.rules +usr/bin/btrfs +usr/bin/btrfs-convert +usr/bin/btrfs-find-root +usr/bin/btrfs-image +usr/bin/btrfs-map-logical +usr/bin/btrfs-select-super +usr/bin/btrfsck +usr/bin/btrfstune +usr/bin/fsck.btrfs +usr/bin/mkfs.btrfs +#usr/include/btrfs +#usr/include/btrfs/ctree.h +#usr/include/btrfs/ioctl.h +#usr/include/btrfs/kerncompat.h +#usr/include/btrfs/list.h +#usr/include/btrfs/rbtree.h +#usr/include/btrfs/rbtree_types.h +#usr/include/btrfs/send-stream.h +#usr/include/btrfs/send-utils.h +#usr/include/btrfs/send.h +#usr/include/btrfs/version.h +#usr/include/btrfsutil.h +#usr/lib/libbtrfs.a +#usr/lib/libbtrfs.so +usr/lib/libbtrfs.so.0 +usr/lib/libbtrfs.so.0.1 +#usr/lib/libbtrfsutil.a +#usr/lib/libbtrfsutil.so +usr/lib/libbtrfsutil.so.1 +usr/lib/libbtrfsutil.so.1.2.0 +#usr/lib/pkgconfig/libbtrfsutil.pc diff --git a/lfs/btrfs-progs b/lfs/btrfs-progs new file mode 100644 index 000000000..caf8f0b96 --- /dev/null +++ b/lfs/btrfs-progs @@ -0,0 +1,85 @@ +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+################################################################## ############# +# Definitions +################################################################## #############
+include Config
+VER = 6.7.1
+THISAPP = btrfs-progs-v$(VER) +DL_FILE = $(THISAPP).tar.xz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)
+################################################################## ############# +# Top-level Rules +################################################################## #############
+objects = $(DL_FILE)
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+$(DL_FILE)_BLAKE2 = 4e05e9dd80e5531425490970318389aef280f61cc636a80aa2bbc630399afd4f1f3 ce649d194822ff93ff4b1774d65a504e3bed6f1426ff60830e4c0d0ac87b0
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+b2 : $(subst %,%_BLAKE2,$(objects))
+dist:
- @$(PAK)
+################################################################## ############# +# Downloading, checking, b2sum +################################################################## #############
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
- @$(CHECK)
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
- @$(LOAD)
+$(subst %,%_BLAKE2,$(objects)) :
- @$(B2SUM)
+################################################################## ############# +# Installation Details +################################################################## #############
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
- @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf
$(DIR_DL)/$(DL_FILE)
- $(UPDATE_AUTOMAKE)
- cd $(DIR_APP) && ./autogen.sh
- cd $(DIR_APP) && ./configure \
- --prefix=/usr \
- --disable-documentation \
- --disable-python
- cd $(DIR_APP) && make $(MAKETUNING)
- cd $(DIR_APP) && make install
- @rm -rf $(DIR_APP)
- @$(POSTBUILD)
diff --git a/make.sh b/make.sh index 7b56b7fc8..7e3ea09d1 100755 --- a/make.sh +++ b/make.sh @@ -1711,6 +1711,7 @@ buildipfire() { lfsmake2 perl-URI-Encode lfsmake2 rsnapshot lfsmake2 mympd + lfsmake2 btrfs-progs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty -- 2.39.2
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/dracut-module/module-setup.sh | 4 ++-- src/installer/hw.c | 8 ++++++++ src/installer/hw.h | 1 + src/installer/main.c | 1 + 4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/installer/dracut-module/module-setup.sh b/src/installer/dracut-module/module-setup.sh index 26a257cf8..09564f885 100755 --- a/src/installer/dracut-module/module-setup.sh +++ b/src/installer/dracut-module/module-setup.sh @@ -30,8 +30,8 @@ install() { instmods virtio_net hv_netvsc vmxnet3
# Filesystem support - inst_multiple parted mkswap mke2fs mkfs.xfs mkfs.vfat - instmods ext4 iso9660 vfat xfs ntfs3 + inst_multiple parted mkswap mke2fs mkfs.xfs mkfs.vfat mkfs.btrfs + instmods ext4 iso9660 vfat xfs ntfs3 btrfs
# Extraction inst_multiple tar gzip zstd diff --git a/src/installer/hw.c b/src/installer/hw.c index 894b887d9..a196bf8be 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -822,6 +822,10 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) { } else if (fs == HW_FS_XFS) { snprintf(cmd, sizeof(cmd), "/sbin/mkfs.xfs -f %s", path);
+ // BTRFS + } else if (fs == HW_FS_BTRFS) { + snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L rootfs -f %s", path); + // FAT32 } else if (fs == HW_FS_FAT32) { snprintf(cmd, sizeof(cmd), "/sbin/mkfs.vfat %s", path); @@ -882,6 +886,10 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { filesystem = "xfs"; break;
+ case HW_FS_BTRFS: + filesystem = "btrfs"; + break; + case HW_FS_FAT32: filesystem = "vfat"; break; diff --git a/src/installer/hw.h b/src/installer/hw.h index 6a7f23aa7..e5ee65a6d 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -46,6 +46,7 @@ #define HW_FS_EXT4_WO_JOURNAL 2 #define HW_FS_XFS 3 #define HW_FS_FAT32 4 +#define HW_FS_BTRFS 5
#define HW_FS_DEFAULT HW_FS_EXT4
diff --git a/src/installer/main.c b/src/installer/main.c index cddb0d91a..b3c9d27ee 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -720,6 +720,7 @@ int main(int argc, char *argv[]) { { HW_FS_EXT4, _("ext4 Filesystem") }, { HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") }, { HW_FS_XFS, _("XFS Filesystem") }, + { HW_FS_BTRFS, _("BTRFS Filesystem") }, { 0, NULL }, }; unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems);
Hello,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/dracut-module/module-setup.sh | 4 ++-- src/installer/hw.c | 8 ++++++++ src/installer/hw.h | 1 + src/installer/main.c | 1 + 4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/installer/dracut-module/module-setup.sh b/src/installer/dracut-module/module-setup.sh index 26a257cf8..09564f885 100755 --- a/src/installer/dracut-module/module-setup.sh +++ b/src/installer/dracut-module/module-setup.sh @@ -30,8 +30,8 @@ install() { instmods virtio_net hv_netvsc vmxnet3
# Filesystem support
- inst_multiple parted mkswap mke2fs mkfs.xfs mkfs.vfat
- instmods ext4 iso9660 vfat xfs ntfs3
inst_multiple parted mkswap mke2fs mkfs.xfs mkfs.vfat mkfs.btrfs
instmods ext4 iso9660 vfat xfs ntfs3 btrfs
# Extraction inst_multiple tar gzip zstd
diff --git a/src/installer/hw.c b/src/installer/hw.c index 894b887d9..a196bf8be 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -822,6 +822,10 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) { } else if (fs == HW_FS_XFS) { snprintf(cmd, sizeof(cmd), "/sbin/mkfs.xfs -f %s", path);
- // BTRFS
- } else if (fs == HW_FS_BTRFS) {
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L rootfs -f %s", path);
Is this label required here? The other filesystems don’t use a label.
// FAT32 } else if (fs == HW_FS_FAT32) { snprintf(cmd, sizeof(cmd), "/sbin/mkfs.vfat %s", path); @@ -882,6 +886,10 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { filesystem = "xfs"; break;
- case HW_FS_BTRFS:
- filesystem = "btrfs";
- break;
case HW_FS_FAT32: filesystem = "vfat"; break; diff --git a/src/installer/hw.h b/src/installer/hw.h index 6a7f23aa7..e5ee65a6d 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -46,6 +46,7 @@ #define HW_FS_EXT4_WO_JOURNAL 2 #define HW_FS_XFS 3 #define HW_FS_FAT32 4 +#define HW_FS_BTRFS 5
#define HW_FS_DEFAULT HW_FS_EXT4
diff --git a/src/installer/main.c b/src/installer/main.c index cddb0d91a..b3c9d27ee 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -720,6 +720,7 @@ int main(int argc, char *argv[]) { { HW_FS_EXT4, _("ext4 Filesystem") }, { HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") }, { HW_FS_XFS, _("XFS Filesystem") },
- { HW_FS_BTRFS, _("BTRFS Filesystem") },
Can we please add an “(EXPERIMENTAL)” here to signal to users that this is currently an experimental feature?
{ 0, NULL }, }; unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems); -- 2.39.2
Ensure to always create the /boot directory during the mounting of the various created file systems. If the /boot directory does not exist some following mount operations could not be performed correctly and the installation/mounting will fail.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index a196bf8be..b9ed92459 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -904,10 +904,16 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { return r;
// boot - if (*dest->part_boot) { - snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT); - mkdir(target, S_IRWXU|S_IRWXG|S_IRWXO); + snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT); + r = mkdir(target, S_IRWXU|S_IRWXG|S_IRWXO); + + if (r) { + hw_umount_filesystems(dest, prefix);
+ return r; + } + + if (*dest->part_boot) { r = hw_mount(dest->part_boot, target, filesystem, 0); if (r) { hw_umount_filesystems(dest, prefix);
This will merge /boot and / to be on the same partition.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index b9ed92459..81be87471 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -490,7 +490,7 @@ static unsigned long long hw_swap_size(struct hw_destination* dest) { }
static unsigned long long hw_boot_size(struct hw_destination* dest) { - return MB2BYTES(512); + return 0; }
static int hw_device_has_p_suffix(const struct hw_destination* dest) {
Can we have Arne sign off on this?
We could in theory only disable the /boot partition when people have selected btrfs.
The flash image will keep a /boot partition and I don’t like this kind of inconsistencies between different installation types.
-Michael
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
This will merge /boot and / to be on the same partition.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index b9ed92459..81be87471 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -490,7 +490,7 @@ static unsigned long long hw_swap_size(struct hw_destination* dest) { }
static unsigned long long hw_boot_size(struct hw_destination* dest) {
- return MB2BYTES(512);
- return 0;
}
static int hw_device_has_p_suffix(const struct hw_destination* dest) {
2.39.2
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-- src/installer/hw.h | 5 ++++ 2 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 81be87471..420feaca7 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -44,6 +44,20 @@
#include "hw.h"
+// Array which contains the subvolumes which will be created when installing +// IPFire on a BTRFS. +const char* btrfs_subvolumes[7][2] = { + {"@root" ,"/"}, + {"@snapshots", "/.snapshots"}, + {"@home", "/home"}, + {"@cache", "/var/cache"}, + {"@lib", "/var/lib"}, + {"@logs", "/var/log"}, + {"@mails", "/var/mail"} +}; + +#define LEN(arr) ((int) (sizeof (arr) / sizeof (arr)[0])) + static int system_chroot(const char* output, const char* path, const char* cmd) { char chroot_cmd[STRING_SIZE];
@@ -805,6 +819,7 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) {
static int hw_format_filesystem(const char* path, int fs, const char* output) { char cmd[STRING_SIZE] = "\0"; + int r;
// Swap if (fs == HW_FS_SWAP) { @@ -824,7 +839,9 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
// BTRFS } else if (fs == HW_FS_BTRFS) { - snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L rootfs -f %s", path); + r = hw_create_btrfs_layout(path, output); + + return r;
// FAT32 } else if (fs == HW_FS_FAT32) { @@ -833,7 +850,7 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
assert(*cmd);
- int r = mysystem(output, cmd); + r = mysystem(output, cmd);
return r; } @@ -870,6 +887,43 @@ int hw_create_filesystems(struct hw_destination* dest, const char* output) { return 0; }
+int hw_create_btrfs_layout(const char* path, const char* output) { + char cmd[STRING_SIZE]; + char subvolume[STRING_SIZE]; + + // Create the main BTRFS. + snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L IPFire -f %s", path); + int r = mysystem(output, cmd); + + if (r) + return r; + + // We need to mount the FS in order to create any subvolumes. + r = hw_mount(path, DESTINATION_MOUNT_PATH, "btrfs", 0); + + if (r) + return r; + + // Loop through the array of subvolumes to create. + for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) { + snprintf(subvolume, sizeof(subvolume), "%s", btrfs_subvolumes[i][0]); + + // Call function to create the subvolume + r = hw_create_btrfs_subvolume(output, subvolume); + + if (r) + return r; + } + + // Umount the main BTRFS after subvolume creation. + r = hw_umount(path, 0); + + if (r) + return r; + + return 0; +} + int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE];
@@ -1219,3 +1273,15 @@ int hw_restore_backup(const char* output, const char* backup_path, const char* d
return 0; } + +int hw_create_btrfs_subvolume(const char* output, const char* subvolume) { + char command [STRING_SIZE]; + snprintf(command, sizeof(command), "/usr/bin/btrfs subvolume create %s/%s", DESTINATION_MOUNT_PATH, subvolume); + + int r = mysystem(output, command); + + if (r) + return -1; + + return 0; +} diff --git a/src/installer/hw.h b/src/installer/hw.h index e5ee65a6d..2de73a3be 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -104,6 +104,8 @@ struct hw_destination { unsigned long long size_root; };
+extern const char* btrfs_subvolumes[][2]; + struct hw* hw_init(); void hw_free(struct hw* hw);
@@ -143,4 +145,7 @@ int hw_start_networking(const char* output);
void hw_sync();
+int hw_create_btrfs_layout(const char* output, const char* subvolume); +int hw_create_btrfs_subvolume(const char* output, const char* subvolume); + #endif /* HEADER_HW_H */
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-- src/installer/hw.h | 5 ++++ 2 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 81be87471..420feaca7 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -44,6 +44,20 @@
#include "hw.h"
+// Array which contains the subvolumes which will be created when installing +// IPFire on a BTRFS. +const char* btrfs_subvolumes[7][2] = {
- {"@root" ,"/"},
- {"@snapshots", "/.snapshots"},
- {"@home", "/home"},
- {"@cache", "/var/cache"},
- {"@lib", "/var/lib"},
- {"@logs", "/var/log"},
- {"@mails", "/var/mail"}
+};
I would prefer to not allocate these arrays to a specific size. You leave the square brackets empty and the compiler will figure out how much space it needs. That avoids any problems when something is being added later.
You should also NULL-terminate the array.
+#define LEN(arr) ((int) (sizeof (arr) / sizeof (arr)[0]))
static int system_chroot(const char* output, const char* path, const char* cmd) { char chroot_cmd[STRING_SIZE];
@@ -805,6 +819,7 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) {
static int hw_format_filesystem(const char* path, int fs, const char* output) { char cmd[STRING_SIZE] = "\0";
- int r;
// Swap if (fs == HW_FS_SWAP) { @@ -824,7 +839,9 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
// BTRFS } else if (fs == HW_FS_BTRFS) {
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L rootfs -f %s", path);
- r = hw_create_btrfs_layout(path, output);
- return r;
// FAT32 } else if (fs == HW_FS_FAT32) { @@ -833,7 +850,7 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
assert(*cmd);
- int r = mysystem(output, cmd);
- r = mysystem(output, cmd);
return r; } @@ -870,6 +887,43 @@ int hw_create_filesystems(struct hw_destination* dest, const char* output) { return 0; }
+int hw_create_btrfs_layout(const char* path, const char* output) {
- char cmd[STRING_SIZE];
- char subvolume[STRING_SIZE];
- // Create the main BTRFS.
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L IPFire -f %s", path);
Again, you are using a label here. Is that a requirement?
- int r = mysystem(output, cmd);
- if (r)
- return r;
- // We need to mount the FS in order to create any subvolumes.
- r = hw_mount(path, DESTINATION_MOUNT_PATH, "btrfs", 0);
- if (r)
- return r;
- // Loop through the array of subvolumes to create.
- for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) {
If you NULL-terminate your array, you won’t need the LEN() macro which I personally don’t consider good style.
- snprintf(subvolume, sizeof(subvolume), "%s", btrfs_subvolumes[i][0]);
I know that the installer isn’t doing that very much, but you should check the return code of snprintf().
- // Call function to create the subvolume
- r = hw_create_btrfs_subvolume(output, subvolume);
- if (r)
- return r;
- }
- // Umount the main BTRFS after subvolume creation.
- r = hw_umount(path, 0);
- if (r)
- return r;
- return 0;
+}
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE];
@@ -1219,3 +1273,15 @@ int hw_restore_backup(const char* output, const char* backup_path, const char* d
return 0; }
+int hw_create_btrfs_subvolume(const char* output, const char* subvolume) {
- char command [STRING_SIZE];
- snprintf(command, sizeof(command), "/usr/bin/btrfs subvolume create %s/%s", DESTINATION_MOUNT_PATH, subvolume);
Likewise.
- int r = mysystem(output, command);
- if (r)
- return -1;
- return 0;
+} diff --git a/src/installer/hw.h b/src/installer/hw.h index e5ee65a6d..2de73a3be 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -104,6 +104,8 @@ struct hw_destination { unsigned long long size_root; };
+extern const char* btrfs_subvolumes[][2];
Please declare the array statically and you won’t need this.
struct hw* hw_init(); void hw_free(struct hw* hw);
@@ -143,4 +145,7 @@ int hw_start_networking(const char* output);
void hw_sync();
+int hw_create_btrfs_layout(const char* output, const char* subvolume); +int hw_create_btrfs_subvolume(const char* output, const char* subvolume);
#endif /* HEADER_HW_H */
2.39.2
Hello,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-- src/installer/hw.h | 5 ++++ 2 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 81be87471..420feaca7 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -44,6 +44,20 @@
#include "hw.h"
+// Array which contains the subvolumes which will be created when installing +// IPFire on a BTRFS. +const char* btrfs_subvolumes[7][2] = {
- {"@root" ,"/"},
- {"@snapshots", "/.snapshots"},
- {"@home", "/home"},
- {"@cache", "/var/cache"},
- {"@lib", "/var/lib"},
- {"@logs", "/var/log"},
- {"@mails", "/var/mail"}
+};
I would prefer to not allocate these arrays to a specific size. You leave the square brackets empty and the compiler will figure out how much space it needs. That avoids any problems when something is being added later.
You should also NULL-terminate the array.
Thanks for the hint, I'll adjust the code to use it in this way.
+#define LEN(arr) ((int) (sizeof (arr) / sizeof (arr)[0]))
static int system_chroot(const char* output, const char* path, const char* cmd) { char chroot_cmd[STRING_SIZE];
@@ -805,6 +819,7 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) {
static int hw_format_filesystem(const char* path, int fs, const char* output) { char cmd[STRING_SIZE] = "\0";
- int r;
// Swap if (fs == HW_FS_SWAP) { @@ -824,7 +839,9 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
// BTRFS } else if (fs == HW_FS_BTRFS) {
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L rootfs -f %s",
path);
- r = hw_create_btrfs_layout(path, output);
- return r;
// FAT32 } else if (fs == HW_FS_FAT32) { @@ -833,7 +850,7 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
assert(*cmd);
- int r = mysystem(output, cmd);
- r = mysystem(output, cmd);
return r; } @@ -870,6 +887,43 @@ int hw_create_filesystems(struct hw_destination* dest, const char* output) { return 0; }
+int hw_create_btrfs_layout(const char* path, const char* output) {
- char cmd[STRING_SIZE];
- char subvolume[STRING_SIZE];
- // Create the main BTRFS.
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L IPFire -f %s",
path);
Again, you are using a label here. Is that a requirement?
There is not a strict requirement on using a label. I added one as some kind of nice to have to indicate the main IPFire file system.
As it is optional I also can drop the label, your opinion?
- int r = mysystem(output, cmd);
- if (r)
- return r;
- // We need to mount the FS in order to create any subvolumes.
- r = hw_mount(path, DESTINATION_MOUNT_PATH, "btrfs", 0);
- if (r)
- return r;
- // Loop through the array of subvolumes to create.
- for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) {
If you NULL-terminate your array, you won’t need the LEN() macro which I personally don’t consider good style.
- snprintf(subvolume, sizeof(subvolume), "%s",
btrfs_subvolumes[i][0]);
I know that the installer isn’t doing that very much, but you should check the return code of snprintf().
Thanks I'll add some checking code.
- // Call function to create the subvolume
- r = hw_create_btrfs_subvolume(output, subvolume);
- if (r)
- return r;
- }
- // Umount the main BTRFS after subvolume creation.
- r = hw_umount(path, 0);
- if (r)
- return r;
- return 0;
+}
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE];
@@ -1219,3 +1273,15 @@ int hw_restore_backup(const char* output, const char* backup_path, const char* d
return 0; }
+int hw_create_btrfs_subvolume(const char* output, const char* subvolume) {
- char command [STRING_SIZE];
- snprintf(command, sizeof(command), "/usr/bin/btrfs subvolume
create %s/%s", DESTINATION_MOUNT_PATH, subvolume);
Likewise.
- int r = mysystem(output, command);
- if (r)
- return -1;
- return 0;
+} diff --git a/src/installer/hw.h b/src/installer/hw.h index e5ee65a6d..2de73a3be 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -104,6 +104,8 @@ struct hw_destination { unsigned long long size_root; };
+extern const char* btrfs_subvolumes[][2];
Please declare the array statically and you won’t need this.
struct hw* hw_init(); void hw_free(struct hw* hw);
@@ -143,4 +145,7 @@ int hw_start_networking(const char* output);
void hw_sync();
+int hw_create_btrfs_layout(const char* output, const char* subvolume); +int hw_create_btrfs_subvolume(const char* output, const char* subvolume);
#endif /* HEADER_HW_H */
2.39.2
- Stefan
On 19 Mar 2024, at 20:05, Stefan Schantl stefan.schantl@ipfire.org wrote:
Hello,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-- src/installer/hw.h | 5 ++++ 2 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 81be87471..420feaca7 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -44,6 +44,20 @@
#include "hw.h"
+// Array which contains the subvolumes which will be created when installing +// IPFire on a BTRFS. +const char* btrfs_subvolumes[7][2] = {
- {"@root" ,"/"},
- {"@snapshots", "/.snapshots"},
- {"@home", "/home"},
- {"@cache", "/var/cache"},
- {"@lib", "/var/lib"},
- {"@logs", "/var/log"},
- {"@mails", "/var/mail"}
+};
I would prefer to not allocate these arrays to a specific size. You leave the square brackets empty and the compiler will figure out how much space it needs. That avoids any problems when something is being added later.
You should also NULL-terminate the array.
Thanks for the hint, I'll adjust the code to use it in this way.
+#define LEN(arr) ((int) (sizeof (arr) / sizeof (arr)[0]))
static int system_chroot(const char* output, const char* path, const char* cmd) { char chroot_cmd[STRING_SIZE];
@@ -805,6 +819,7 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) {
static int hw_format_filesystem(const char* path, int fs, const char* output) { char cmd[STRING_SIZE] = "\0";
- int r;
// Swap if (fs == HW_FS_SWAP) { @@ -824,7 +839,9 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
// BTRFS } else if (fs == HW_FS_BTRFS) {
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L rootfs -f %s",
path);
- r = hw_create_btrfs_layout(path, output);
- return r;
// FAT32 } else if (fs == HW_FS_FAT32) { @@ -833,7 +850,7 @@ static int hw_format_filesystem(const char* path, int fs, const char* output) {
assert(*cmd);
- int r = mysystem(output, cmd);
- r = mysystem(output, cmd);
return r; } @@ -870,6 +887,43 @@ int hw_create_filesystems(struct hw_destination* dest, const char* output) { return 0; }
+int hw_create_btrfs_layout(const char* path, const char* output) {
- char cmd[STRING_SIZE];
- char subvolume[STRING_SIZE];
- // Create the main BTRFS.
- snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -L IPFire -f %s",
path);
Again, you are using a label here. Is that a requirement?
There is not a strict requirement on using a label. I added one as some kind of nice to have to indicate the main IPFire file system.
As it is optional I also can drop the label, your opinion?
I would like to keep it consistent. Either remove it from btrfs, or add it to the others.
Since it is not serving any purpose I would rather remove it.
- int r = mysystem(output, cmd);
- if (r)
- return r;
- // We need to mount the FS in order to create any subvolumes.
- r = hw_mount(path, DESTINATION_MOUNT_PATH, "btrfs", 0);
- if (r)
- return r;
- // Loop through the array of subvolumes to create.
- for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) {
If you NULL-terminate your array, you won’t need the LEN() macro which I personally don’t consider good style.
- snprintf(subvolume, sizeof(subvolume), "%s",
btrfs_subvolumes[i][0]);
I know that the installer isn’t doing that very much, but you should check the return code of snprintf().
Thanks I'll add some checking code.
- // Call function to create the subvolume
- r = hw_create_btrfs_subvolume(output, subvolume);
- if (r)
- return r;
- }
- // Umount the main BTRFS after subvolume creation.
- r = hw_umount(path, 0);
- if (r)
- return r;
- return 0;
+}
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE];
@@ -1219,3 +1273,15 @@ int hw_restore_backup(const char* output, const char* backup_path, const char* d
return 0; }
+int hw_create_btrfs_subvolume(const char* output, const char* subvolume) {
- char command [STRING_SIZE];
- snprintf(command, sizeof(command), "/usr/bin/btrfs subvolume
create %s/%s", DESTINATION_MOUNT_PATH, subvolume);
Likewise.
- int r = mysystem(output, command);
- if (r)
- return -1;
- return 0;
+} diff --git a/src/installer/hw.h b/src/installer/hw.h index e5ee65a6d..2de73a3be 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -104,6 +104,8 @@ struct hw_destination { unsigned long long size_root; };
+extern const char* btrfs_subvolumes[][2];
Please declare the array statically and you won’t need this.
struct hw* hw_init(); void hw_free(struct hw* hw);
@@ -143,4 +145,7 @@ int hw_start_networking(const char* output);
void hw_sync();
+int hw_create_btrfs_layout(const char* output, const char* subvolume); +int hw_create_btrfs_subvolume(const char* output, const char* subvolume);
#endif /* HEADER_HW_H */
2.39.2
- Stefan
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 420feaca7..205d40d21 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -916,7 +916,7 @@ int hw_create_btrfs_layout(const char* path, const char* output) { }
// Umount the main BTRFS after subvolume creation. - r = hw_umount(path, 0); + r = hw_umount(DESTINATION_MOUNT_PATH, 0);
if (r) return r;
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 205d40d21..cb6a8ab81 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1274,6 +1274,49 @@ int hw_restore_backup(const char* output, const char* backup_path, const char* d return 0; }
+int hw_mkdir(const char *dir) { + char tmp[STRING_SIZE]; + char *p = NULL; + size_t len; + int r; + + snprintf(tmp, sizeof(tmp),"%s",dir); + len = strlen(tmp); + + if (tmp[len - 1] == '/') { + tmp[len - 1] = 0; + } + + for (p = tmp + 1; *p; p++) { + if (*p == '/') { + *p = 0; + + // Create target if it does not exist + if (access(tmp, X_OK) != 0) { + r = mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO); + + if (r) { + return r; + } + } + + *p = '/'; + } + } + + // Create target if it does not exist + if (access(tmp, X_OK) != 0) { + r = mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO); + + if (r) { + return r; + } + } + + return 0; +} + + int hw_create_btrfs_subvolume(const char* output, const char* subvolume) { char command [STRING_SIZE]; snprintf(command, sizeof(command), "/usr/bin/btrfs subvolume create %s/%s", DESTINATION_MOUNT_PATH, subvolume);
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index cb6a8ab81..e520fb687 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -926,6 +926,7 @@ int hw_create_btrfs_layout(const char* path, const char* output) {
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE]; + int r;
assert(*prefix == '/');
@@ -953,9 +954,17 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { }
// root - int r = hw_mount(dest->part_root, prefix, filesystem, 0); - if (r) - return r; + if (dest->filesystem == HW_FS_BTRFS) { + r = hw_mount_btrfs_subvolumes(dest->part_root); + + if (r) + return r; + } else { + r = hw_mount(dest->part_root, prefix, filesystem, 0); + + if (r) + return r; + }
// boot snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT); @@ -1019,6 +1028,39 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { return 0; }
+int hw_mount_btrfs_subvolumes(const char* source) { + int r; + char path[STRING_SIZE]; + char options[STRING_SIZE]; + + // Mount the root subvolume + snprintf(options, sizeof(options), "subvol=%s,%s", btrfs_subvolumes[0][0], BTRFS_MOUNT_OPTIONS); + r = mount(source, DESTINATION_MOUNT_PATH, "btrfs", NULL, options); + + if (r) + return r; + + // Loop through the remain array of known subvolumes. + for ( int i = 1; i < LEN(btrfs_subvolumes); i++ ) { + snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, btrfs_subvolumes[i][1]); + snprintf(options, sizeof(options), "subvol=%s,", btrfs_subvolumes[i][0], BTRFS_MOUNT_OPTIONS); + + // Create the directory. + r = hw_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO); + + if(r != 0 && errno != EEXIST) + return r; + + // Try to mount the subvolume. + r = mount(source, path, "btrfs", NULL, options); + + if (r) + return r; + } + + return 0; +} + int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) { int r; char target[STRING_SIZE];
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.c | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index cb6a8ab81..e520fb687 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -926,6 +926,7 @@ int hw_create_btrfs_layout(const char* path, const char* output) {
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE];
- int r;
assert(*prefix == '/');
@@ -953,9 +954,17 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { }
// root
- int r = hw_mount(dest->part_root, prefix, filesystem, 0);
- if (r)
- return r;
- if (dest->filesystem == HW_FS_BTRFS) {
- r = hw_mount_btrfs_subvolumes(dest->part_root);
- if (r)
- return r;
- } else {
- r = hw_mount(dest->part_root, prefix, filesystem, 0);
- if (r)
- return r;
- }
// boot snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT); @@ -1019,6 +1028,39 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { return 0; }
+int hw_mount_btrfs_subvolumes(const char* source) {
- int r;
- char path[STRING_SIZE];
- char options[STRING_SIZE];
- // Mount the root subvolume
- snprintf(options, sizeof(options), "subvol=%s,%s", btrfs_subvolumes[0][0], BTRFS_MOUNT_OPTIONS);
- r = mount(source, DESTINATION_MOUNT_PATH, "btrfs", NULL, options);
Why is this not inside the loop when it is just a regular subvolume?
- if (r)
- return r;
- // Loop through the remain array of known subvolumes.
- for ( int i = 1; i < LEN(btrfs_subvolumes); i++ ) {
- snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, btrfs_subvolumes[i][1]);
- snprintf(options, sizeof(options), "subvol=%s,", btrfs_subvolumes[i][0], BTRFS_MOUNT_OPTIONS);
Likewise, please check the return code of snprintf.
- // Create the directory.
- r = hw_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO);
- if(r != 0 && errno != EEXIST)
- return r;
- // Try to mount the subvolume.
- r = mount(source, path, "btrfs", NULL, options);
- if (r)
- return r;
- }
- return 0;
+}
int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) { int r; char target[STRING_SIZE]; -- 2.39.2
Am Montag, dem 18.03.2024 um 16:11 +0000 schrieb Michael Tremer:
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.c | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index cb6a8ab81..e520fb687 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -926,6 +926,7 @@ int hw_create_btrfs_layout(const char* path, const char* output) {
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE];
- int r;
assert(*prefix == '/');
@@ -953,9 +954,17 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { }
// root
- int r = hw_mount(dest->part_root, prefix, filesystem, 0);
- if (r)
- return r;
- if (dest->filesystem == HW_FS_BTRFS) {
- r = hw_mount_btrfs_subvolumes(dest->part_root);
- if (r)
- return r;
- } else {
- r = hw_mount(dest->part_root, prefix, filesystem, 0);
- if (r)
- return r;
- }
// boot snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT); @@ -1019,6 +1028,39 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { return 0; }
+int hw_mount_btrfs_subvolumes(const char* source) {
- int r;
- char path[STRING_SIZE];
- char options[STRING_SIZE];
- // Mount the root subvolume
- snprintf(options, sizeof(options), "subvol=%s,%s",
btrfs_subvolumes[0][0], BTRFS_MOUNT_OPTIONS);
- r = mount(source, DESTINATION_MOUNT_PATH, "btrfs", NULL,
options);
Why is this not inside the loop when it is just a regular subvolume?
I think my intention, was to be sure that the main root is always mounted before mounting the remaining subvolumes. But as you pointed out the first subvolume in the array would be the root one, so this is some kind of over-engineered and can be joined together.
- if (r)
- return r;
- // Loop through the remain array of known subvolumes.
- for ( int i = 1; i < LEN(btrfs_subvolumes); i++ ) {
- snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH,
btrfs_subvolumes[i][1]);
- snprintf(options, sizeof(options), "subvol=%s,",
btrfs_subvolumes[i][0], BTRFS_MOUNT_OPTIONS);
Likewise, please check the return code of snprintf.
- // Create the directory.
- r = hw_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO);
- if(r != 0 && errno != EEXIST)
- return r;
- // Try to mount the subvolume.
- r = mount(source, path, "btrfs", NULL, options);
- if (r)
- return r;
- }
- return 0;
+}
int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) { int r; char target[STRING_SIZE]; -- 2.39.2
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index e520fb687..7868cbb23 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -46,14 +46,15 @@
// Array which contains the subvolumes which will be created when installing // IPFire on a BTRFS. -const char* btrfs_subvolumes[7][2] = { +const char* btrfs_subvolumes[8][2] = { {"@root" ,"/"}, {"@snapshots", "/.snapshots"}, {"@home", "/home"}, {"@cache", "/var/cache"}, {"@lib", "/var/lib"}, {"@logs", "/var/log"}, - {"@mails", "/var/mail"} + {"@mails", "/var/mail"}, + {"@tmp", "/var/tmp"} };
#define LEN(arr) ((int) (sizeof (arr) / sizeof (arr)[0]))
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 7868cbb23..1c4adc24b 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1044,7 +1044,7 @@ int hw_mount_btrfs_subvolumes(const char* source) { // Loop through the remain array of known subvolumes. for ( int i = 1; i < LEN(btrfs_subvolumes); i++ ) { snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, btrfs_subvolumes[i][1]); - snprintf(options, sizeof(options), "subvol=%s,", btrfs_subvolumes[i][0], BTRFS_MOUNT_OPTIONS); + snprintf(options, sizeof(options), "subvol=%s,%s", btrfs_subvolumes[i][0], BTRFS_MOUNT_OPTIONS);
// Create the directory. r = hw_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO);
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 1c4adc24b..b5b853e92 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1106,13 +1106,36 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) { return -1;
// root - r = hw_umount(prefix, NULL); + if(dest->filesystem == HW_FS_BTRFS) { + r = hw_umount_btrfs_layout(); + } else { + r = hw_umount(prefix, NULL); + } + if (r) return -1;
return 0; }
+int hw_umount_btrfs_layout() { + char path[STRING_SIZE]; + int r; + + // Reverse loop through the array of known subvolumes. + for ( int i = LEN(btrfs_subvolumes); i >= 0; i-- ) { + snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, btrfs_subvolumes[i][1]); + + // umount the subvolume. + r = hw_umount(path, NULL); + + if (r) + return r; + } + + return 0; +} + int hw_destroy_raid_superblocks(const struct hw_destination* dest, const char* output) { char cmd[STRING_SIZE];
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index b5b853e92..26c473e9c 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1260,6 +1260,7 @@ int hw_write_fstab(struct hw_destination* dest) { return -1;
char* uuid = NULL; + char mount_options[STRING_SIZE];
// boot if (*dest->part_boot) { @@ -1295,7 +1296,16 @@ int hw_write_fstab(struct hw_destination* dest) { // root uuid = hw_get_uuid(dest->part_root); if (uuid) { - fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + if(dest->filesystem == HW_FS_BTRFS) { + // Loop through the array of known BTRFS subvolumes + for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) { + snprintf(mount_options, sizeof(mount_options), "defaults,%s,subvol=%s", BTRFS_MOUNT_OPTIONS, btrfs_subvolumes[i][0]); + fprintf(f, FSTAB_FMT, uuid, btrfs_subvolumes[i][1], "btrfs", mount_options, 1, 1); + } + } else { + fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + } + free(uuid); }
As default we are using zstd for compression with level 1
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/installer/hw.h b/src/installer/hw.h index 2de73a3be..402e5cd0d 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -54,6 +54,8 @@
#define SERIAL_BAUDRATE 115200
+#define BTRFS_MOUNT_OPTIONS "compress=zstd:1" + #define BYTES2MB(x) ((x) / 1024 / 1024) #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024)
Hello,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
As default we are using zstd for compression with level 1
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/installer/hw.h b/src/installer/hw.h index 2de73a3be..402e5cd0d 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -54,6 +54,8 @@
#define SERIAL_BAUDRATE 115200
+#define BTRFS_MOUNT_OPTIONS "compress=zstd:1"
Is there no way to configure this in the filesystem when it is being created to be used as default?
I think it would be nicer to have a less busy /etc/fstab.
#define BYTES2MB(x) ((x) / 1024 / 1024) #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024)
-- 2.39.2
Am Montag, dem 18.03.2024 um 16:13 +0000 schrieb Michael Tremer:
Hello,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
As default we are using zstd for compression with level 1
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/installer/hw.h b/src/installer/hw.h index 2de73a3be..402e5cd0d 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -54,6 +54,8 @@
#define SERIAL_BAUDRATE 115200
+#define BTRFS_MOUNT_OPTIONS "compress=zstd:1"
Is there no way to configure this in the filesystem when it is being created to be used as default?
SBTRFS provides the freedom to the user to tell which kind of compression, the used algorithm and the compression ration should be used by specifying this at mount time.
It also would be possible to change this at any later time by just change the mount option. (This only would affect newly created files.)
So yes, it is possible to start with zstd, switch over to xz, gz and finally uncompressed data on the same volume.
Reading through the BTRFS documentation, there is no option to persistant set the compression details.
https://btrfs.readthedocs.io/en/latest/Compression.html
I think it would be nicer to have a less busy /etc/fstab.
If I did not miss anything while reading the docs, we have to live with this or disable compression.
#define BYTES2MB(x) ((x) / 1024 / 1024) #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024)
-- 2.39.2
Thought so. In that case, let’s rather have compression enabled.
On 19 Mar 2024, at 20:19, Stefan Schantl stefan.schantl@ipfire.org wrote:
Am Montag, dem 18.03.2024 um 16:13 +0000 schrieb Michael Tremer:
Hello,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
As default we are using zstd for compression with level 1
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/hw.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/installer/hw.h b/src/installer/hw.h index 2de73a3be..402e5cd0d 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -54,6 +54,8 @@
#define SERIAL_BAUDRATE 115200
+#define BTRFS_MOUNT_OPTIONS "compress=zstd:1"
Is there no way to configure this in the filesystem when it is being created to be used as default?
SBTRFS provides the freedom to the user to tell which kind of compression, the used algorithm and the compression ration should be used by specifying this at mount time.
It also would be possible to change this at any later time by just change the mount option. (This only would affect newly created files.)
So yes, it is possible to start with zstd, switch over to xz, gz and finally uncompressed data on the same volume.
Reading through the BTRFS documentation, there is no option to persistant set the compression details.
https://btrfs.readthedocs.io/en/latest/Compression.html
I think it would be nicer to have a less busy /etc/fstab.
If I did not miss anything while reading the docs, we have to live with this or disable compression.
#define BYTES2MB(x) ((x) / 1024 / 1024) #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024)
-- 2.39.2
This package is required for the grub-btrfs daemon
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- config/rootfiles/common/inotify-tools | 19 ++++++ lfs/inotify-tools | 83 +++++++++++++++++++++++++++ make.sh | 1 + 3 files changed, 103 insertions(+) create mode 100644 config/rootfiles/common/inotify-tools create mode 100644 lfs/inotify-tools
diff --git a/config/rootfiles/common/inotify-tools b/config/rootfiles/common/inotify-tools new file mode 100644 index 000000000..f99d64c01 --- /dev/null +++ b/config/rootfiles/common/inotify-tools @@ -0,0 +1,19 @@ +usr/bin/fsnotifywait +usr/bin/fsnotifywatch +usr/bin/inotifywait +usr/bin/inotifywatch +#usr/include/inotifytools +#usr/include/inotifytools/fanotify-dfid-name.h +#usr/include/inotifytools/fanotify.h +#usr/include/inotifytools/inotify-nosys.h +#usr/include/inotifytools/inotify.h +#usr/include/inotifytools/inotifytools.h +#usr/lib/libinotifytools.a +#usr/lib/libinotifytools.la +#usr/lib/libinotifytools.so +usr/lib/libinotifytools.so.0 +usr/lib/libinotifytools.so.0.4.1 +#usr/share/man/man1/fsnotifywait.1 +#usr/share/man/man1/fsnotifywatch.1 +#usr/share/man/man1/inotifywait.1 +#usr/share/man/man1/inotifywatch.1 diff --git a/lfs/inotify-tools b/lfs/inotify-tools new file mode 100644 index 000000000..bb70fbfc6 --- /dev/null +++ b/lfs/inotify-tools @@ -0,0 +1,83 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 4.23.9.0 + +THISAPP = inotify-tools-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_BLAKE2 = eddb0e44721cd8674f2309046998de16a030ed9ad84c49bc5950b9362055db9242dc0de1c615c3bd6c1f2835c83fc55446c9f8e6da52a98870c53f4e6cfa31f9 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +b2 : $(subst %,%_BLAKE2,$(objects)) + +dist: + @$(PAK) + +############################################################################### +# Downloading, checking, b2sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_BLAKE2,$(objects)) : + @$(B2SUM) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + $(UPDATE_AUTOMAKE) + cd $(DIR_APP) && ./autogen.sh + cd $(DIR_APP) && ./configure \ + --prefix=/usr + cd $(DIR_APP) && make $(MAKETUNING) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index 7e3ea09d1..30bd5f16b 100755 --- a/make.sh +++ b/make.sh @@ -1712,6 +1712,7 @@ buildipfire() { lfsmake2 rsnapshot lfsmake2 mympd lfsmake2 btrfs-progs + lfsmake2 inotify-tools
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty
This kind of grub addon will extend the grub boot menu by a additional submenu where a BTRFS snapshot can be selected to directly use as root volume and boot into it.
The grub-btrfsd daemon is using inotify(tools) to watch the snapshot directory for new or deleted snapshots and calls grub-mkconfig to adjust the snapshot grub submenu
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- config/rootfiles/common/grub-btrfs | 14 ++++ config/rootfiles/common/x86_64/initscripts | 4 ++ lfs/grub-btrfs | 79 ++++++++++++++++++++++ lfs/initscripts | 3 + make.sh | 1 + src/initscripts/system/grub-btrfsd | 61 +++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 lfs/grub-btrfs create mode 100644 src/initscripts/system/grub-btrfsd
diff --git a/config/rootfiles/common/grub-btrfs b/config/rootfiles/common/grub-btrfs new file mode 100644 index 000000000..a612af065 --- /dev/null +++ b/config/rootfiles/common/grub-btrfs @@ -0,0 +1,14 @@ +boot/grub/grubenv +etc/default/grub-btrfs +etc/default/grub-btrfs/config +etc/grub.d/41_snapshots-btrfs +usr/bin/grub-btrfsd +#usr/lib/systemd/system/grub-btrfsd.service +#usr/share/doc/grub-btrfs +#usr/share/doc/grub-btrfs/README.md +#usr/share/doc/grub-btrfs/initramfs-overlayfs.md +#usr/share/licenses +#usr/share/licenses/grub-btrfs +#usr/share/licenses/grub-btrfs/LICENSE +#usr/share/man/man8/grub-btrfs.8.bz2 +#usr/share/man/man8/grub-btrfsd.8.bz2 diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a5e1596fb..2d6fa85dc 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -26,6 +26,7 @@ etc/rc.d/init.d/firewall etc/rc.d/init.d/firstsetup etc/rc.d/init.d/fsresize etc/rc.d/init.d/functions +etc/rc.d/init.d/grub-btrfsd etc/rc.d/init.d/halt etc/rc.d/init.d/ipsec etc/rc.d/init.d/leds @@ -92,6 +93,7 @@ etc/rc.d/init.d/vnstat etc/rc.d/init.d/waitdrives etc/rc.d/init.d/wlanclient #etc/rc.d/rc0.d +etc/rc.d/rc0.d/K01grub-btrfsd #etc/rc.d/rc0.d/K01imspetor #etc/rc.d/rc0.d/K01motion #etc/rc.d/rc0.d/K01vdradmin @@ -135,10 +137,12 @@ etc/rc.d/rc3.d/S32apache etc/rc.d/rc3.d/S40fcron etc/rc.d/rc3.d/S98rc.local #etc/rc.d/rc3.d/S98sslh +etc/rc.d/rc3.d/S99grub-btrfsd #etc/rc.d/rc3.d/S99imspetor #etc/rc.d/rc3.d/S99motion #etc/rc.d/rc3.d/S99vdradmin #etc/rc.d/rc6.d +etc/rc.d/rc6.d/K01grub-btrfsd #etc/rc.d/rc6.d/K01imspetor #etc/rc.d/rc6.d/K01motion #etc/rc.d/rc6.d/K01vdradmin diff --git a/lfs/grub-btrfs b/lfs/grub-btrfs new file mode 100644 index 000000000..8dc0c4f3e --- /dev/null +++ b/lfs/grub-btrfs @@ -0,0 +1,79 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 4.13 + +THISAPP = grub-btrfs-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_BLAKE2 = e2f11a0a8282e3ec8ff8223e3bad70b5d5c5e81b4d740a1bf3554db412dbe48a8a0f216f4e6c65ae1d11c01a27b8b92bae9b470c60d2389505ce089511536e1a + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +b2 : $(subst %,%_BLAKE2,$(objects)) + +dist: + @$(PAK) + +############################################################################### +# Downloading, checking, b2sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_BLAKE2,$(objects)) : + @$(B2SUM) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + $(UPDATE_AUTOMAKE) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..4d67ee0c4 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -91,6 +91,7 @@ $(TARGET) : install -v -m 755 $$i /etc/rc.d/helper/; \ done
+ ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc0.d/K01grub-btrfsd ln -sf ../init.d/imspetor /etc/rc.d/rc0.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc0.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc0.d/K01vdradmin @@ -132,10 +133,12 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh + ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc3.d/S99grub-btrfsd ln -sf ../init.d/imspetor /etc/rc.d/rc3.d/S99imspetor ln -sf ../init.d/motion /etc/rc.d/rc3.d/S99motion ln -sf ../init.d/vdradmin /etc/rc.d/rc3.d/S99vdradmin
+ ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc6.d/K01grub-btrfsd ln -sf ../init.d/imspetor /etc/rc.d/rc6.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc6.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc6.d/K01vdradmin diff --git a/make.sh b/make.sh index 30bd5f16b..0aa3d26af 100755 --- a/make.sh +++ b/make.sh @@ -1713,6 +1713,7 @@ buildipfire() { lfsmake2 mympd lfsmake2 btrfs-progs lfsmake2 inotify-tools + lfsmake2 grub-btrfs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd new file mode 100644 index 000000000..833f90cb1 --- /dev/null +++ b/src/initscripts/system/grub-btrfsd @@ -0,0 +1,61 @@ +#!/bin/sh +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +. /etc/sysconfig/rc +. ${rc_functions} + +SNAPSHOTDIR="/.snapshots" +PIDFILE="/run/grub-btrfsd.pid" + +root_is_btrfs() { + [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1 + + return 0 +} + +case "$1" in + start) + root_is_btrfs || exit 0 + + boot_mesg "Starting grub-btrfsd..." + loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" + + # Store the gained PID to the defined pidfile + echo "$!" > "$PIDFILE" + ;; + + stop) + boot_mesg "Stopping grub-btrfsd..." + killproc -p "$PIDFILE" /usr/bin/grub-btrfsd + sleep 1; + ;; + + restart) + $0 stop + sleep 2 + $0 start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
This kind of grub addon will extend the grub boot menu by a additional submenu where a BTRFS snapshot can be selected to directly use as root volume and boot into it.
The grub-btrfsd daemon is using inotify(tools) to watch the snapshot directory for new or deleted snapshots and calls grub-mkconfig to adjust the snapshot grub submenu
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
config/rootfiles/common/grub-btrfs | 14 ++++ config/rootfiles/common/x86_64/initscripts | 4 ++ lfs/grub-btrfs | 79 ++++++++++++++++++++++ lfs/initscripts | 3 + make.sh | 1 + src/initscripts/system/grub-btrfsd | 61 +++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 lfs/grub-btrfs create mode 100644 src/initscripts/system/grub-btrfsd
diff --git a/config/rootfiles/common/grub-btrfs b/config/rootfiles/common/grub-btrfs new file mode 100644 index 000000000..a612af065 --- /dev/null +++ b/config/rootfiles/common/grub-btrfs @@ -0,0 +1,14 @@ +boot/grub/grubenv +etc/default/grub-btrfs +etc/default/grub-btrfs/config +etc/grub.d/41_snapshots-btrfs +usr/bin/grub-btrfsd +#usr/lib/systemd/system/grub-btrfsd.service +#usr/share/doc/grub-btrfs +#usr/share/doc/grub-btrfs/README.md +#usr/share/doc/grub-btrfs/initramfs-overlayfs.md +#usr/share/licenses +#usr/share/licenses/grub-btrfs +#usr/share/licenses/grub-btrfs/LICENSE +#usr/share/man/man8/grub-btrfs.8.bz2 +#usr/share/man/man8/grub-btrfsd.8.bz2 diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a5e1596fb..2d6fa85dc 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -26,6 +26,7 @@ etc/rc.d/init.d/firewall etc/rc.d/init.d/firstsetup etc/rc.d/init.d/fsresize etc/rc.d/init.d/functions +etc/rc.d/init.d/grub-btrfsd etc/rc.d/init.d/halt etc/rc.d/init.d/ipsec etc/rc.d/init.d/leds @@ -92,6 +93,7 @@ etc/rc.d/init.d/vnstat etc/rc.d/init.d/waitdrives etc/rc.d/init.d/wlanclient #etc/rc.d/rc0.d +etc/rc.d/rc0.d/K01grub-btrfsd #etc/rc.d/rc0.d/K01imspetor #etc/rc.d/rc0.d/K01motion #etc/rc.d/rc0.d/K01vdradmin @@ -135,10 +137,12 @@ etc/rc.d/rc3.d/S32apache etc/rc.d/rc3.d/S40fcron etc/rc.d/rc3.d/S98rc.local #etc/rc.d/rc3.d/S98sslh +etc/rc.d/rc3.d/S99grub-btrfsd #etc/rc.d/rc3.d/S99imspetor #etc/rc.d/rc3.d/S99motion #etc/rc.d/rc3.d/S99vdradmin #etc/rc.d/rc6.d +etc/rc.d/rc6.d/K01grub-btrfsd #etc/rc.d/rc6.d/K01imspetor #etc/rc.d/rc6.d/K01motion #etc/rc.d/rc6.d/K01vdradmin diff --git a/lfs/grub-btrfs b/lfs/grub-btrfs new file mode 100644 index 000000000..8dc0c4f3e --- /dev/null +++ b/lfs/grub-btrfs @@ -0,0 +1,79 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +###############################################################################
+############################################################################### +# Definitions +###############################################################################
+include Config
+VER = 4.13
+THISAPP = grub-btrfs-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)
+############################################################################### +# Top-level Rules +###############################################################################
+objects = $(DL_FILE)
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+$(DL_FILE)_BLAKE2 = e2f11a0a8282e3ec8ff8223e3bad70b5d5c5e81b4d740a1bf3554db412dbe48a8a0f216f4e6c65ae1d11c01a27b8b92bae9b470c60d2389505ce089511536e1a
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+b2 : $(subst %,%_BLAKE2,$(objects))
+dist:
- @$(PAK)
+############################################################################### +# Downloading, checking, b2sum +###############################################################################
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
- @$(CHECK)
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
- @$(LOAD)
+$(subst %,%_BLAKE2,$(objects)) :
- @$(B2SUM)
+############################################################################### +# Installation Details +###############################################################################
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
- @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
- $(UPDATE_AUTOMAKE)
- cd $(DIR_APP) && make install
- @rm -rf $(DIR_APP)
- @$(POSTBUILD)
diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..4d67ee0c4 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -91,6 +91,7 @@ $(TARGET) : install -v -m 755 $$i /etc/rc.d/helper/; \ done
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc0.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc0.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc0.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc0.d/K01vdradmin @@ -132,10 +133,12 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc3.d/S99grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc3.d/S99imspetor ln -sf ../init.d/motion /etc/rc.d/rc3.d/S99motion ln -sf ../init.d/vdradmin /etc/rc.d/rc3.d/S99vdradmin
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc6.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc6.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc6.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc6.d/K01vdradmin diff --git a/make.sh b/make.sh index 30bd5f16b..0aa3d26af 100755 --- a/make.sh +++ b/make.sh @@ -1713,6 +1713,7 @@ buildipfire() { lfsmake2 mympd lfsmake2 btrfs-progs lfsmake2 inotify-tools
lfsmake2 grub-btrfs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd new file mode 100644 index 000000000..833f90cb1 --- /dev/null +++ b/src/initscripts/system/grub-btrfsd @@ -0,0 +1,61 @@ +#!/bin/sh +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +###############################################################################
+. /etc/sysconfig/rc +. ${rc_functions}
+SNAPSHOTDIR="/.snapshots" +PIDFILE="/run/grub-btrfsd.pid"
+root_is_btrfs() {
- [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1
- return 0
+}
+case "$1" in
start)
- root_is_btrfs || exit 0
- boot_mesg "Starting grub-btrfsd..."
Please give this a more human-readable name. Like the other services :)
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR"
- # Store the gained PID to the defined pidfile
- echo "$!" > "$PIDFILE"
- ;;
- stop)
- boot_mesg "Stopping grub-btrfsd..."
- killproc -p "$PIDFILE" /usr/bin/grub-btrfsd
- sleep 1;
- ;;
- restart)
- $0 stop
- sleep 2
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
+esac
2.39.2
Am Montag, dem 18.03.2024 um 16:13 +0000 schrieb Michael Tremer:
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
This kind of grub addon will extend the grub boot menu by a additional submenu where a BTRFS snapshot can be selected to directly use as root volume and boot into it.
The grub-btrfsd daemon is using inotify(tools) to watch the snapshot directory for new or deleted snapshots and calls grub-mkconfig to adjust the snapshot grub submenu
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
config/rootfiles/common/grub-btrfs | 14 ++++ config/rootfiles/common/x86_64/initscripts | 4 ++ lfs/grub-btrfs | 79 ++++++++++++++++++++++ lfs/initscripts | 3 + make.sh | 1 + src/initscripts/system/grub-btrfsd | 61 +++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 lfs/grub-btrfs create mode 100644 src/initscripts/system/grub-btrfsd
diff --git a/config/rootfiles/common/grub-btrfs b/config/rootfiles/common/grub-btrfs new file mode 100644 index 000000000..a612af065 --- /dev/null +++ b/config/rootfiles/common/grub-btrfs @@ -0,0 +1,14 @@ +boot/grub/grubenv +etc/default/grub-btrfs +etc/default/grub-btrfs/config +etc/grub.d/41_snapshots-btrfs +usr/bin/grub-btrfsd +#usr/lib/systemd/system/grub-btrfsd.service +#usr/share/doc/grub-btrfs +#usr/share/doc/grub-btrfs/README.md +#usr/share/doc/grub-btrfs/initramfs-overlayfs.md +#usr/share/licenses +#usr/share/licenses/grub-btrfs +#usr/share/licenses/grub-btrfs/LICENSE +#usr/share/man/man8/grub-btrfs.8.bz2 +#usr/share/man/man8/grub-btrfsd.8.bz2 diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a5e1596fb..2d6fa85dc 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -26,6 +26,7 @@ etc/rc.d/init.d/firewall etc/rc.d/init.d/firstsetup etc/rc.d/init.d/fsresize etc/rc.d/init.d/functions +etc/rc.d/init.d/grub-btrfsd etc/rc.d/init.d/halt etc/rc.d/init.d/ipsec etc/rc.d/init.d/leds @@ -92,6 +93,7 @@ etc/rc.d/init.d/vnstat etc/rc.d/init.d/waitdrives etc/rc.d/init.d/wlanclient #etc/rc.d/rc0.d +etc/rc.d/rc0.d/K01grub-btrfsd #etc/rc.d/rc0.d/K01imspetor #etc/rc.d/rc0.d/K01motion #etc/rc.d/rc0.d/K01vdradmin @@ -135,10 +137,12 @@ etc/rc.d/rc3.d/S32apache etc/rc.d/rc3.d/S40fcron etc/rc.d/rc3.d/S98rc.local #etc/rc.d/rc3.d/S98sslh +etc/rc.d/rc3.d/S99grub-btrfsd #etc/rc.d/rc3.d/S99imspetor #etc/rc.d/rc3.d/S99motion #etc/rc.d/rc3.d/S99vdradmin #etc/rc.d/rc6.d +etc/rc.d/rc6.d/K01grub-btrfsd #etc/rc.d/rc6.d/K01imspetor #etc/rc.d/rc6.d/K01motion #etc/rc.d/rc6.d/K01vdradmin diff --git a/lfs/grub-btrfs b/lfs/grub-btrfs new file mode 100644 index 000000000..8dc0c4f3e --- /dev/null +++ b/lfs/grub-btrfs @@ -0,0 +1,79 @@ +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+################################################################## ############# +# Definitions +################################################################## #############
+include Config
+VER = 4.13
+THISAPP = grub-btrfs-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)
+################################################################## ############# +# Top-level Rules +################################################################## #############
+objects = $(DL_FILE)
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+$(DL_FILE)_BLAKE2 = e2f11a0a8282e3ec8ff8223e3bad70b5d5c5e81b4d740a1bf3554db412dbe48a8a0 f216f4e6c65ae1d11c01a27b8b92bae9b470c60d2389505ce089511536e1a
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+b2 : $(subst %,%_BLAKE2,$(objects))
+dist:
- @$(PAK)
+################################################################## ############# +# Downloading, checking, b2sum +################################################################## #############
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
- @$(CHECK)
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
- @$(LOAD)
+$(subst %,%_BLAKE2,$(objects)) :
- @$(B2SUM)
+################################################################## ############# +# Installation Details +################################################################## #############
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
- @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf
$(DIR_DL)/$(DL_FILE)
- $(UPDATE_AUTOMAKE)
- cd $(DIR_APP) && make install
- @rm -rf $(DIR_APP)
- @$(POSTBUILD)
diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..4d67ee0c4 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -91,6 +91,7 @@ $(TARGET) : install -v -m 755 $$i /etc/rc.d/helper/; \ done
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc0.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc0.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc0.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc0.d/K01vdradmin @@ -132,10 +133,12 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc3.d/S99grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc3.d/S99imspetor ln -sf ../init.d/motion /etc/rc.d/rc3.d/S99motion ln -sf ../init.d/vdradmin /etc/rc.d/rc3.d/S99vdradmin
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc6.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc6.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc6.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc6.d/K01vdradmin diff --git a/make.sh b/make.sh index 30bd5f16b..0aa3d26af 100755 --- a/make.sh +++ b/make.sh @@ -1713,6 +1713,7 @@ buildipfire() { lfsmake2 mympd lfsmake2 btrfs-progs lfsmake2 inotify-tools + lfsmake2 grub-btrfs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd new file mode 100644 index 000000000..833f90cb1 --- /dev/null +++ b/src/initscripts/system/grub-btrfsd @@ -0,0 +1,61 @@ +#!/bin/sh +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+. /etc/sysconfig/rc +. ${rc_functions}
+SNAPSHOTDIR="/.snapshots" +PIDFILE="/run/grub-btrfsd.pid"
+root_is_btrfs() { + [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1
+ return 0 +}
+case "$1" in + start)
- root_is_btrfs || exit 0
- boot_mesg "Starting grub-btrfsd..."
Please give this a more human-readable name. Like the other services :)
Okay, any suggestions?
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog
"$SNAPSHOTDIR"
- # Store the gained PID to the defined pidfile
- echo "$!" > "$PIDFILE"
- ;;
- stop)
- boot_mesg "Stopping grub-btrfsd..."
- killproc -p "$PIDFILE" /usr/bin/grub-btrfsd
- sleep 1;
- ;;
- restart)
- $0 stop
- sleep 2
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
+esac
2.39.2
Btrfs Snapshot Daemon?
GRUB/Btrfs Daemon?
Are we spelling btrfs lowercase everywhere? Wikipedia seems to have gone for a capital B, rest lowercase.
https://en.wikipedia.org/wiki/Btrfs
-Michael
On 19 Mar 2024, at 20:21, Stefan Schantl stefan.schantl@ipfire.org wrote:
Am Montag, dem 18.03.2024 um 16:13 +0000 schrieb Michael Tremer:
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
This kind of grub addon will extend the grub boot menu by a additional submenu where a BTRFS snapshot can be selected to directly use as root volume and boot into it.
The grub-btrfsd daemon is using inotify(tools) to watch the snapshot directory for new or deleted snapshots and calls grub-mkconfig to adjust the snapshot grub submenu
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
config/rootfiles/common/grub-btrfs | 14 ++++ config/rootfiles/common/x86_64/initscripts | 4 ++ lfs/grub-btrfs | 79 ++++++++++++++++++++++ lfs/initscripts | 3 + make.sh | 1 + src/initscripts/system/grub-btrfsd | 61 +++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 lfs/grub-btrfs create mode 100644 src/initscripts/system/grub-btrfsd
diff --git a/config/rootfiles/common/grub-btrfs b/config/rootfiles/common/grub-btrfs new file mode 100644 index 000000000..a612af065 --- /dev/null +++ b/config/rootfiles/common/grub-btrfs @@ -0,0 +1,14 @@ +boot/grub/grubenv +etc/default/grub-btrfs +etc/default/grub-btrfs/config +etc/grub.d/41_snapshots-btrfs +usr/bin/grub-btrfsd +#usr/lib/systemd/system/grub-btrfsd.service +#usr/share/doc/grub-btrfs +#usr/share/doc/grub-btrfs/README.md +#usr/share/doc/grub-btrfs/initramfs-overlayfs.md +#usr/share/licenses +#usr/share/licenses/grub-btrfs +#usr/share/licenses/grub-btrfs/LICENSE +#usr/share/man/man8/grub-btrfs.8.bz2 +#usr/share/man/man8/grub-btrfsd.8.bz2 diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a5e1596fb..2d6fa85dc 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -26,6 +26,7 @@ etc/rc.d/init.d/firewall etc/rc.d/init.d/firstsetup etc/rc.d/init.d/fsresize etc/rc.d/init.d/functions +etc/rc.d/init.d/grub-btrfsd etc/rc.d/init.d/halt etc/rc.d/init.d/ipsec etc/rc.d/init.d/leds @@ -92,6 +93,7 @@ etc/rc.d/init.d/vnstat etc/rc.d/init.d/waitdrives etc/rc.d/init.d/wlanclient #etc/rc.d/rc0.d +etc/rc.d/rc0.d/K01grub-btrfsd #etc/rc.d/rc0.d/K01imspetor #etc/rc.d/rc0.d/K01motion #etc/rc.d/rc0.d/K01vdradmin @@ -135,10 +137,12 @@ etc/rc.d/rc3.d/S32apache etc/rc.d/rc3.d/S40fcron etc/rc.d/rc3.d/S98rc.local #etc/rc.d/rc3.d/S98sslh +etc/rc.d/rc3.d/S99grub-btrfsd #etc/rc.d/rc3.d/S99imspetor #etc/rc.d/rc3.d/S99motion #etc/rc.d/rc3.d/S99vdradmin #etc/rc.d/rc6.d +etc/rc.d/rc6.d/K01grub-btrfsd #etc/rc.d/rc6.d/K01imspetor #etc/rc.d/rc6.d/K01motion #etc/rc.d/rc6.d/K01vdradmin diff --git a/lfs/grub-btrfs b/lfs/grub-btrfs new file mode 100644 index 000000000..8dc0c4f3e --- /dev/null +++ b/lfs/grub-btrfs @@ -0,0 +1,79 @@ +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+################################################################## ############# +# Definitions +################################################################## #############
+include Config
+VER = 4.13
+THISAPP = grub-btrfs-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)
+################################################################## ############# +# Top-level Rules +################################################################## #############
+objects = $(DL_FILE)
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+$(DL_FILE)_BLAKE2 = e2f11a0a8282e3ec8ff8223e3bad70b5d5c5e81b4d740a1bf3554db412dbe48a8a0 f216f4e6c65ae1d11c01a27b8b92bae9b470c60d2389505ce089511536e1a
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+b2 : $(subst %,%_BLAKE2,$(objects))
+dist:
- @$(PAK)
+################################################################## ############# +# Downloading, checking, b2sum +################################################################## #############
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
- @$(CHECK)
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
- @$(LOAD)
+$(subst %,%_BLAKE2,$(objects)) :
- @$(B2SUM)
+################################################################## ############# +# Installation Details +################################################################## #############
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
- @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf
$(DIR_DL)/$(DL_FILE)
- $(UPDATE_AUTOMAKE)
- cd $(DIR_APP) && make install
- @rm -rf $(DIR_APP)
- @$(POSTBUILD)
diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..4d67ee0c4 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -91,6 +91,7 @@ $(TARGET) : install -v -m 755 $$i /etc/rc.d/helper/; \ done
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc0.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc0.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc0.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc0.d/K01vdradmin @@ -132,10 +133,12 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc3.d/S99grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc3.d/S99imspetor ln -sf ../init.d/motion /etc/rc.d/rc3.d/S99motion ln -sf ../init.d/vdradmin /etc/rc.d/rc3.d/S99vdradmin
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc6.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc6.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc6.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc6.d/K01vdradmin diff --git a/make.sh b/make.sh index 30bd5f16b..0aa3d26af 100755 --- a/make.sh +++ b/make.sh @@ -1713,6 +1713,7 @@ buildipfire() { lfsmake2 mympd lfsmake2 btrfs-progs lfsmake2 inotify-tools
lfsmake2 grub-btrfs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd new file mode 100644 index 000000000..833f90cb1 --- /dev/null +++ b/src/initscripts/system/grub-btrfsd @@ -0,0 +1,61 @@ +#!/bin/sh +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+. /etc/sysconfig/rc +. ${rc_functions}
+SNAPSHOTDIR="/.snapshots" +PIDFILE="/run/grub-btrfsd.pid"
+root_is_btrfs() {
- [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1
- return 0
+}
+case "$1" in
start)
- root_is_btrfs || exit 0
- boot_mesg "Starting grub-btrfsd..."
Please give this a more human-readable name. Like the other services :)
Okay, any suggestions?
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog
"$SNAPSHOTDIR"
- # Store the gained PID to the defined pidfile
- echo "$!" > "$PIDFILE"
- ;;
- stop)
- boot_mesg "Stopping grub-btrfsd..."
- killproc -p "$PIDFILE" /usr/bin/grub-btrfsd
- sleep 1;
- ;;
- restart)
- $0 stop
- sleep 2
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
+esac
2.39.2
Hello?!
On 20 Mar 2024, at 09:47, Michael Tremer michael.tremer@ipfire.org wrote:
Btrfs Snapshot Daemon?
GRUB/Btrfs Daemon?
Are we spelling btrfs lowercase everywhere? Wikipedia seems to have gone for a capital B, rest lowercase.
https://en.wikipedia.org/wiki/Btrfs
-Michael
On 19 Mar 2024, at 20:21, Stefan Schantl stefan.schantl@ipfire.org wrote:
Am Montag, dem 18.03.2024 um 16:13 +0000 schrieb Michael Tremer:
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
This kind of grub addon will extend the grub boot menu by a additional submenu where a BTRFS snapshot can be selected to directly use as root volume and boot into it.
The grub-btrfsd daemon is using inotify(tools) to watch the snapshot directory for new or deleted snapshots and calls grub-mkconfig to adjust the snapshot grub submenu
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
config/rootfiles/common/grub-btrfs | 14 ++++ config/rootfiles/common/x86_64/initscripts | 4 ++ lfs/grub-btrfs | 79 ++++++++++++++++++++++ lfs/initscripts | 3 + make.sh | 1 + src/initscripts/system/grub-btrfsd | 61 +++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 lfs/grub-btrfs create mode 100644 src/initscripts/system/grub-btrfsd
diff --git a/config/rootfiles/common/grub-btrfs b/config/rootfiles/common/grub-btrfs new file mode 100644 index 000000000..a612af065 --- /dev/null +++ b/config/rootfiles/common/grub-btrfs @@ -0,0 +1,14 @@ +boot/grub/grubenv +etc/default/grub-btrfs +etc/default/grub-btrfs/config +etc/grub.d/41_snapshots-btrfs +usr/bin/grub-btrfsd +#usr/lib/systemd/system/grub-btrfsd.service +#usr/share/doc/grub-btrfs +#usr/share/doc/grub-btrfs/README.md +#usr/share/doc/grub-btrfs/initramfs-overlayfs.md +#usr/share/licenses +#usr/share/licenses/grub-btrfs +#usr/share/licenses/grub-btrfs/LICENSE +#usr/share/man/man8/grub-btrfs.8.bz2 +#usr/share/man/man8/grub-btrfsd.8.bz2 diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a5e1596fb..2d6fa85dc 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -26,6 +26,7 @@ etc/rc.d/init.d/firewall etc/rc.d/init.d/firstsetup etc/rc.d/init.d/fsresize etc/rc.d/init.d/functions +etc/rc.d/init.d/grub-btrfsd etc/rc.d/init.d/halt etc/rc.d/init.d/ipsec etc/rc.d/init.d/leds @@ -92,6 +93,7 @@ etc/rc.d/init.d/vnstat etc/rc.d/init.d/waitdrives etc/rc.d/init.d/wlanclient #etc/rc.d/rc0.d +etc/rc.d/rc0.d/K01grub-btrfsd #etc/rc.d/rc0.d/K01imspetor #etc/rc.d/rc0.d/K01motion #etc/rc.d/rc0.d/K01vdradmin @@ -135,10 +137,12 @@ etc/rc.d/rc3.d/S32apache etc/rc.d/rc3.d/S40fcron etc/rc.d/rc3.d/S98rc.local #etc/rc.d/rc3.d/S98sslh +etc/rc.d/rc3.d/S99grub-btrfsd #etc/rc.d/rc3.d/S99imspetor #etc/rc.d/rc3.d/S99motion #etc/rc.d/rc3.d/S99vdradmin #etc/rc.d/rc6.d +etc/rc.d/rc6.d/K01grub-btrfsd #etc/rc.d/rc6.d/K01imspetor #etc/rc.d/rc6.d/K01motion #etc/rc.d/rc6.d/K01vdradmin diff --git a/lfs/grub-btrfs b/lfs/grub-btrfs new file mode 100644 index 000000000..8dc0c4f3e --- /dev/null +++ b/lfs/grub-btrfs @@ -0,0 +1,79 @@ +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2023 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+################################################################## ############# +# Definitions +################################################################## #############
+include Config
+VER = 4.13
+THISAPP = grub-btrfs-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP)
+################################################################## ############# +# Top-level Rules +################################################################## #############
+objects = $(DL_FILE)
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+$(DL_FILE)_BLAKE2 = e2f11a0a8282e3ec8ff8223e3bad70b5d5c5e81b4d740a1bf3554db412dbe48a8a0 f216f4e6c65ae1d11c01a27b8b92bae9b470c60d2389505ce089511536e1a
+install : $(TARGET)
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+b2 : $(subst %,%_BLAKE2,$(objects))
+dist:
- @$(PAK)
+################################################################## ############# +# Downloading, checking, b2sum +################################################################## #############
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
- @$(CHECK)
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
- @$(LOAD)
+$(subst %,%_BLAKE2,$(objects)) :
- @$(B2SUM)
+################################################################## ############# +# Installation Details +################################################################## #############
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
- @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf
$(DIR_DL)/$(DL_FILE)
- $(UPDATE_AUTOMAKE)
- cd $(DIR_APP) && make install
- @rm -rf $(DIR_APP)
- @$(POSTBUILD)
diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..4d67ee0c4 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -91,6 +91,7 @@ $(TARGET) : install -v -m 755 $$i /etc/rc.d/helper/; \ done
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc0.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc0.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc0.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc0.d/K01vdradmin @@ -132,10 +133,12 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc3.d/S99grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc3.d/S99imspetor ln -sf ../init.d/motion /etc/rc.d/rc3.d/S99motion ln -sf ../init.d/vdradmin /etc/rc.d/rc3.d/S99vdradmin
- ln -sf ../init.d/grub-btrfsd /etc/rc.d/rc6.d/K01grub-btrfsd
ln -sf ../init.d/imspetor /etc/rc.d/rc6.d/K01imspetor ln -sf ../init.d/motion /etc/rc.d/rc6.d/K01motion ln -sf ../init.d/vdradmin /etc/rc.d/rc6.d/K01vdradmin diff --git a/make.sh b/make.sh index 30bd5f16b..0aa3d26af 100755 --- a/make.sh +++ b/make.sh @@ -1713,6 +1713,7 @@ buildipfire() { lfsmake2 mympd lfsmake2 btrfs-progs lfsmake2 inotify-tools
- lfsmake2 grub-btrfs
# Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd new file mode 100644 index 000000000..833f90cb1 --- /dev/null +++ b/src/initscripts/system/grub-btrfsd @@ -0,0 +1,61 @@ +#!/bin/sh +################################################################## ############# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2024 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +################################################################## #############
+. /etc/sysconfig/rc +. ${rc_functions}
+SNAPSHOTDIR="/.snapshots" +PIDFILE="/run/grub-btrfsd.pid"
+root_is_btrfs() {
- [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1
- return 0
+}
+case "$1" in
start)
- root_is_btrfs || exit 0
- boot_mesg "Starting grub-btrfsd..."
Please give this a more human-readable name. Like the other services :)
Okay, any suggestions?
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog
"$SNAPSHOTDIR"
- # Store the gained PID to the defined pidfile
- echo "$!" > "$PIDFILE"
- ;;
- stop)
- boot_mesg "Stopping grub-btrfsd..."
- killproc -p "$PIDFILE" /usr/bin/grub-btrfsd
- sleep 1;
- ;;
- restart)
- $0 stop
- sleep 2
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
+esac
2.39.2
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer/main.c b/src/installer/main.c index b3c9d27ee..154c2d66a 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -720,7 +720,7 @@ int main(int argc, char *argv[]) { { HW_FS_EXT4, _("ext4 Filesystem") }, { HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") }, { HW_FS_XFS, _("XFS Filesystem") }, - { HW_FS_BTRFS, _("BTRFS Filesystem") }, + { HW_FS_BTRFS, _("BTRFS Filesystem (experimental)") }, { 0, NULL }, }; unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems);
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/installer/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer/main.c b/src/installer/main.c index b3c9d27ee..154c2d66a 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -720,7 +720,7 @@ int main(int argc, char *argv[]) { { HW_FS_EXT4, _("ext4 Filesystem") }, { HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") }, { HW_FS_XFS, _("XFS Filesystem") },
- { HW_FS_BTRFS, _("BTRFS Filesystem") },
- { HW_FS_BTRFS, _("BTRFS Filesystem (experimental)") },
Please make this EXPERIMENTAL. That should scare people more.
{ 0, NULL }, }; unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems); -- 2.39.2
* Rename the fs root to @ to prevent name collision with home directory of user root.
* Add @root which contains the home directory of the root user * Add @backup which will contains the created backups
Fixes #13608
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 26c473e9c..4110deccf 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -47,10 +47,12 @@ // Array which contains the subvolumes which will be created when installing // IPFire on a BTRFS. const char* btrfs_subvolumes[8][2] = { - {"@root" ,"/"}, + {"@" ,"/"}, {"@snapshots", "/.snapshots"}, {"@home", "/home"}, + {"@root", "/root"}, {"@cache", "/var/cache"}, + {"@backup", "/var/ipfire/backup"}, {"@lib", "/var/lib"}, {"@logs", "/var/log"}, {"@mails", "/var/mail"},
Hello Stefan,
On 15 Mar 2024, at 19:14, Stefan Schantl stefan.schantl@ipfire.org wrote:
Hello mailinglist followers,
this first patchset will introduce basic BTRFS support in IPFire 2.x.
Thank you for submitting this. I have been looking forward to see this on here.
Although it is still early days, I would like to merge this as soon as possible and generally consider this an experimental feature for a long time to come. There probably won't be any tangible advantages for our users, but we should have a better option to roll back any physical installations if any experimental updates go wrong.
It allows to choose BTRFS during installation as filesystem, will install IPFire and bring it up as usual.
The main difference to the other file system will be displayed when showing the current mounted filesystems. When using BTRFS a lot of so called subvolumes will be created. They act as some kind of logical partition and are needed in two cases.
This kind of fragmentation allows to create snapshots of such a subvolume and only the stored data on it. The more important reason of using subvolumes is, that while creating a snapshot any files which are located on a different subvolume will not be part of it.
So, when creating a snaphot of the filesystem root and restoring it back later, no files which are part of a subvolume (logfile, database files etc) are rolled-back. This helps us debugging because the old logs are still there and mostly important prevents from data lost of altered databases or newly created files!
Currently there is still some work to do see:
Wiki-Roadmap: https://www.ipfire.org/docs/roadmap/btrfs Bugzilla: https://bugzilla.ipfire.org/show_bug.cgi?id=13606
Stefan Schantl (17): btrfs-progs: New package installer: Allow to install IPFire on BTRFS installer: Ensure to always create the /boot directory. installer: Disable seperate boot partition installer: Add code to create a BTRFS subvolume layout. installer: Correctly umount main BTRFS partition. installer: Add recurisve mkdir function installer: Mount BTRFS layout before installing the system installer: Add /var/tmp to the BTRFS layout installer: Fix using BTRFS mount options when mounting the layout installer: Add code to proper unmount the BTRFS layout installer: Add code to correctly write the fstab when installing on BTRFS installer: Define common mount options for BTRFS volumes inotify-tools: New package grub-btrfs: New package installer: Mark BTRFS support as experimental installer: Adjust BTRFS layout
config/rootfiles/common/btrfs-progs | 33 +++ config/rootfiles/common/grub-btrfs | 14 ++ config/rootfiles/common/inotify-tools | 19 ++ config/rootfiles/common/x86_64/initscripts | 4 + lfs/btrfs-progs | 85 ++++++++ lfs/grub-btrfs | 79 +++++++ lfs/initscripts | 3 + lfs/inotify-tools | 83 ++++++++ make.sh | 3 + src/initscripts/system/grub-btrfsd | 61 ++++++ src/installer/dracut-module/module-setup.sh | 4 +- src/installer/hw.c | 221 +++++++++++++++++++- src/installer/hw.h | 8 + src/installer/main.c | 1 + 14 files changed, 606 insertions(+), 12 deletions(-) create mode 100644 config/rootfiles/common/btrfs-progs create mode 100644 config/rootfiles/common/grub-btrfs create mode 100644 config/rootfiles/common/inotify-tools create mode 100644 lfs/btrfs-progs create mode 100644 lfs/grub-btrfs create mode 100644 lfs/inotify-tools create mode 100644 src/initscripts/system/grub-btrfsd
-- 2.39.2