Thanks a ton for the wiki page! I 'smartened' up the scripts a bit to deal
with the various locations and kernel versions:
cgroup_clean:
#!/bin/sh
if [ -d /sys/fs/cgroup ] ; then
  cdir=/sys/fs/cgroup
else
  cdir=/dev/cgroup
fi

rmdir /dev/cgroup/$*

cgroup_start:
#!/bin/sh

if [ -d /sys/fs/cgroup ] ; then
  cdir=/sys/fs/cgroup
else
  cdir=/dev/cgroup
  mkdir $cdir
fi

kern_version=`uname -r|cut -d\- -f1|tr -d '.'`
if [ $kern_version -lt 2638 ] ; then
  mount -t cgroup cgroup $cdir -o cpu
else
  mount -t cgroup cgroup $cdir -o cpu,blkio
fi

mkdir -m 0777 $cdir/user

/bin/echo '/root/bin/cgroup_clean' > $cdir/release_agent

bashrc:
# Turn on cgroups
if [ "$PS1" ] ; then
  if [ -d /sys/fs/cgroup ] ; then
    cdir=/sys/fs/cgroup
  else
    cdir=/dev/cgroup
  fi

  mkdir -p -m 0700 $cdir/user/$$ > /dev/null 2>&1
  /bin/echo $$ > $cdir/user/$$/tasks
  /bin/echo '1' > $cdir/user/$$/notify_on_release
fi


Hope someone finds that useful.

Reply via email to