From patchwork Sat Mar 23 10:56:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7659 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3160x2z3wtq for ; Sat, 23 Mar 2024 10:56:45 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3016pJzFKr; Sat, 23 Mar 2024 10:56:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x2z5hVNz32vd; Sat, 23 Mar 2024 10:56:43 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2x4TYVz32bJ for ; Sat, 23 Mar 2024 10:56:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2w1Q6PzT1; Sat, 23 Mar 2024 10:56:40 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6F7dCV5wGBKH1aTZExe/cXePtst8m4RfqPfLoi2S5SU=; b=E5QooEP7wyiuTXkspOBq0OdlfojX8ACNAdBlWqJu7pvrkr6e5H25bbMPtTMYVD22BKVuTC IBV74Gy4onJ9KaAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6F7dCV5wGBKH1aTZExe/cXePtst8m4RfqPfLoi2S5SU=; b=lUehQXL91In98Itwvjex5iHhjwYJT/qxeFhdM5rcOaKivP8mOqq4HPtpPZ93++Xci/Ppxy k3vSRjuntrTwGrbDuh1z2quImvDbCej4kvmCRHeOJz1nkenp7GE5v5he/OlksZ/WP8zXxn Un+5MIhVarZvZXA8XBAcILUH8GzdDBhAxx0tXCfGGifBk24mlTn6hq22PYCFhC12k2QTgY snVACJClGQeG2z8qFVQLQNfE7TYbb4xWFBx3qFz/WsSrcNIsQj2bmSlwbP5FM5tT/M2a2Q 5wkjYXZSQhcqpLE2SnVkfd8ZL6MPHT89op72O8RLA4E6QQ5V4uEIp8lniY0TyQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 01/12] btrfs-progs: New package Date: Sat, 23 Mar 2024 11:56:18 +0100 Message-Id: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: K32YOP6A4D2B3T5WEMAGAHH7OOZPZMMC X-Message-ID-Hash: K32YOP6A4D2B3T5WEMAGAHH7OOZPZMMC X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- 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 # +# # +# 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 . # +# # +############################################################################### + +############################################################################### +# 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 64dbef5c4..3c0b9ef27 100755 --- a/make.sh +++ b/make.sh @@ -1712,6 +1712,7 @@ buildipfire() { lfsmake2 rsnapshot lfsmake2 mympd lfsmake2 wsdd + lfsmake2 btrfs-progs # Kernelbuild ... current we have no platform that need # multi kernel builds so KCFG is empty From patchwork Sat Mar 23 10:56:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7660 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x392P6pz3wtq for ; Sat, 23 Mar 2024 10:56:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x330MmnzcS; Sat, 23 Mar 2024 10:56:47 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x32747Kz32vb; Sat, 23 Mar 2024 10:56:46 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2x5PWYz32bJ for ; Sat, 23 Mar 2024 10:56:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2x36dQzcG; Sat, 23 Mar 2024 10:56:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h1ymAjtpUmetvAyhCmOgjsKblhlSBGetYOWa9fAZzmc=; b=3Lq95rgJxJY1p7Oa4o9jdweCSuaZopOJK9mgXQjX6NyFxbQPCp7HaQ1UCKv/z/zY/RxUOn aSJrM9hGGfL39lCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h1ymAjtpUmetvAyhCmOgjsKblhlSBGetYOWa9fAZzmc=; b=aKk467SWAEiVgtxg8CcuXvalSaWCylgUfiayQ5aW4rpJNBfilTSQYiJU5DiI8iQfZiZzHO jK2XGvooaaCNAuMNlltAsZ+cRhTeWRXnZ7i6eN6YURsGlwEqDso0Fxcyn2/1zM83l49dBv Xj37q1m0qf27OcWwNf31VqgAt9baXmXsNY3Pv2kQacdPBEInI++r21VTwEJIFBPZIVrBbu UBaq5zCMetq8Xmwtipiy15cKai2PPXRlOr1u56ltQEjF9ElVcdufTSnc8dzomH5FZYPt2f Kye83zYqGcFJDqSFJ8Fmn2HfrR+AR7vmW56+2J+3br6ifKI1rBHzv1He2CVD7Q== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 02/12] installer: Allow to install IPFire on BTRFS Date: Sat, 23 Mar 2024 11:56:19 +0100 Message-Id: <20240323105629.371511-2-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: VM52KABPPORAM3YQSCL4FNFTI6QBE44Y X-Message-ID-Hash: VM52KABPPORAM3YQSCL4FNFTI6QBE44Y X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- 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..4d214c152 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 -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..47daccdaa 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 (EXPERIMENTAL)") }, { 0, NULL }, }; unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems); From patchwork Sat Mar 23 10:56:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7661 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3D2cJMz3wtq for ; Sat, 23 Mar 2024 10:56:56 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x342rCkzFLY; Sat, 23 Mar 2024 10:56:48 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x340kf9z32vH; Sat, 23 Mar 2024 10:56:48 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2y0l2Mz32bJ for ; Sat, 23 Mar 2024 10:56:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2x5dHsz4Rt; Sat, 23 Mar 2024 10:56:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CO0itatf2wWFkCmlpy21T7Mwuz38EAURWMnOnrQ61J8=; b=tPe8ugRzeKsJZx61ktUQtnaufnEb1VrPKC+arqCU+bOYaufx224/3tl1vThCqeHjE2V5Y6 vQlqplZiAGPMDnCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CO0itatf2wWFkCmlpy21T7Mwuz38EAURWMnOnrQ61J8=; b=graGfQDSpTi9qScCz8pr80IlxDK4AcUQ1YLqdyVzCoyu5yFq2oXv3CeGFaSJra1o+4nfEV 5YIpKv7aHt1oWBYBLKKWXUdLYNNloROYlFuNLZ88bN5fC2dDhyi4B+KVtOkopG1sO2Z18w bCjmI92pw7tf3x1XyuZTnF1UuFiQw5jb2GjfwrEBBQBb4RQbGVyF51DvIe8p2QsDbP73Zi rMuXWKe6YcPJhuk6mUGUFaO7FsRpn8uNGMTjhPAIWCZd72czk1iAUTsxMJJAPETIRq3eE2 AZzbVf3vrLxJ1Q5TlL+X4wwbpvC1qyixl9b6j1NcqnctbFPtKgq+LYxvuaTZZw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 03/12] dracut: Ship BTRFS related modules Date: Sat, 23 Mar 2024 11:56:20 +0100 Message-Id: <20240323105629.371511-3-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 6R2YV3G4YOUU626J26OZZA3FSVEK7LMI X-Message-ID-Hash: 6R2YV3G4YOUU626J26OZZA3FSVEK7LMI X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- config/rootfiles/common/dracut | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/rootfiles/common/dracut b/config/rootfiles/common/dracut index d172898ee..b08b39a30 100644 --- a/config/rootfiles/common/dracut +++ b/config/rootfiles/common/dracut @@ -189,12 +189,12 @@ usr/lib/dracut/modules.d/50drm/module-setup.sh #usr/lib/dracut/modules.d/81cio_ignore #usr/lib/dracut/modules.d/81cio_ignore/module-setup.sh #usr/lib/dracut/modules.d/81cio_ignore/parse-cio_accept.sh -#usr/lib/dracut/modules.d/90btrfs -#usr/lib/dracut/modules.d/90btrfs/80-btrfs.rules -#usr/lib/dracut/modules.d/90btrfs/btrfs_device_ready.sh -#usr/lib/dracut/modules.d/90btrfs/btrfs_finished.sh -#usr/lib/dracut/modules.d/90btrfs/btrfs_timeout.sh -#usr/lib/dracut/modules.d/90btrfs/module-setup.sh +usr/lib/dracut/modules.d/90btrfs +usr/lib/dracut/modules.d/90btrfs/80-btrfs.rules +usr/lib/dracut/modules.d/90btrfs/btrfs_device_ready.sh +usr/lib/dracut/modules.d/90btrfs/btrfs_finished.sh +usr/lib/dracut/modules.d/90btrfs/btrfs_timeout.sh +usr/lib/dracut/modules.d/90btrfs/module-setup.sh #usr/lib/dracut/modules.d/90crypt #usr/lib/dracut/modules.d/90crypt/crypt-cleanup.sh #usr/lib/dracut/modules.d/90crypt/crypt-lib.sh From patchwork Sat Mar 23 10:56:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7662 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3K4h0Wz3wtq for ; Sat, 23 Mar 2024 10:57:01 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x351nGdzFLJ; Sat, 23 Mar 2024 10:56:49 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3514vDz32vb; Sat, 23 Mar 2024 10:56:49 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2y3F8cz32bJ for ; Sat, 23 Mar 2024 10:56:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2y10xNzT1; Sat, 23 Mar 2024 10:56:42 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=diIZ9XvCF91NQbX6Xg1L3lxTwvU2StVfXiirRdmY7JU=; b=8G6gsLOzagQskOxni5CgV3wtEJ4NcJXUdttn+75PcBm/vc2PmFTbG6bk4nBf4nRnjz2wEc 57QWdhtqpJVtIUBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=diIZ9XvCF91NQbX6Xg1L3lxTwvU2StVfXiirRdmY7JU=; b=b33iJvsgMNjil8MqitavygoIigiNJ12a1nudTloLl1RueQjwBWMuB+Xl69bc8TqaHmGTe1 ONaH2+jq76X+8aBZINMntqXH/UxIKsqvv4gtrebn8D8uFkwghh0JwY6R2R97sUIApj+llR eSYrgKvEaCWDjIl5cc9+loC6Qsg7cBD+ax17gIwkJDBTeVA1hR/qF+HDxONytZM6cHNg8A sFfFAA0qhlk1eU1+cvbsj4LcrPO5u2LGFcx5SdKD6TcBya2CgzprHklSayMxtGCiBF7sWY ZTwk7XProWlmVN5rzStaMOC0LChkc7VuqyRefqguc+um/I+GvB0E9YUCBlO4+g== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 04/12] installer: Ensure to always create the /boot directory. Date: Sat, 23 Mar 2024 11:56:21 +0100 Message-Id: <20240323105629.371511-4-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: SIYKFPCD7IJES6PD22ZQ45UWKVNG73SS X-Message-ID-Hash: SIYKFPCD7IJES6PD22ZQ45UWKVNG73SS X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 4d214c152..969c47508 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); From patchwork Sat Mar 23 10:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7663 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3L3ZbHz3ww6 for ; Sat, 23 Mar 2024 10:57:02 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x39248gzFLf; Sat, 23 Mar 2024 10:56:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x362RJpz32vl; Sat, 23 Mar 2024 10:56:50 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2y6267z32vX for ; Sat, 23 Mar 2024 10:56:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2y3WnhzcG; Sat, 23 Mar 2024 10:56:42 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gw0lHbSI8ihGFiQUE1yw0eHwyoXtV5KxilS5/t4T/Fk=; b=BAkK4beGt1j/JRrP96jLcqxS8MsoPTxCvf45y39+9hQvXDMspLF6RHaGNkNGBPq5S9PBbA aSwgGFseoRMqv6DQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gw0lHbSI8ihGFiQUE1yw0eHwyoXtV5KxilS5/t4T/Fk=; b=LmbOPza43WBJOqpUG0/IaYjmKH9Ew+99W4tzfwgYPSoUgn2lv12FMaYEcQ8tsRcd2E5xvW GaOwUa4ccfBMK0iFCmQ1wYmuvISNnn6Oq+WBb9T6bAwuQa7KeJqBCBPq9rAO9r3wgmsjWK erVcwsoJMDo2lDUwPWMO8epIhFEvSApYUmqLCOAfbZZr8V19sLmdYDaqOOpbjFz+47XHcu KBtt7woD/+xf5uzoz6W4JgRPhbAa1H3M6Haxu+jaNQg3ImVuj92ZHHhwXD/UrRP/xnQ0Jr hvwg3GGeI5RsRaQ0V7Zc07cFMhVjRpOyxmZ+4kcQR2jCVixzsS15WUwxUaGy5g== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 05/12] installer: Disable own boot partition when using BTRFS Date: Sat, 23 Mar 2024 11:56:22 +0100 Message-Id: <20240323105629.371511-5-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: T2YNWGY57DRNJEEGDOD7JQUC2CLYURXX X-Message-ID-Hash: T2YNWGY57DRNJEEGDOD7JQUC2CLYURXX X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --- src/installer/hw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 969c47508..11dbcd96d 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -563,7 +563,12 @@ static int hw_calculate_partition_table(struct hw* hw, struct hw_destination* de dest->size_bootldr = 0; } - dest->size_boot = hw_boot_size(dest); + // Disable seperate boot partition for BTRFS installations. + if(dest->filesystem == HW_FS_BTRFS) { + dest->size_boot = 0; + } else { + dest->size_boot = hw_boot_size(dest); + } // Create an EFI partition when running in EFI mode if (hw->efi) From patchwork Sat Mar 23 10:56:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7664 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3M28rdz3wtq for ; Sat, 23 Mar 2024 10:57:03 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x392YrqzFLr; Sat, 23 Mar 2024 10:56:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x363mWmz32vr; Sat, 23 Mar 2024 10:56:50 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2z1pznz32vX for ; Sat, 23 Mar 2024 10:56:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2y6Jwxz4Rt; Sat, 23 Mar 2024 10:56:42 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZwGrJq3MIfge6fO4qmL/rhFzTnFqhoCYZClf3w7drYU=; b=oWtcaWCWSV3LPCvxhW15IDoRb2sbhPC/Mn0CC4vvjOoM3O6zBWt7TCZei8Nkz6QYNDOZLf oJU20iG8Sa6UIeAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZwGrJq3MIfge6fO4qmL/rhFzTnFqhoCYZClf3w7drYU=; b=tjZ2eSfFTCVybRB8t2h/gw9HHRnbJbrNTDdc626Suel14xkkU9SaB1oPkmLrM+ccfy/9Nh Z+0uU57Jy2L0qGdmZYR4zmP0QpPLunXG6YUNnC0wzZtOcF7gzWcc/I08CpDZXntjFTqpcI jdnsaygGJ3wwLw9r2xQX1Zo2+2Z/ugH6SmYYp4LXq1PYInokoF0Wx4HxArjYQZSC6jHfwM vKzYvpI1yE23k6ncIOOegGEnnNTktOmwMZYiMjxejYnuKh4JoiHv789Bfo3e9tHvAQQuvi jT9OrZU30miEDgvmvmopoGNK6Q38lcqbEdnULk0lbtioj7THE4Y6EsE7yz4qdQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 06/12] installer: Add code to create a BTRFS subvolume layout Date: Sat, 23 Mar 2024 11:56:23 +0100 Message-Id: <20240323105629.371511-6-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: OVYQF6BKBOL2SKTRB6RVVQHZVMXBDV7Z X-Message-ID-Hash: OVYQF6BKBOL2SKTRB6RVVQHZVMXBDV7Z X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-- src/installer/hw.h | 20 ++++++++++++ 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 11dbcd96d..8396d83cf 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -810,6 +810,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) { @@ -829,7 +830,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 -f %s", path); + r = hw_create_btrfs_layout(path, output); + + return r; // FAT32 } else if (fs == HW_FS_FAT32) { @@ -838,7 +841,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; } @@ -875,6 +878,59 @@ int hw_create_filesystems(struct hw_destination* dest, const char* output) { return 0; } +int hw_create_btrfs_layout(const char* path, const char* output) { + const struct btrfs_subvolumes* subvolume = NULL; + char cmd[STRING_SIZE]; + char volume[STRING_SIZE]; + int r; + + r = snprintf(cmd, sizeof(cmd), "/usr/bin/mkfs.btrfs -f %s", path); + if (r < 0) { + return r; + } + + // Create the main BTRFS file system. + 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 list of subvolumes to create. + for ( subvolume = btrfs_subvolumes; subvolume->name; subvolume++ ) { + r = snprintf(volume, sizeof(volume), "%s", subvolume->name); + + // Abort if snprintf fails. + if (r < 0) { + return r; + } + + // Call function to create the subvolume + r = hw_create_btrfs_subvolume(output, volume); + + if (r) { + return r; + } + } + + // Umount the main BTRFS after subvolume creation. + r = hw_umount(DESTINATION_MOUNT_PATH, 0); + + if (r) { + return r; + } + + return 0; +} + int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { char target[STRING_SIZE]; @@ -1224,3 +1280,23 @@ 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]; + int r; + + // Abort if the command could not be assigned. + r = snprintf(command, sizeof(command), "/usr/bin/btrfs subvolume create %s/%s", DESTINATION_MOUNT_PATH, subvolume); + if (r < 0) { + return r; + } + + // Create the subvolume + r = mysystem(output, command); + + if (r) { + return r; + } + + return 0; +} diff --git a/src/installer/hw.h b/src/installer/hw.h index e5ee65a6d..73a5233e2 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -104,6 +104,26 @@ struct hw_destination { unsigned long long size_root; }; +// Struct to define the BTRFS subvolumes layout +static const struct btrfs_subvolumes { + const char* name; + const char* mount_path; +} btrfs_subvolumes[] = { + { "@", "/" }, + { "@snapshots", "/.snapshots" }, + { "@home", "/home" }, + { "@root", "/root" }, + { "@cache", "/var/cache" }, + { "@backups", "/var/ipfire/backup" }, + { "@lib", "/var/lib" }, + { "@logs", "/var/log" }, + { "@mails", "/var/mail" }, + { "@tmp", "/var/tmp" }, + + // Sentinel + { NULL }, +}; + struct hw* hw_init(); void hw_free(struct hw* hw); From patchwork Sat Mar 23 10:56:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7665 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3N35jvz3wtq for ; Sat, 23 Mar 2024 10:57:04 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3C5BzNzFM0; Sat, 23 Mar 2024 10:56:55 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3960gbz32vY; Sat, 23 Mar 2024 10:56:53 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x2z4Hdfz32bJ for ; Sat, 23 Mar 2024 10:56:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2z22wrzFKr; Sat, 23 Mar 2024 10:56:43 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YIDZP/bX32eOFNtrgGZHJYklKDUYcKOVfg2YqBzG/K4=; b=O8CHmc9As8K6b0v7j+lrlPekinWfpSYJ19h81mmxQ2Eeowuk10FCXYlTbZ+JwUutAb0kB+ bWCvtZOqDFwgskCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YIDZP/bX32eOFNtrgGZHJYklKDUYcKOVfg2YqBzG/K4=; b=sgWn1rOdPNE+trThP491zVnQPSu/VwUT92ttuHOSvVzSdHM/dQM32a18mSrjAg/yHzNQhq wW9iOm489LS+P+lkq3iUBoSiK2/DAI36zb6tH2SkM9OdLBnZJJO+nv+dOYpqUpbriRJ4kW EG+ChthPvsF/4NYtcYk4g58XQl8OKnLZobr4eroljGUNLdMkXVxyGbpCqOG/Y3Tn+0lLlg 7LVyIXJV7Bn+1iCZDSs3ODdzEAU+J5b1sWwOJjDoebKCb1MO6+XzQylcZXWHI889F1R9GL /r4hdtAEV5Zd4OVcJdoWuK2dSei0kd6vb3JtkerXUN8aQZpAdbEwUkn3OYLbRw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 07/12] installer: Add recurisve mkdir function Date: Sat, 23 Mar 2024 11:56:24 +0100 Message-Id: <20240323105629.371511-7-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: VS5B5QWFM3A56ZHTTPWPLLHB7Z46BL4R X-Message-ID-Hash: VS5B5QWFM3A56ZHTTPWPLLHB7Z46BL4R X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/installer/hw.c b/src/installer/hw.c index 8396d83cf..3fa8b889e 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1281,6 +1281,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]; int r; From patchwork Sat Mar 23 10:56:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7666 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3P2b4Mz3wtq for ; Sat, 23 Mar 2024 10:57:05 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3D2Q6HzFL2; Sat, 23 Mar 2024 10:56:56 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3B0Fgmz32vk; Sat, 23 Mar 2024 10:56:54 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3001dDz32vb for ; Sat, 23 Mar 2024 10:56:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x2z4tmzzT1; Sat, 23 Mar 2024 10:56:43 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nrZ2KM5q3zSSQapcaV575WqCvTnY7Ia1U1uqx7nOTS8=; b=xQk21OuvC+0fq3kJtqDIFVC3ECklhFGrJGthschg05ma1metyaxJB2zDwHYA8N5cB7eSJ/ uzD9cwkPiC2rdJCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nrZ2KM5q3zSSQapcaV575WqCvTnY7Ia1U1uqx7nOTS8=; b=Hx4PhKpKoWOjgKAVNeDlieG9foy/nLmaEhhNEQGsl+iQauVAmEhPodeAjYPozl2E7Eo7Bn Wn2tkDC2Z7ArnR70guyt0ecasL6izDRSWbi6pITGMJrYGPNCGua/1Q46Z4IYq5lNJ/HZU3 ynWijqfKsyIo24hpaq2oJv6lLpx5Z++7vaPDwZjToOQCs0g+CwrCeJF6fCta3Y1Dm0yJM1 7MtF/rowszMCNn9V6HQKRQTK9+YHFy7M0bOnI8Gy3u7H+OCkZJSJaolBqpmYG+vX4px/Yi Uww0ufSdP05DgJ8lIV0QAcxMOogmiObTYAGCPOnlByaOlPRQUem4ihHaiZ6COQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 08/12] installer: Allow writing to the debug console from anywhere Date: Sat, 23 Mar 2024 11:56:25 +0100 Message-Id: <20240323105629.371511-8-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: DCBXKH2MGXMRXED23DSFLOWJIKTHZEW4 X-Message-ID-Hash: DCBXKH2MGXMRXED23DSFLOWJIKTHZEW4 X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 2 ++ src/installer/main.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 3fa8b889e..ba6064cf5 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -44,6 +44,8 @@ #include "hw.h" +extern FILE* flog; + static int system_chroot(const char* output, const char* path, const char* cmd) { char chroot_cmd[STRING_SIZE]; diff --git a/src/installer/main.c b/src/installer/main.c index 47daccdaa..30f02d8cb 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -29,6 +29,8 @@ extern char url[STRING_SIZE]; +FILE* flog = NULL; + static int newtChecklist(const char* title, const char* message, unsigned int width, unsigned int height, unsigned int num_entries, const char** entries, int* states) { @@ -377,7 +379,6 @@ int main(int argc, char *argv[]) { sethostname(DISTRO_SNAME, 10); /* Log file/terminal stuff. */ - FILE* flog = NULL; if (argc >= 2) { logfile = argv[1]; From patchwork Sat Mar 23 10:56:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7667 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3Q3rNWz3wtq for ; Sat, 23 Mar 2024 10:57:06 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3F1CnfzFMF; Sat, 23 Mar 2024 10:56:57 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3B1zv3z32vr; Sat, 23 Mar 2024 10:56:54 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x302d2Gz32vH for ; Sat, 23 Mar 2024 10:56:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x300L5Vz4Rt; Sat, 23 Mar 2024 10:56:43 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ir0APRKSp65ziwxEt1nN4BMrv+OX3uWfPgCnlVXX0kc=; b=vYYZ/a28KL7GVD+AdeRPW6upY2iGDTysCoBocAOn8VINUfJ2PxFuxcOpPCQyltkba3L9HL 38Lw2cI0bbXfxAAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ir0APRKSp65ziwxEt1nN4BMrv+OX3uWfPgCnlVXX0kc=; b=DuSFq67jp851zFjs9KVD7X8qURqaFdGo2AtYRRFYhsi72AZujgKSD/HqG1IfCGst4GPTta wpmugbArxR8KjzHaz293osCQRQtAxUbR2fL9zA9xBqD9aIBCCibRG+6QThd+Zu4MreafGD 7ABZAuOeuUkUhtGf5oXFxAhrSxAXTqXXb84XU0CVey7WB3jjS8G16MTIf3Z3zMSxKSQJEj VSfYZc6V5d0+G/PuBJp1SiBTe4HEyFFTdMxLQhB0Uq8seB6I4r7ZG9F3mod7PoxFB3dGK5 2J/vjJviGvRvRptbrYI8p6eMt39viV2qvpbiYxSXaheHBg0sW1bTgCbXx4BXOw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 09/12] installer: Mount BTRFS layout before installing the system Date: Sat, 23 Mar 2024 11:56:26 +0100 Message-Id: <20240323105629.371511-9-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: GYKIGUOTCZR2RNYQKKM55EKSL4WSHX7E X-Message-ID-Hash: GYKIGUOTCZR2RNYQKKM55EKSL4WSHX7E X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 57 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index ba6064cf5..8ee6c5726 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -935,6 +935,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 == '/'); @@ -962,9 +963,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); @@ -1028,6 +1037,48 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { return 0; } +int hw_mount_btrfs_subvolumes(const char* source) { + const struct btrfs_subvolumes* subvolume = NULL; + char path[STRING_SIZE]; + char options[STRING_SIZE]; + int r; + + // Loop through the list of known subvolumes. + for ( subvolume = btrfs_subvolumes; subvolume->name; subvolume++ ) { + // Assign subvolume path. + r = snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, subvolume->mount_path); + + if (r < 0) { + return r; + } + + // Assign subvolume name. + r = snprintf(options, sizeof(options), "subvol=%s,", subvolume->name); + if (r < 0) { + return r; + } + + // Create the directory. + r = hw_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO); + + // Abort if the directory could not be created. + if(r != 0 && errno != EEXIST) + return r; + + // Print log message + fprintf(flog, "Mounting subvolume %s to %s\n", subvolume->name, subvolume->mount_path); + + // 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]; From patchwork Sat Mar 23 10:56:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7668 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3Q66cpz3ww6 for ; Sat, 23 Mar 2024 10:57:06 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3F1MptzFMK; Sat, 23 Mar 2024 10:56:57 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3B3Y4mz32vv; Sat, 23 Mar 2024 10:56:54 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x305CCsz32bJ for ; Sat, 23 Mar 2024 10:56:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x302sgmzT1; Sat, 23 Mar 2024 10:56:44 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iiVqX5Lz+LjjaUT77Ic9eYOFz215PqLT+eAMLWl/1c4=; b=ca8V0NYMC3Hjvn2pclWdtVHHa9tgBEqq0oAjDSkrDQPLbCS/34gWzyLrhFcv+mViUskD7G QKp1c+EXbuhuhIAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iiVqX5Lz+LjjaUT77Ic9eYOFz215PqLT+eAMLWl/1c4=; b=wvREnCVWXsxKoVEJTuBefgpldI2prrF+SFJHEdm2jwEu7dCDKYSD265MbUOz8D/S2XGdGf m/NVzKxQG9ha1K7nI9ulDgH4qrWdgtgcL58pHV/D8eWsemNgJroOU1zv9uzukPRd2itv4B yrnxNNDLzSohvEnQ6qt8zRUwfX622EXfhfMAEGrkp7a9vAQO2nO8h9LQD4YMoce+VZLc3X aA+I+t+ZBvj5m6lIfjpYpghc53SVCM7DCqAW6hETD1N0j7P7x/ornhxiVENwnq478UkIgp jNWrhEsjgDDaOYuYqeFEqqeRGe7gzqpN/OFkijFP731mX/KqJmgqL+ySxBTsmA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 10/12] installer: Define common mount options for BTRFS volumes Date: Sat, 23 Mar 2024 11:56:27 +0100 Message-Id: <20240323105629.371511-10-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: ZZFRCWQAXCNBK6H75SH4FMQ7SAWYHROV X-Message-ID-Hash: ZZFRCWQAXCNBK6H75SH4FMQ7SAWYHROV X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: As default we are using zstd for compression with level 1 Signed-off-by: Stefan Schantl --- src/installer/hw.c | 2 +- src/installer/hw.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 8ee6c5726..5665cb955 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1053,7 +1053,7 @@ int hw_mount_btrfs_subvolumes(const char* source) { } // Assign subvolume name. - r = snprintf(options, sizeof(options), "subvol=%s,", subvolume->name); + r = snprintf(options, sizeof(options), "subvol=%s,%s", subvolume->name, BTRFS_MOUNT_OPTIONS); if (r < 0) { return r; } diff --git a/src/installer/hw.h b/src/installer/hw.h index 73a5233e2..7fbea86de 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) From patchwork Sat Mar 23 10:56:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7670 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3S6SZRz3ww6 for ; Sat, 23 Mar 2024 10:57:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3F4whwzFMN; Sat, 23 Mar 2024 10:56:57 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3B4qK3z32w1; Sat, 23 Mar 2024 10:56:54 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3157qMz32vH for ; Sat, 23 Mar 2024 10:56:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x305VyVzFLH; Sat, 23 Mar 2024 10:56:44 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F5sw6K7HT7AO0Qw9AEzkALA4mGF285b9uM0+bE2cIb8=; b=zP9fCeoBtMXaoqWuRgOnbqdloEFxAlTTYhcv1bp112sxQ3qWwXWRqdSwFZteU21xxfnwb+ /qoqklRD2dsnETAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F5sw6K7HT7AO0Qw9AEzkALA4mGF285b9uM0+bE2cIb8=; b=QILIVANcwytygA/z59kCnNHIHLT7x58AdnkyCAn/LtyRX3eYtjGgiQGXJpEhiEzeBCq+4r xwYDOzb9XoQ5y+7XGcFe++Kqelqi7uaZob4AFkIJjv30swtOVdDqHc08dAnQ+TyH8PPe67 eIo4NzcfxPQiBKb0pwu/d4USveqndCGzI8DGcC7wysAVy3aYwmCGbuuIFCEycBOBgAog/M lf1rZMEQ+HuCuLbrDHVgDnmshcXrpS0VC37QnixgT5Dwg+WfMAXU+DrixKGnyNTMaUpusT T8aSHVw0jBapEhLh7ytTY7FbYxJ2bXP9SuteGYGI44DOUczfxiHH4OrMNISZOg== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 11/12] installer: Add code to proper unmount the BTRFS layout Date: Sat, 23 Mar 2024 11:56:28 +0100 Message-Id: <20240323105629.371511-11-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: TP34USY6PSDJYRGA3BLFAKZ5CC6J7Q7H X-Message-ID-Hash: TP34USY6PSDJYRGA3BLFAKZ5CC6J7Q7H X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 72 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 5665cb955..3b26920d1 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1123,13 +1123,83 @@ 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() { + const struct btrfs_subvolumes* subvolume = NULL; + char path[STRING_SIZE]; + int counter = 0; + int retry = 1; + int r; + + do { + // Reset the retry marker + retry = 0; + + // Loop through the list of subvolumes + for (subvolume = btrfs_subvolumes; subvolume->name; subvolume++) { + // Abort if the subvolume path could not be assigned. + r = snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, subvolume->mount_path); + + if (r < 0) { + return r; + } + + // Try to umount the subvolume. + r = umount2(path, 0); + + // Handle return codes. + if (r) { + switch(errno) { + case EBUSY: + // Set marker to retry the umount. + retry = 1; + + // Ignore if the subvolume could not be unmounted yet, + // because it is still used. + continue; + + case EINVAL: + // Ignore if the subvolume already has been unmounted + continue; + case ENOENT: + // Ignore if the directory does not longer exist. + continue; + default: + fprintf(flog, "Could not umount %s from %s - Error: %d\n", subvolume->name, path, r); + return r; + } + } + + // Print log message + fprintf(flog, "Umounted %s from %s\n", subvolume->name, path); + } + + // Abort loop if all mountpoins got umounted + if (retry == 0) { + return 0; + } + + // Abort after five failed umount attempts + if (counter == 5) { + return -1; + } + + // Increment counter. + counter++; + } while (1); +} + int hw_destroy_raid_superblocks(const struct hw_destination* dest, const char* output) { char cmd[STRING_SIZE]; From patchwork Sat Mar 23 10:56:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7669 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4V1x3R4Lgsz3wtq for ; Sat, 23 Mar 2024 10:57:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4V1x3F5CMwzFMS; Sat, 23 Mar 2024 10:56:57 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4V1x3B6593z32w4; Sat, 23 Mar 2024 10:56:54 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4V1x320kdXz32vH for ; Sat, 23 Mar 2024 10:56:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4V1x3110tFzT1; Sat, 23 Mar 2024 10:56:45 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1711191405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jR6eOiJkv/Uncwr2Tljo2rq4PwdZQHf/FPVmGcGnTcI=; b=Ecnyyv/ACd+kkMb/etXqSYuSwSMxwlxuf0I8JSFjL68QvEhMy8YFKBcqm0CpLGIrkeeqWo 0KMwd2CXm3INVZDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1711191405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jR6eOiJkv/Uncwr2Tljo2rq4PwdZQHf/FPVmGcGnTcI=; b=hgkAEi8nBdYPay/Zo9+orpSU/7Faaw42Tjit6vGhOvH3IB+NMc2xQAuJMZLcqUuxztdbGY d8GGXxkKj6l3Pd2PXy0ugazuehABDeNLqhShS2YkqMWQ/vB6nQd0gC8zbPqrvtelhGgWHl MXSxa3d79tqsP/qFZBTBU1KLGXn/0+o7F0GzMEE0iyJ73FnpZ4s0tlqi25EXuvKyHqQxBZ /5Msnf1iQrYolf+MFVqc5eUAMJ3XPPMBf0Ym9SYvZRXOfxPVqxrmKcSHrPzoq2xNJ6vhp9 Tb0Chmjn8VDg139DtNmcqj2COB0ZvRUJwjkvqzO9qiolcG1/GRStKQSxJl+8EQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2 12/12] installer: Add code to correctly write the fstab when installing on BTRFS Date: Sat, 23 Mar 2024 11:56:29 +0100 Message-Id: <20240323105629.371511-12-stefan.schantl@ipfire.org> In-Reply-To: <20240323105629.371511-1-stefan.schantl@ipfire.org> References: <20240323105629.371511-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 5KQNDMFSQZXZR4HUBSTR33B5D35RFDTJ X-Message-ID-Hash: 5KQNDMFSQZXZR4HUBSTR33B5D35RFDTJ X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 3b26920d1..77789e35e 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1319,11 +1319,13 @@ static char* hw_get_uuid(const char* dev) { #define FSTAB_FMT "UUID=%s %-8s %-4s %-10s %d %d\n" int hw_write_fstab(struct hw_destination* dest) { + const struct btrfs_subvolumes* subvolume = NULL; FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/fstab", "w"); if (!f) return -1; char* uuid = NULL; + char mount_options[STRING_SIZE]; // boot if (*dest->part_boot) { @@ -1359,7 +1361,22 @@ 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 list of subvolumes + for (subvolume = btrfs_subvolumes; subvolume->name; subvolume++) { + // Abort if the mount options could not be assigned + int r = snprintf(mount_options, sizeof(mount_options), "defaults,%s,subvol=%s", BTRFS_MOUNT_OPTIONS, subvolume->name); + if (r < 0) { + return r; + } + + // Write the entry to the file + fprintf(f, FSTAB_FMT, uuid, subvolume->mount_path, "btrfs", mount_options, 1, 1); + } + } else { + fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + } + free(uuid); }