You could use squashmount and callKhumarahn wrote:What is the easiest way to keep portage in squashfs, and recompress in on emerge --sync?
Code: Select all
squashmount remount [repos mount point]Thanks! This worked beautifully. I get a strange error on squashmount remount:mv wrote:You could use squashmount and callin an /etc/portage/postsync.d hook.Code: Select all
squashmount remount [repos mount point]
Code: Select all
mount: /usr/portage: wrong fs type, bad option, bad superblock on overlayfs, missing codepage or helper program, or other error.Code: Select all
#!/usr/bin/perl (this is only for editors)
@order = qw(overlay overlayfs aufs! unionfs-fuse! unionfs??# funionfs??#);
$rm_changes = $rm_workdir = $rm_readonly = 0;
my $defaults = {
COMPRESSION => 'xz',
COMPOPT_XZ => ['-Xbcj', 'arm'],
};
@mounts = (
standard_mount('portage', '/usr/portage', $defaults),
);
1; # The last executed command in this file should be a true expressionCode: Select all
#!/bin/sh
# This file remounts the squashmount mount-point "gentoo" after each syncing
# of the "gentoo" repository.
set -u
repository_name=$1
sync_uri=$2
repository_path=$3
# Run only for repository gentoo:
[ x"$repository_name" = x'gentoo' ] || exit 0
# Run only if mount-point portage is configured
[ x"$(squashmount --quiet print-tag portage 2>/dev/null)" = x'portage' ] || exit 0
squashmount remount portagesquashmount has its [topic=1079548]own thread[/topic] and a github bugtracker, so we should perhaps not clutter the discussion here.Khumarahn wrote:I get a strange error on squashmount remount
Code: Select all
squashmount listThis option (and the working directory) are used for the variant in newer kernels; squashmount calls this variant "overlay".Khumarahn wrote:--workdir option
This way, first the variant without a working directory is attempted. However, you will have to remove that line once you upgrade to >=linux-3.18./etc/squashmount.pl wrote:@order=qw(overlayfs!? overlay!? aufs! unionfs-fuse! unionfs! funionfs!);
Code: Select all
@order = qw(overlayfs? overlay)Code: Select all
$obsolete_overlayfs = 1;
Code: Select all
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
DESCRIPTION="Use squashfs and overlays for portage tree"
HOMEPAGE="https://www.brunsware.de/blog/portage-tree-squashfs-overlayfs"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
DEPEND="sys-fs/squashfs-tools"
RDEPEND="${DEPEND}"
BDEPEND=""
pkg_setup() {
mkdir "${S}"
}
src_install() {
newinitd "${FILESDIR}"/squashfs_portage-init.d squash_portage
newconfd "${FILESDIR}"/squashfs_portage-conf.d squash_portage
}
Code: Select all
# cat /opt/scripts/squash_it/portage
#! /bin/bash
#set -x
set_vars () {
OVFS="${OVFS:-/media/overlay}"
INSTANCE="${INSTANCE:-$(basename $0)}"
TARGET="${TARGET:-/usr/${INSTANCE}}"
SQDIR="${OVFS}/squash"
LOWER="${OVFS}/lower/${INSTANCE}"
UPPER="${OVFS}/upper/${INSTANCE}"
WORK="${OVFS}/work/${INSTANCE}"
TMP="${OVFS}/tmp"
SQNAME="${INSTANCE}"
SQFS="${SQDIR}/${SQNAME}"
SQCMD="/usr/bin/mksquashfs"
# excluding files does not work as reliably as I'd like, but git it already compressed, so squashing it mostly wastes CPU time and clogs RAM and disk during update. We're better off leaving it in the overlayfs.
SQPARAM="-quiet -no-progress -comp xz -Xdict-size 100% -wildcards -e '.git/'"
# This was for testing, not needed anymore, but I'm too lazy to remove it right now
MODE="eval"
}
delay (){
echo "### running command: ==> $@ <=="
sleep 5
eval "$@"
}
main (){
set_vars
case $1 in
"sudo: reset" )
"${MODE}" /bin/umount -l "${TARGET}"
"${MODE}" /bin/umount -l "${LOWER}"
"${MODE}" rm -rf "${LOWER}" "${UPPER}" "${WORK}" "${TMP}" "${SQFS}"
;&
bootstrap )
"${MODE}" mkdir -p "${LOWER}" "${UPPER}" "${WORK}" "${TMP}" "${SQDIR}"
"${MODE}" mkdir "/tmp/empty.$$"
"${MODE}" "${SQCMD}" "/tmp/empty.$$" "${SQFS}" ${SQPARAM}
"${MODE}" rmdir "/tmp/empty.$$"
echo "disk usage (squash + upper) and uncompressed data size (lower) after bootstrap"
du -hs "${SQFS}" "${LOWER}" "${UPPER}"
main mount
main update
;;
update )
"${MODE}" emerge --sync -q || exit 1
echo "disk usage (squash + upper) and uncompressed data size (lower) after sync"
du -hs "${SQFS}" "${LOWER}" "${UPPER}"
;&
squash )
"${MODE}" "${SQCMD}" "${TARGET}" "${TMP}/${SQNAME}" ${SQPARAM} || exit 2
;&
clean )
"${MODE}" /bin/umount -l "${TARGET}" || exit 3
"${MODE}" /bin/umount -l "${LOWER}" || exit 4
"${MODE}" mv "${TMP}/${SQNAME}" "${SQFS}" || exit 5
"${MODE}" find "${UPPER}/ -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} \+" || exit 6
;&
mount )
"${MODE}" /bin/mount -o loop "${SQFS}" "${LOWER}" || exit 7
"${MODE}" /bin/mount -t overlay overlay -o "lowerdir=${LOWER},upperdir=${UPPER},workdir=${WORK}" "${TARGET}" || exit 8
echo "disk usage (squash + upper) and uncompressed data size (lower) after remount"
du -hs "${SQFS}" "${LOWER}" "${UPPER}"
;;
*)
echo "usage: $0 < sudo: reset | bootstrap | update | squash | clean | mount >"
esac
}
main "$@"
Wild guess: Some components of the paths to the links or of the links were not mounted when systemd started the service, that is, you might need to specify some dependency explicitly. But there are several other setups I can think of which can cause this: For instance, involving mount --bind or --rbind. There might also be permission problems to some components of the paths (to the links or of the links). Probably there are also things which can cause this I am not aware of: With containers (which systemd is heavily manipulating) a lot of strange things can happen.yoshi314 wrote:there is one thing worth mentioning when using systemd
i had /usr/src as a symlink to a separate volume mounted elsewhere. when i specified links to files in /usr/src in squashmount.pl , the service would fail. It would work if i did sudo squashmount start later
I had to explictly list paths to actual squash files' mount points, not traversing via symlinks. I have no clue why this happens