1 |
Am 25.11.2010 12:21, schrieb Adam Carter: |
2 |
> |
3 |
> Would you share? |
4 |
> |
5 |
> +1 |
6 |
> |
7 |
> I only have an empty /sys/fs/cgroup with the following config on 2.6.36, |
8 |
> so please share the kernel config as well. |
9 |
> |
10 |
|
11 |
I guess you have to mount your cgroup there, first. The original link |
12 |
describes, how. |
13 |
|
14 |
I don't have a /sys/fs/cgroup at all. So I don't think my kernel config |
15 |
will help you. |
16 |
|
17 |
My solution isn't that great, anyway. I thought about writing an init |
18 |
script but I haven't done that yet and don't think I'll do it soon. |
19 |
|
20 |
Anyway, if you want my solution, here it is, although it's mostly |
21 |
copy'n'paste from the original link: |
22 |
|
23 |
1. Create '/usr/local/sbin/cgroup_start' with the following content: |
24 |
|
25 |
#!/bin/bash |
26 |
mkdir -p /dev/cgroup/cpu |
27 |
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu |
28 |
mkdir -m 0777 /dev/cgroup/cpu/user |
29 |
/bin/echo '/usr/local/sbin/cgroup_clean' > /dev/cgroup/cpu/release_agent |
30 |
|
31 |
(Execution right for root, only) |
32 |
|
33 |
## Please note ## |
34 |
Since I had no /sys/fs/cgroup directory to start with and I didn't want |
35 |
to fiddle with /proc or /sys, I create a new directory /dev/cgroup to |
36 |
work with. If you have a better directory, you have to adjust all |
37 |
following code snippets to work on that directory. |
38 |
|
39 |
Please also note that I use /bin/echo instead of the shell built-in |
40 |
echo. There is supposed to be a difference in write error detection |
41 |
between the both which is important to detect problems when you |
42 |
configure cgroups. |
43 |
################# |
44 |
|
45 |
2. Create '/usr/local/sbin/cgroup_clean' |
46 |
|
47 |
#!/bin/sh |
48 |
rmdir /dev/cgroup/cpu/$* |
49 |
|
50 |
(Execution right for root, only) |
51 |
|
52 |
3.a If you use OpenRC / Baselayout-2, edit /etc/conf.d/local |
53 |
|
54 |
local_start() { |
55 |
/usr/local/sbin/cgroup_start |
56 |
|
57 |
# We should always return 0 |
58 |
return 0 |
59 |
} |
60 |
|
61 |
3.b If you use Baselayout-1, edit /etc/conf.d/local.start and add |
62 |
|
63 |
/usr/local/sbin/cgroup_start |
64 |
|
65 |
## Please note ## |
66 |
It would be great to know what to do in order to stop using cgroups |
67 |
again. Then we could create a proper init script for this. Does anyone know? |
68 |
Can you just unmount it? Do you need to delete its content, first? |
69 |
################# |
70 |
|
71 |
4. Create a file /etc/bash/local/cgrouprc |
72 |
|
73 |
if [ "$PS1" ] ; then |
74 |
mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1 |
75 |
/bin/echo $$ > /dev/cgroup/cpu/user/$$/tasks |
76 |
/bin/echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release |
77 |
fi |
78 |
|
79 |
5. Edit your own ~/.bashrc file and /root/.bashrc and add the following |
80 |
line: |
81 |
|
82 |
source /etc/bash/local/cgrouprc |
83 |
|
84 |
## Please note ## |
85 |
The last two steps can be varied as you wish. The creation of a |
86 |
/etc/bash/local directory is my own policy. It is useful for collecting |
87 |
common bashrc code that all users can include as they wish. |
88 |
################# |
89 |
|
90 |
Then call `/etc/init.d/local restart` and type `source ~/.bashrc` in all |
91 |
your open shells and you are done. |
92 |
|
93 |
Hope this helps, |
94 |
Florian Philipp |