1e41f4b71Sopenharmony_ci# init Module FAQs
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## FAQs Related to Service Processes
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci### System Service Process Does Not Automatically Restart After Exit
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciCheck whether **once** is set to **1** in the **.cfg** file of the service process. If **once** is set to **1**, the process is a one-time process and will not be started by the init process after exit.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci### How to Disable System Service Processes by Default
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciThe **disable** option in the **.cfg** file of the service is not enabled. You can configure the **start-mode** option to control the startup mode.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci### How to Close the System Service Process Sandbox
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciConfigure **sandbox** in the **.cfg** file of the service. The value **0** indicates that the service is not moved to the sandbox, and the value **1** indicates the opposite. The default value is **0**.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci### Service Does Not Exist
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Symptom**
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci"Failed get servName" is recorded in the kernel log.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**Cause Analysis**
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciAfter a code review on the init process, it is found that the service does not exist.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Solution**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci1. Check whether the service is correctly configured in the **.cfg** file.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci2. Check whether the **.cfg** file of the service is loaded normally.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci3. Check whether the format of the **.cfg** file is correct.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci## FAQs Related to init Process Startup
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci### System Stuck at the Startup Logo Screen
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci1. Cause analysis: The level-2 startup of the init process is not complete.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci    Solution:
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci    Run the **begetctl setloglevel 0** command, restart the device, and view the kernel log through the serial port. Check whether the level-2 startup of the init process is complete. The key log information is as follows:
44e41f4b71Sopenharmony_ci    
45e41f4b71Sopenharmony_ci    ```
46e41f4b71Sopenharmony_ci    [32.173144][pid=1] [Init] [INFO] [init.c:206]Start init second stage.
47e41f4b71Sopenharmony_ci    [33.173144][pid=1] [Init] [DEBUG] [init.c:206]Parse init configs from /etc/init.cfg.
48e41f4b71Sopenharmony_ci    ```
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci​    If the **hdcd** service is not started or the partition is not properly mounted, the **begetctl** command cannot be executed. You need to modify the init process code to set the log level. Ensure that the debug log of the init process can be properly generated.
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci2. Cause analysis: The **init.cfg** file fails to be parsed.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci    - Incorrect format of the **.cfg** file
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci    - No permission or restricted permission
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci    Solution:
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci      1. Check the format of the **.cfg** file. Make sure that the file complies with the JSON format.
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci      2. The log contains **permission denied**, and the init process reports a permission error. Check whether the fault is caused by SELinux. Disable SELinux, and perform the verification again. If the verification is successful, no permission error is reported. If the fault persists, the fault is probably caused by incorrect SELinux policy configuration. Configure the SELinux policy correctly. For details, see the readme in the **base/security/selinux_adapter** repository.
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci3. Cause analysis: The **required** partition is not properly mounted.
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci   - The **required** partition is not configured in cmdline or the format is incorrect.
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci   - The **fstag.required** file does not exist in the ramdisk.
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci   Solution:
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci   1. View the log to check whether the **required** partition is configured in the kernel cmdline. If yes, check whether the command format is correct and make modifications as needed.
73e41f4b71Sopenharmony_ci          
74e41f4b71Sopenharmony_ci      ```
75e41f4b71Sopenharmony_ci      [0.000000] Kernel command line: currentslot=0 bootslots=0 rw rootwait earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0 ohos.boot.eng_mode=on root=PARTUUID=614e0000-0000 hardware=rk3568 default_boot_device=fe310000.sdhci ohos.required_mount.system=/dev/block/platform/fe310000.sdhci/by-name/system@/usr@ext4@ro,barrier=1@wait,required ohos.required_mount.vendor=/dev/block/platform/fe310000.sdhci/by-name/vendor@/vendor@ext4@ro,barrier=1@wait,required ohos.required_mount.misc=/dev/block/platform/fe310000.sdhci/by-name/misc@none@none@none@wait,required ohos.required_mount.bootctrl=/dev/block/platform/fe310000.sdhci/by-name/bootctrl@none@none@none@wait,required   
76e41f4b71Sopenharmony_ci      ```
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci      You can also run the **cat /proc/cmdline** command on the device to view the information.
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci   2. Check whether the **fstab.required** file exists in **ramdisk.img**.
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci4. Cause analysis: **com.ohos.launcher** is not started. As a result, no startup animation is displayed.
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci     Solution: Run the **ps -ef** command to check whether **com.ohos.launcher** is available. Analyze the fault cause based on the log.
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci5. Cause analysis: The **bootanimation** service fails to start.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci     Solution:
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci     1. Check whether the **bootanimation** service is started.
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci     2. Check whether the **bootanimation** is repeatedly started.
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci        The following log information indicates that the **bootanimation** service is started.
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci        ```
97e41f4b71Sopenharmony_ci        [10.175192] [pid=1] [Init] [INFO] [init_service_manager.c:1088]Start service bootanimation
98e41f4b71Sopenharmony_ci        ```
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci  6. Cause analysis: The **data** partition is not properly mounted.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci     - The **userdata** partition is not configured in the device partition table.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci     - The **fstab** file of the device does not have the mounting configuration of the **data** partition.
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci     - The file system configured in the **fstab** file of the device does not match the actual file system of the **userdata** image. For example, **ext4** is configured in the **fstab** file, but the actual file system of the **userdata** image is f2fs.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci     Solution:
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci     Check the kernel log and rectify the fault based on the log information.
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci     1. "wait for file:/dev/block/platform/soc/10100000.himci.eMMC/by-name/userdata failed after" 
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci     2. No mounting information of the **userdata** partition in the log
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci     3. "Mount /dev/block/platform/soc/10100000.himci.eMMC/by-name/userdata to /data failed"
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci        If **nofail** is configured in the **fstab** file, "Mount no fail device /dev/block/platform/soc/10100000.himci.eMMC/by-name/userdata to /data failed" is recorded in the log. **nofail** indicates that a device mounting failure is not allowed.
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci### System Stuck at the Startup Animation Screen
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Cause Analysis**
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci- The startup animation does not exit properly.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci- System application spawning fails.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci- The reported boot events are incomplete. Not all services that have registered bootevent reported a boot event.
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**Solution**
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci1. Check whether any service is repeatedly restarted and whether **critical** is configured for the service.
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci2. Run the **ps -ef | grep ohos** command to check whether the system application exists. If the log contains **permission denied**, the init process has reported a permission error. Apply for the required system application permission, disable SELinux, and perform verification again. If the verification is successful, the problem is caused by incorrect SELinux policy configuration. Modify or add the corresponding SELinux permission. For details about [SELinux policy configuration](https://gitee.com/openharmony/security_selinux_adapter#%E6%97%A5%E5%BF%97%E4%BF%A1%E6%81%AF), see the readme in the **base/security/selinux_adapter** repository.
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci3. Identify the services that do not report a boot event. If a certain service, for example, systemUI, does not report a boot event, the startup animation may be suspended.
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci### Automatic Service Restart
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**Cause Analysis**
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci- The **importance** attribute is defined in the init service.
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci- If the **critical** attribute is configured for a service, key processes that meet specified conditions will restart.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci- A panic occurs because the init process is suspended.
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci**Solution**
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci1. For a small system, set the **importance** attribute to **0**. The value **0** indicates that the service is restarted, and the value **1** indicates the opposite.
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci2. Determine whether to configure the **critical** attribute for a service.
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci3. Execute **execv ("/bin/sh", NULL)** before **CloseStdio();**.
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci### Failed to Restart the System Using the reboot Command
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci**Cause Analysis**
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci- Unsuccessful reboot plug-in installation
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci- Incorrect **reboot** command
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci- Invalid parameter setting of **ohos.startup.powerctrl reboot**
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci- Restricted permission of **reboot selinux**
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**Solution**
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci1. Check whether **/system/lib/init/reboot/librebootmodule.z.so** is successfully installed on the board.
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci2. Run the **begetctl setloglevel 0** command to set the log level. The log information is as follows:
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci   ```
176e41f4b71Sopenharmony_ci   08-10 18:48:07.653  1421  1421 D C02c0b/BEGET: [init_reboot_innerkits.c:51]Reboot cmd reboot
177e41f4b71Sopenharmony_ci   ```
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci   Check the number of **reboot** commands and make sure that it does not exceed 96.
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci3. Run the **param set ohos.startup.powerctrl reboot** command in hdc shell to check whether the system is restarted. If the system is restarted, the system parameters are set successfully.
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci4. Check whether the log contains **permission denied**. If yes, the init process has reported a permission error. Disable SELinux, and perform verification again. If the verification is successful, the problem is caused by incorrect SELinux policy configuration. Modify or add the corresponding SELinux permission. For details about [SELinux policy configuration](https://gitee.com/openharmony/security_selinux_adapter#%E6%97%A5%E5%BF%97%E4%BF%A1%E6%81%AF), see the readme in the **base/security/selinux_adapter** repository.
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci### System Startup Interrupted Due to "parse failed!" Error
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci**Symptom**
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ciDuring system startup, the error message "[Init] InitReadCfg, parse failed! please check file /etc/init.cfg format." is printed, and the startup is interrupted, as shown in the following figure.
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci**Figure 1** Error information
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci![Run error](figures/run-error.png)
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**Possible Causes**
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ciDuring modification of the **init.cfg** file, required commas (,) or parentheses are missing or unnecessary ones are added. As a result, the file's JSON format becomes invalid.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci**Solution**
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ciCheck the **init.cfg** file and ensure that its format meets the JSON specifications.
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci### Requesting FD Proxy for Other Services Failed
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci**Symptom**
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci"Service' xxx '(pid = xxx) is not valid or request with unexpected process(pid = xxx)" is recorded in the kernel log.
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci**Cause Analysis**
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ciThe kernel log is printed by the init process. After a code review on the init process, it is found that FD proxy is requested for other services.
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci**Solution**
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ciRequest FD proxy for the current service, but not other services.
216