init.rc revision 2b8f76cdbb254ac1170087a40dbf30b7627f3516
1on early-init
2    start ueventd
3
4# create mountpoints
5    mkdir /mnt 0775 root system
6
7on init
8
9sysclktz 0
10
11loglevel 3
12
13# setup the global environment
14    export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
15    export LD_LIBRARY_PATH /vendor/lib:/system/lib
16    export ANDROID_BOOTLOGO 1
17    export ANDROID_ROOT /system
18    export ANDROID_ASSETS /system/app
19    export ANDROID_DATA /data
20    export ASEC_MOUNTPOINT /mnt/asec
21    export LOOP_MOUNTPOINT /mnt/obb
22    export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
23
24# Backward compatibility
25    symlink /system/etc /etc
26    symlink /sys/kernel/debug /d
27
28# Right now vendor lives on the same filesystem as system,
29# but someday that may change.
30    symlink /system/vendor /vendor
31
32# Create cgroup mount point for cpu accounting
33    mkdir /acct
34    mount cgroup none /acct cpuacct
35    mkdir /acct/uid
36
37    mkdir /system
38    mkdir /data 0771 system system
39    mkdir /cache 0770 system cache
40    mkdir /config 0500 root root
41
42    # Directory for putting things only root should see.
43    mkdir /mnt/secure 0700 root root
44
45    # Directory for staging bindmounts
46    mkdir /mnt/secure/staging 0700 root root
47
48    # Directory-target for where the secure container
49    # imagefile directory will be bind-mounted
50    mkdir /mnt/secure/asec  0700 root root
51
52    # Secure container public mount points.
53    mkdir /mnt/asec  0700 root system
54    mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
55
56    # Filesystem image public mount points.
57    mkdir /mnt/obb 0700 root system
58    mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
59
60    write /proc/sys/kernel/panic_on_oops 1
61    write /proc/sys/kernel/hung_task_timeout_secs 0
62    write /proc/cpu/alignment 4
63    write /proc/sys/kernel/sched_latency_ns 10000000
64    write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
65    write /proc/sys/kernel/sched_compat_yield 1
66    write /proc/sys/kernel/sched_child_runs_first 0
67
68# Create cgroup mount points for process groups
69    mkdir /dev/cpuctl
70    mount cgroup none /dev/cpuctl cpu
71    chown system system /dev/cpuctl
72    chown system system /dev/cpuctl/tasks
73    chmod 0777 /dev/cpuctl/tasks
74    write /dev/cpuctl/cpu.shares 1024
75
76    mkdir /dev/cpuctl/fg_boost
77    chown system system /dev/cpuctl/fg_boost/tasks
78    chmod 0777 /dev/cpuctl/fg_boost/tasks
79    write /dev/cpuctl/fg_boost/cpu.shares 1024
80
81    mkdir /dev/cpuctl/bg_non_interactive
82    chown system system /dev/cpuctl/bg_non_interactive/tasks
83    chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
84    # 5.0 %
85    write /dev/cpuctl/bg_non_interactive/cpu.shares 52
86
87on fs
88# mount mtd partitions
89    # Mount /system rw first to give the filesystem a chance to save a checkpoint
90    mount yaffs2 mtd@system /system
91    mount yaffs2 mtd@system /system ro remount
92    mount yaffs2 mtd@userdata /data nosuid nodev
93    mount yaffs2 mtd@cache /cache nosuid nodev
94
95on post-fs
96    # once everything is setup, no need to modify /
97    mount rootfs rootfs / ro remount
98
99    # We chown/chmod /cache again so because mount is run as root + defaults
100    chown system cache /cache
101    chmod 0770 /cache
102
103    # This may have been created by the recovery system with odd permissions
104    chown system cache /cache/recovery
105    chmod 0770 /cache/recovery
106
107    #change permissions on vmallocinfo so we can grab it from bugreports
108    chown root log /proc/vmallocinfo
109    chmod 0440 /proc/vmallocinfo
110
111    #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
112    chown root system /proc/kmsg
113    chmod 0440 /proc/kmsg
114    chown root system /proc/sysrq-trigger
115    chmod 0220 /proc/sysrq-trigger
116
117    # create the lost+found directories, so as to enforce our permissions
118    mkdir /cache/lost+found 0770
119
120    # double check the perms, in case lost+found already exists, and set owner
121    chown root root /cache/lost+found
122    chmod 0770 /cache/lost+found
123
124on post-fs-data
125    # We chown/chmod /data again so because mount is run as root + defaults
126    chown system system /data
127    chmod 0771 /data
128
129    # Create dump dir and collect dumps.
130    # Do this before we mount cache so eventually we can use cache for
131    # storing dumps on platforms which do not have a dedicated dump partition.
132   
133    mkdir /data/dontpanic
134    chown root log /data/dontpanic
135    chmod 0750 /data/dontpanic
136
137    # Collect apanic data, free resources and re-arm trigger
138    copy /proc/apanic_console /data/dontpanic/apanic_console
139    chown root log /data/dontpanic/apanic_console
140    chmod 0640 /data/dontpanic/apanic_console
141
142    copy /proc/apanic_threads /data/dontpanic/apanic_threads
143    chown root log /data/dontpanic/apanic_threads
144    chmod 0640 /data/dontpanic/apanic_threads
145
146    write /proc/apanic_console 1
147
148    # create basic filesystem structure
149    mkdir /data/misc 01771 system misc
150    mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
151    mkdir /data/misc/bluetooth 0770 system system
152    mkdir /data/misc/keystore 0700 keystore keystore
153    mkdir /data/misc/keychain 0771 keychain keychain
154    mkdir /data/misc/vpn 0770 system system
155    mkdir /data/misc/systemkeys 0700 system system
156    mkdir /data/misc/vpn/profiles 0770 system system
157    # give system access to wpa_supplicant.conf for backup and restore
158    mkdir /data/misc/wifi 0770 wifi wifi
159    chmod 0770 /data/misc/wifi
160    chmod 0660 /data/misc/wifi/wpa_supplicant.conf
161    mkdir /data/local 0771 shell shell
162    mkdir /data/local/tmp 0771 shell shell
163    mkdir /data/data 0771 system system
164    mkdir /data/app-private 0771 system system
165    mkdir /data/app 0771 system system
166    mkdir /data/property 0700 root root
167
168    # create dalvik-cache and double-check the perms
169    mkdir /data/dalvik-cache 0771 system system
170    chown system system /data/dalvik-cache
171    chmod 0771 /data/dalvik-cache
172
173    # create the lost+found directories, so as to enforce our permissions
174    mkdir /data/lost+found 0770
175
176    # double check the perms, in case lost+found already exists, and set owner
177    chown root root /data/lost+found
178    chmod 0770 /data/lost+found
179
180    # create directory for DRM plug-ins
181    mkdir /data/drm 0774 drm drm
182
183    # If there is no fs-post-data action in the init.<device>.rc file, you
184    # must uncomment this line, otherwise encrypted filesystems
185    # won't work.
186    # Set indication (checked by vold) that we have finished this action
187    #setprop vold.post_fs_data_done 1
188
189on boot
190# basic network init
191    ifup lo
192    hostname localhost
193    domainname localdomain
194
195# set RLIMIT_NICE to allow priorities from 19 to -20
196    setrlimit 13 40 40
197
198# Define the oom_adj values for the classes of processes that can be
199# killed by the kernel.  These are used in ActivityManagerService.
200    setprop ro.FOREGROUND_APP_ADJ 0
201    setprop ro.VISIBLE_APP_ADJ 1
202    setprop ro.PERCEPTIBLE_APP_ADJ 2
203    setprop ro.HEAVY_WEIGHT_APP_ADJ 3
204    setprop ro.SECONDARY_SERVER_ADJ 4
205    setprop ro.BACKUP_APP_ADJ 5
206    setprop ro.HOME_APP_ADJ 6
207    setprop ro.HIDDEN_APP_MIN_ADJ 7
208    setprop ro.EMPTY_APP_ADJ 15
209
210# Define the memory thresholds at which the above process classes will
211# be killed.  These numbers are in pages (4k).
212    # These are currently tuned for tablets with approx 1GB RAM.
213    setprop ro.FOREGROUND_APP_MEM 8192
214    setprop ro.VISIBLE_APP_MEM 10240
215    setprop ro.PERCEPTIBLE_APP_MEM 12288
216    setprop ro.HEAVY_WEIGHT_APP_MEM 12288
217    setprop ro.SECONDARY_SERVER_MEM 14336
218    setprop ro.BACKUP_APP_MEM 14336
219    setprop ro.HOME_APP_MEM 14336
220    setprop ro.HIDDEN_APP_MEM 16384
221    setprop ro.EMPTY_APP_MEM 20480
222
223    # Old values for phones.  Should probably be adjusted up for the next
224    # phone version.
225    #setprop ro.FOREGROUND_APP_MEM 2048
226    #setprop ro.VISIBLE_APP_MEM 3072
227    #setprop ro.PERCEPTIBLE_APP_MEM 4096
228    #setprop ro.HEAVY_WEIGHT_APP_MEM 4096
229    #setprop ro.SECONDARY_SERVER_MEM 6144
230    #setprop ro.BACKUP_APP_MEM 6144
231    #setprop ro.HOME_APP_MEM 6144
232    #setprop ro.HIDDEN_APP_MEM 7168
233    #setprop ro.EMPTY_APP_MEM 8192
234
235# Write value must be consistent with the above properties.
236# Note that the driver only supports 6 slots, so we have combined some of
237# the classes into the same memory level; the associated processes of higher
238# classes will still be killed first.
239    write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15
240
241    write /proc/sys/vm/overcommit_memory 1
242    write /proc/sys/vm/min_free_order_shift 4
243    write /sys/module/lowmemorykiller/parameters/minfree 8192,10240,12288,14336,16384,20480
244
245    # Set init its forked children's oom_adj.
246    write /proc/1/oom_adj -16
247
248    # Tweak background writeout
249    write /proc/sys/vm/dirty_expire_centisecs 200
250    write /proc/sys/vm/dirty_background_ratio  5
251
252    # Permissions for System Server and daemons.
253    chown radio system /sys/android_power/state
254    chown radio system /sys/android_power/request_state
255    chown radio system /sys/android_power/acquire_full_wake_lock
256    chown radio system /sys/android_power/acquire_partial_wake_lock
257    chown radio system /sys/android_power/release_wake_lock
258    chown radio system /sys/power/state
259    chown radio system /sys/power/wake_lock
260    chown radio system /sys/power/wake_unlock
261    chmod 0660 /sys/power/state
262    chmod 0660 /sys/power/wake_lock
263    chmod 0660 /sys/power/wake_unlock
264    chown system system /sys/class/timed_output/vibrator/enable
265    chown system system /sys/class/leds/keyboard-backlight/brightness
266    chown system system /sys/class/leds/lcd-backlight/brightness
267    chown system system /sys/class/leds/button-backlight/brightness
268    chown system system /sys/class/leds/jogball-backlight/brightness
269    chown system system /sys/class/leds/red/brightness
270    chown system system /sys/class/leds/green/brightness
271    chown system system /sys/class/leds/blue/brightness
272    chown system system /sys/class/leds/red/device/grpfreq
273    chown system system /sys/class/leds/red/device/grppwm
274    chown system system /sys/class/leds/red/device/blink
275    chown system system /sys/class/leds/red/brightness
276    chown system system /sys/class/leds/green/brightness
277    chown system system /sys/class/leds/blue/brightness
278    chown system system /sys/class/leds/red/device/grpfreq
279    chown system system /sys/class/leds/red/device/grppwm
280    chown system system /sys/class/leds/red/device/blink
281    chown system system /sys/class/timed_output/vibrator/enable
282    chown system system /sys/module/sco/parameters/disable_esco
283    chown system system /sys/kernel/ipv4/tcp_wmem_min
284    chown system system /sys/kernel/ipv4/tcp_wmem_def
285    chown system system /sys/kernel/ipv4/tcp_wmem_max
286    chown system system /sys/kernel/ipv4/tcp_rmem_min
287    chown system system /sys/kernel/ipv4/tcp_rmem_def
288    chown system system /sys/kernel/ipv4/tcp_rmem_max
289    chown root radio /proc/cmdline
290
291# Define TCP buffer sizes for various networks
292#   ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
293    setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
294    setprop net.tcp.buffersize.wifi    4095,87380,110208,4096,16384,110208
295    setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
296    setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
297    setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680
298
299# Set this property so surfaceflinger is not started by system_init
300    setprop system_init.startsurfaceflinger 0
301
302    class_start core
303    class_start main
304
305on nonencrypted
306    class_start late_start
307
308on property:vold.decrypt=trigger_reset_main
309    class_reset main
310
311on property:vold.decrypt=trigger_load_persist_props
312    load_persist_props
313
314on property:vold.decrypt=trigger_post_fs_data
315    trigger post-fs-data
316
317on property:vold.decrypt=trigger_restart_min_framework
318    class_start main
319
320on property:vold.decrypt=trigger_restart_framework
321    class_start main
322    class_start late_start
323
324on property:vold.decrypt=trigger_shutdown_framework
325    class_reset late_start
326    class_reset main
327
328## Daemon processes to be run by init.
329##
330service ueventd /sbin/ueventd
331    class core
332    critical
333
334service console /system/bin/sh
335    class core
336    console
337    disabled
338    user shell
339    group log
340
341on property:ro.debuggable=1
342    start console
343
344# adbd is controlled by the persist.service.adb.enable system property
345service adbd /sbin/adbd
346    class core
347    disabled
348
349# adbd on at boot in emulator
350on property:ro.kernel.qemu=1
351    start adbd
352
353on property:persist.service.adb.enable=1
354    start adbd
355
356on property:persist.service.adb.enable=0
357    stop adbd
358
359service servicemanager /system/bin/servicemanager
360    class core
361    user system
362    group system
363    critical
364    onrestart restart zygote
365    onrestart restart media
366
367service vold /system/bin/vold
368    class core
369    socket vold stream 0660 root mount
370    ioprio be 2
371
372service netd /system/bin/netd
373    class main
374    socket netd stream 0660 root system
375    socket dnsproxyd stream 0660 root inet
376
377service debuggerd /system/bin/debuggerd
378    class main
379
380service ril-daemon /system/bin/rild
381    class late_start
382    socket rild stream 660 root radio
383    socket rild-debug stream 660 radio system
384    user root
385    group radio cache inet misc audio sdcard_rw
386
387service surfaceflinger /system/bin/surfaceflinger
388    class main
389    user system
390    group graphics
391    onrestart restart zygote
392
393service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
394    class main
395    socket zygote stream 666
396    onrestart write /sys/android_power/request_state wake
397    onrestart write /sys/power/state on
398    onrestart restart surfaceflinger
399    onrestart restart media
400    onrestart restart netd
401
402service drm /system/bin/drmserver
403    class main
404    user drm
405    group system inet
406
407service media /system/bin/mediaserver
408    class main
409    user media
410    group audio camera inet net_bt net_bt_admin
411    ioprio rt 4
412
413service bootanim /system/bin/bootanimation
414    class main
415    user graphics
416    group graphics
417    disabled
418    oneshot
419
420service dbus /system/bin/dbus-daemon --system --nofork
421    class main
422    socket dbus stream 660 bluetooth bluetooth
423    user bluetooth
424    group bluetooth net_bt_admin
425
426service bluetoothd /system/bin/bluetoothd -n
427    class main
428    socket bluetooth stream 660 bluetooth bluetooth
429    socket dbus_bluetooth stream 660 bluetooth bluetooth
430    # init.rc does not yet support applying capabilities, so run as root and
431    # let bluetoothd drop uid to bluetooth with the right linux capabilities
432    group bluetooth net_bt_admin misc
433    disabled
434
435service installd /system/bin/installd
436    class main
437    socket installd stream 600 system system
438
439service flash_recovery /system/etc/install-recovery.sh
440    class main
441    oneshot
442
443service racoon /system/bin/racoon
444    class main
445    socket racoon stream 600 system system
446    # racoon will setuid to vpn after getting necessary resources.
447    group net_admin
448    disabled
449    oneshot
450
451service mtpd /system/bin/mtpd
452    class main
453    socket mtpd stream 600 system system
454    user vpn
455    group vpn net_admin net_raw
456    disabled
457    oneshot
458
459service keystore /system/bin/keystore /data/misc/keystore
460    class main
461    user keystore
462    group keystore
463    socket keystore stream 666
464
465service dumpstate /system/bin/dumpstate -s
466    class main
467    socket dumpstate stream 0660 shell log
468    disabled
469    oneshot
470