From 2b1fbfd4bc5e8daa8fc2319af539ed82d36a20de Mon Sep 17 00:00:00 2001 From: Zhang Xiao Date: Sat, 6 Aug 2022 05:42:23 -0700 Subject: [PATCH] Debian: Break hardlinks in /var Here the root filesystem is managed by OSTree. OSTree is designed to manage/deploy read-only filesystem. For read-only filesystem, hardlink all files with same content is safe and can save disk space. It is a good principle for readonly folders like /bin, /lib and so on. While "/var" is somehow special that it is designed to store variable data files, it can not be read-only, it must be read-write. Files in "/var" should not be hardlinked together like other folders, break them to make it. Do the same for /usr/homedirs/home as it gets mounted at /var/home at runtime. Test Plan: Pass: build ISO image Pass: In runtime system, no hardlink in /var Story: 2008862 Task: 45966 Related-Bug: #1983580 Change-Id: I1a61f919e0a60f83e27b6c0bf402c20c2d43abb4 Signed-off-by: Zhang Xiao --- ...ree-install.sh-break-hardlink-in-var.patch | 43 +++++++++++++++++++ ostree/initramfs-ostree/debian/patches/series | 1 + 2 files changed, 44 insertions(+) create mode 100644 ostree/initramfs-ostree/debian/patches/0008-init-ostree-install.sh-break-hardlink-in-var.patch diff --git a/ostree/initramfs-ostree/debian/patches/0008-init-ostree-install.sh-break-hardlink-in-var.patch b/ostree/initramfs-ostree/debian/patches/0008-init-ostree-install.sh-break-hardlink-in-var.patch new file mode 100644 index 000000000..da1559d50 --- /dev/null +++ b/ostree/initramfs-ostree/debian/patches/0008-init-ostree-install.sh-break-hardlink-in-var.patch @@ -0,0 +1,43 @@ +From c4eaf35440afe4ef0473b90b32566a05f99dfbd6 Mon Sep 17 00:00:00 2001 +From: Zhang Xiao +Date: Sat, 6 Aug 2022 12:39:16 +0000 +Subject: [PATCH] init-ostree-install.sh: break hardlinks in /var + +Here the root filesystem is managed by OSTree. OSTree is designed to +manage/deploy read-only filesystem. For read-only filesystem, hardlink +all files with same content is safe and can save disk space. It is a +good principle for readonly folders like /bin, /lib and so on. While +"/var" is somehow special that it is designed to store variable data +files, it can not be read-only, it must be read-write. Files in +"/var" should not be hardlinked together like other folders, break +them to make it. + +Do the same for /usr/homedirs/home as it gets mounted at /var/home +at runtime. + +Signed-off-by: Zhang Xiao +--- + init-ostree-install.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/init-ostree-install.sh b/init-ostree-install.sh +index 0e5b8f3..f66224d 100644 +--- a/init-ostree-install.sh ++++ b/init-ostree-install.sh +@@ -1478,11 +1478,11 @@ else + mount -o $mount_flags LABEL=fluxdata /var1 + fi + if [ -d ${PHYS_SYSROOT}/ostree/1/var ] ; then +- tar -C ${PHYS_SYSROOT}/ostree/1/var/ --xattrs --xattrs-include='*' -cf - . | \ ++ tar -C ${PHYS_SYSROOT}/ostree/1/var/ --hard-dereference --xattrs --xattrs-include='*' -cf - . | \ + tar --xattrs --xattrs-include='*' -xf - -C /var1 2> /dev/null + fi + if [ -d ${PHYS_SYSROOT}/ostree/1/usr/homedirs/home ] ; then +- tar -C ${PHYS_SYSROOT}/ostree/1/usr/homedirs/home --xattrs --xattrs-include='*' -cf - . | \ ++ tar -C ${PHYS_SYSROOT}/ostree/1/usr/homedirs/home --hard-dereference --xattrs --xattrs-include='*' -cf - . | \ + tar --xattrs --xattrs-include='*' -xf - -C /var1/home 2> /dev/null + fi + +-- +2.32.0 + diff --git a/ostree/initramfs-ostree/debian/patches/series b/ostree/initramfs-ostree/debian/patches/series index 28d4fdb6d..81cd5d5ce 100644 --- a/ostree/initramfs-ostree/debian/patches/series +++ b/ostree/initramfs-ostree/debian/patches/series @@ -5,3 +5,4 @@ 0005-Make-boot-efi-mount-as-rw.patch 0006-debian-set-default-size-variables-in-install-script.patch 0007-Wait-for-devices-to-be-configured-after-boot.patch +0008-init-ostree-install.sh-break-hardlink-in-var.patch