Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Created December 18, 2014 06:04
Show Gist options
  • Save lambdalisue/f8f36af29ffccdc7d485 to your computer and use it in GitHub Desktop.
Save lambdalisue/f8f36af29ffccdc7d485 to your computer and use it in GitHub Desktop.
Install cgroup-bin in Debian Wheezy with a patch
#!/usr/bin/env bash
#==============================================================================
#
# Install cgroup-bin in Debian Wheezy
#
# The following required files in a cgroup-bin package of debian wheezy are
# missing. That's why this script get these files from a package of debian
# squeeze while original init.d scripts of cgroup were not regulated to use
# in debian system.
#
# - /etc/cgconfig.conf
# - /etc/cgrules.conf
# - /default/cgconfig
# - /default/cgred
# - /init.d/cgconfig
# - /init.d/cgred
#
#==============================================================================
# Manual config ---------------------------------------------------------------
HOST="ftp.jp.debian.org"
ARCH="amd64" # https://packages.debian.org/en/squeeze/cgroup-bin
PORG=1 # 0 if you don't have porg
# Pre config ------------------------------------------------------------------
URL="http://${HOST}/debian/pool/main/libc/libcgroup/cgroup-bin_0.36.2-3+squeeze1_${ARCH}.deb"
DEB=$(mktemp /tmp/cgroup-bin.XXXXXXXX.deb)
DIR=$(mktemp -d /tmp/cgroup-bin.XXXXXXXX)
# Procedure -------------------------------------------------------------------
echo "Install cgroup-bin package of debian wheezy..."
aptitude -y install cgroup-bin
echo "Download a cgroup-bin package of Debian Squeeze..."
wget -q $URL -O $DEB
dpkg-deb -x $DEB $DIR
# mount points are changed in debian wheezy from /mnt/cgroups to /sys/fs/cgroup
sed -i -e "45,49d" $DIR/etc/cgconfig.conf
echo "Install missing required files from a cgroup-bin package of Squeeze..."
if [[ $PORG -eq 1 ]]; then
porg -l -p "cgroup-bin-patch" "cp -rf $DIR/etc/* /etc"
else
cp -rf $DIR/etc/* /etc
fi
rm -rf $DEB
rm -rf $DIR
# activate init scripts
update-rc.d cgconfig defaults
/etc/init.d/cgconfig start
update-rc.d cgred defaults
/etc/init.d/cgred start
echo "************************************************************************"
echo
echo "Note:"
echo " If you have not mounted 'cgroup', add the following line in "
echo " '/etc/fstab'"
echo
echo " cgroup /sys/fs/cgroup cgroup defaults 0 0"
echo
echo "Note:"
echo " Debian disables the 'memory' subsystem by default in the kernel."
echo " To activate it, add 'cgroup_enable=memory' to "
echo " 'GRUB_CMDLINE_LINUX_DEFAULT' in '/etc/default/grub' file and reboot."
echo
echo "Note:"
echo " If the 'cpuset' subsystem is activated, you have to set 'cpuset.cpus'"
echo " and 'cpuset.mems' correctly. Otherwise 'cgexec' or 'cgclassify' will"
echo " complain 'cgroup change of group failed' and you may get confused."
echo " To see more useful information, execute the command with"
echo " 'CGROUP_LOGLEVEL=5 gcexec <options>'."
echo
echo "************************************************************************"
@lambdalisue
Copy link
Author

sudo ./install_cgroup_debian_wheezy.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment