summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-hooks/05-disable_swapon
blob: 16af130d71373132a8a4e4bf6e949f598bba4096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

set -e

echo "Disabling swapon"

# Disable swapon to avoid initscripts to setup swap space.
# Rationale: security-in-depth model.

SWAPON=/sbin/swapon

# Move any /sbin/swapon installed by any package out of the way,
# now (--rename) as well for any future one (hint: apt-get upgrade...).
dpkg-divert --rename --add /sbin/swapon

# Install a custom noop swapon executable instead.
cat > $SWAPON << 'EOF'
#!/bin/sh
/bin/true
EOF
chmod 755 $SWAPON