The Following User Says Thank You to mr_jrt For This Useful Post: | ||
|
2011-11-27
, 22:27
|
Posts: 560 |
Thanked: 422 times |
Joined on Mar 2011
|
#2
|
|
2011-11-27
, 22:34
|
Posts: 1,100 |
Thanked: 2,797 times |
Joined on Apr 2011
@ Netherlands
|
#3
|
|
2011-11-27
, 22:36
|
Posts: 249 |
Thanked: 277 times |
Joined on May 2010
@ Brighton, UK
|
#4
|
Are there conditions 'user' can do things that 'root' cannot? Sorry can't be more helpful.
How did you get all those colours in your terminal? I want...
The Following User Says Thank You to mr_jrt For This Useful Post: | ||
|
2011-11-27
, 22:46
|
Posts: 249 |
Thanked: 277 times |
Joined on May 2010
@ Brighton, UK
|
#5
|
Nothing wrong with your configuration I would say.
The error message indicates you try to execute the module. Are you sure it is line 72 that contains the if statement?
Attaching the script may help in a further analysis...
1 #!/bin/sh
2
3 # Debugging
4 if [ true ]
5 then
6 rm /ramtest.log
7 exec &> /ramtest.log
8 fi
9
10 # Tuning
11 compcache_size=65536 # Size of cache in KB
12 priority_compcache=15
13 priority_external=10
14 priority_internal=0
15 compcache_timeout=10 # Timeout for device node to be ready in seconds
16
17 # Constants
18 compcache_module=/lib/modules/current/ramzswap.ko
19 device_internal=mmcblk0
20 device_external=mmcblk1
21 device_compcache=ramzswap0
22
23 whoami
24 ls -la /lib/modules
25 stat /lib/modules/current
26 stat $compcache_module
27
28 # Calculated
29 swapdrivelist_internal=$(sfdisk -lnd | grep Id=82 | awk "/$device_internal/ {print \$1}")
30 swapdrivelist_external=$(sfdisk -lnd | grep Id=82 | awk "/$device_external/ {print \$1}")
31 if [ -n "$(swapon 2>&1 | grep "\-p")" ]
32 then
33 priority_available=true
34 fi
35
36 # If priority support is available, use it
37 if [ $priority_available ]
38 then
39 priority_compcache="-p $priority_compcache "
40 priority_external="-p $priority_external "
41 priority_internal="-p $priority_internal "
42 fi
43
44 # Compcache first - we want stuff to get bumped here.
45 if [ -e $compcache_module ]
46 then
47 if [ $priority_available ]
48 then
49 priority=$priority_compcache
50 fi
51
52 compcache_succeeded=insmod $compcache_module disksize_kb=$compcache_size
53 if [ $compcache_succeeded ]
54 then
55 start_wait=$(date +%s)
56 while [ ! -s /dev/$device_compcache -a $(($(date +%s) - $start_wait)) -lt $compcache_timeout ]
57 do
58 printf "Waiting %ds for compcache to be ready... " $(($compcache_timeout - ($(date +%s) - $start_wait)))
59 done
60 echo
61 swapon $priority/dev/$device_compcache
62 exit
63 fi
64 fi
65
66 # Turn on SD swap first
67 for swapdrive in $swapdrivelist_external
68 do
69 if [ $priority_available ]
70 then
71 priority=$priority_external
72 fi
73 swapon $priority$swapdrive
74 done
75
76 # If we have at least one other type of swap, diable the internal swap temporarily
77 if [ "$compcache_succeeded" -o -n "$swapdrivelist_sd" ]
78 then
79 # Turn off the internal swap to bump things into our preferred locations
80 for swapdrive in $swapdrivelist_internal
81 do
82 swapoff $swapdrive
83 done
84
85 # Turn on internal swap again just in case
86 for swapdrive in $swapdrivelist_internal
87 do
88 if [ $priority_available ]
89 then
90 priority=$priority_internal
91 fi
92 swapon $priority$swapdrive
93 done
94 fi
|
2011-11-27
, 22:54
|
Posts: 249 |
Thanked: 277 times |
Joined on May 2010
@ Brighton, UK
|
#6
|
|
2011-11-27
, 23:03
|
Posts: 1,100 |
Thanked: 2,797 times |
Joined on Apr 2011
@ Netherlands
|
#7
|
The Following User Says Thank You to ade For This Useful Post: | ||
|
2011-11-27
, 23:14
|
Posts: 249 |
Thanked: 277 times |
Joined on May 2010
@ Brighton, UK
|
#8
|
That was what I was going to say: you assign the the execution of a command (insmod) to variable. Place it between quotes if you want to assign the text of the insmod.
insmod $compcache_module disksize_kb=$compcache_size
compcache_succeeded=$?
|
2011-11-27
, 23:29
|
Posts: 1,100 |
Thanked: 2,797 times |
Joined on Apr 2011
@ Netherlands
|
#9
|
...and the answer is:
...I guess you can't grab the exit status directly with assignment. That's another one for today's list of something new learnt.PHP Code:
insmod $compcache_module disksize_kb=$compcache_size
compcache_succeeded=$?
The Following User Says Thank You to ade For This Useful Post: | ||
|
2011-11-28
, 22:32
|
|
Posts: 4,118 |
Thanked: 8,901 times |
Joined on Aug 2010
@ Ruhrgebiet, Germany
|
#10
|
compcache_succeeded=`insmod $compcache_module disksize_kb=$compcache_size]`
I'm writing a startup script to handle setting up the swap devices (which I plan on packaging up and uploading to extras-devel), and as part of that, it looks for the compcache kernel module. Works fine when I test, but fails when I run it during boot.
whoami
ls -la /lib/modules
stat /lib/modules/current
stat $compcache_module
root
drwxr-xr-x 4 root root 376 Nov 19 12:09 .
drwxr-xr-x 10 root root 8096 Jul 1 20:58 ..
drwxr-xr-x 3 root root 7664 May 22 2011 2.6.28-omap1
drwxr-xr-x 2 root root 20936 Nov 19 12:09 2.6.28.10-power49
lrwxrwxrwx 1 root root 17 Nov 19 12:09 current -> 2.6.28.10-power49
File: '/lib/modules/current' -> '2.6.28.10-power49'
Size: 17 Blocks: 0 IO Block: 4096 symbolic link
Device: fe01h/65025d Inode: 1681667 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2011-11-19 12:09:10.000000000
Modify: 2011-11-19 12:09:10.000000000
Change: 2011-11-19 12:09:10.000000000
File: /lib/modules/current/ramzswap.ko
Size: 22280 Blocks: 48 IO Block: 4096 regular file
Device: fe01h/65025d Inode: 1681513 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2011-11-19 12:09:00.000000000
Modify: 2011-11-18 22:04:17.000000000
Change: 2011-11-19 12:09:04.000000000
compcache_module=/lib/modules/current/ramzswap.ko
...
if [ -e $compcache_module ]
...any ideas?
[edit]
I'm going to change it to just use the output of stat...but I don't like unsolved mysteries...
Last edited by mr_jrt; 2011-11-27 at 22:32.