Skip to content

Commit

Permalink
Skip swap creation and btrfs check when we have overlayfs (#7333)
Browse files Browse the repository at this point in the history
Co-authored-by: Cédric Bosdonnat <cbosdonnat@suse.com>
  • Loading branch information
mbussolotto and cbosdo authored Aug 3, 2023
1 parent 48225fd commit 4ddb91e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
78 changes: 43 additions & 35 deletions susemanager/bin/mgr-setup
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ if [ $SWAP -eq 0 ]; then
echo "Not enough space on /. Not adding swap space. Good luck..."
else
FSTYPE=`df -T / | tail -1 | awk '{print $2}'`
# Ignore for overlay too
if [ $FSTYPE == "btrfs" ]; then
echo "Will *NOT* create swapfile on btrfs. Make sure you have enough RAM!"
elif [ $FSTYPE == "overlay" ]; then
echo "Will *NOT* create swapfile in a container!"
else
if [ -f /SWAPFILE ]; then
swapoff /SWAPFILE
Expand Down Expand Up @@ -316,47 +319,52 @@ check_mksubvolume() {
}

check_btrfs_dirs() {
DIR="/var/spacewalk"
if [ ! -d $DIR ]; then
FSTYPE=`df -T \`dirname $DIR\` | tail -1 | awk '{print $2}'`
echo -n "Filesystem type for $DIR is $FSTYPE - "
if [ $FSTYPE == "btrfs" ]; then
check_mksubvolume
echo "creating nCoW subvolume."
mksubvolume --nocow $DIR
ROOT_FSTYPE=`df -T / | tail -1 | awk '{print $2}'`
if [ $ROOT_FSTYPE == "overlay" ]; then
echo "Skipping btrfs check in containers"
else
DIR="/var/spacewalk"
if [ ! -d $DIR ]; then
FSTYPE=`df -T \`dirname $DIR\` | tail -1 | awk '{print $2}'`
echo -n "Filesystem type for $DIR is $FSTYPE - "
if [ $FSTYPE == "btrfs" ]; then
check_mksubvolume
echo "creating nCoW subvolume."
mksubvolume --nocow $DIR
else
echo "ok."
fi
else
echo "ok."
echo "$DIR already exists. Leaving it untouched."
fi
else
echo "$DIR already exists. Leaving it untouched."
fi

DIR="/var/cache"
if [ ! -d $DIR ]; then
mkdir $DIR
fi
FSTYPE=`df -T $DIR | tail -1 | awk '{print $2}'`
echo -n "Filesystem type for $DIR is $FSTYPE - "
if [ $FSTYPE == "btrfs" ]; then
TESTDIR=`basename $DIR`
btrfs subvolume list /var | grep "$TESTDIR" > /dev/null
if [ ! $? -eq 0 ]; then
check_mksubvolume
echo "creating subvolume."
mv $DIR ${DIR}.sav
mksubvolume $DIR
touch ${DIR}.sav/foobar.dummy
if [ ! -d $DIR ]; then
mkdir $DIR
DIR="/var/cache"
if [ ! -d $DIR ]; then
mkdir $DIR
fi
FSTYPE=`df -T $DIR | tail -1 | awk '{print $2}'`
echo -n "Filesystem type for $DIR is $FSTYPE - "
if [ $FSTYPE == "btrfs" ]; then
TESTDIR=`basename $DIR`
btrfs subvolume list /var | grep "$TESTDIR" > /dev/null
if [ ! $? -eq 0 ]; then
check_mksubvolume
echo "creating subvolume."
mv $DIR ${DIR}.sav
mksubvolume $DIR
touch ${DIR}.sav/foobar.dummy
if [ ! -d $DIR ]; then
mkdir $DIR
fi
mv ${DIR}.sav/* $DIR
rmdir ${DIR}.sav
rm -f $DIR/foobar.dummy
else
echo "subvolume for $DIR already exists. Fine."
fi
mv ${DIR}.sav/* $DIR
rmdir ${DIR}.sav
rm -f $DIR/foobar.dummy
else
echo "subvolume for $DIR already exists. Fine."
echo "ok."
fi
else
echo "ok."
fi
}

Expand Down
1 change: 1 addition & 0 deletions susemanager/susemanager.changes.mbussolotto.ignore_overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Skip swap creation and BTRFS check when we have overlayfs

0 comments on commit 4ddb91e

Please sign in to comment.