1# init Module FAQs 2 3## FAQs Related to Service Processes 4 5### System Service Process Does Not Automatically Restart After Exit 6 7Check 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. 8 9### How to Disable System Service Processes by Default 10 11The **disable** option in the **.cfg** file of the service is not enabled. You can configure the **start-mode** option to control the startup mode. 12 13### How to Close the System Service Process Sandbox 14 15Configure **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**. 16 17### Service Does Not Exist 18 19**Symptom** 20 21"Failed get servName" is recorded in the kernel log. 22 23**Cause Analysis** 24 25After a code review on the init process, it is found that the service does not exist. 26 27**Solution** 28 291. Check whether the service is correctly configured in the **.cfg** file. 30 312. Check whether the **.cfg** file of the service is loaded normally. 32 333. Check whether the format of the **.cfg** file is correct. 34 35## FAQs Related to init Process Startup 36 37### System Stuck at the Startup Logo Screen 38 391. Cause analysis: The level-2 startup of the init process is not complete. 40 41 Solution: 42 43 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: 44 45 ``` 46 [32.173144][pid=1] [Init] [INFO] [init.c:206]Start init second stage. 47 [33.173144][pid=1] [Init] [DEBUG] [init.c:206]Parse init configs from /etc/init.cfg. 48 ``` 49 50 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. 51 522. Cause analysis: The **init.cfg** file fails to be parsed. 53 54 - Incorrect format of the **.cfg** file 55 56 - No permission or restricted permission 57 58 Solution: 59 60 1. Check the format of the **.cfg** file. Make sure that the file complies with the JSON format. 61 62 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. 63 643. Cause analysis: The **required** partition is not properly mounted. 65 66 - The **required** partition is not configured in cmdline or the format is incorrect. 67 68 - The **fstag.required** file does not exist in the ramdisk. 69 70 Solution: 71 72 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. 73 74 ``` 75 [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 76 ``` 77 78 You can also run the **cat /proc/cmdline** command on the device to view the information. 79 80 2. Check whether the **fstab.required** file exists in **ramdisk.img**. 81 824. Cause analysis: **com.ohos.launcher** is not started. As a result, no startup animation is displayed. 83 84 Solution: Run the **ps -ef** command to check whether **com.ohos.launcher** is available. Analyze the fault cause based on the log. 85 865. Cause analysis: The **bootanimation** service fails to start. 87 88 Solution: 89 90 1. Check whether the **bootanimation** service is started. 91 92 2. Check whether the **bootanimation** is repeatedly started. 93 94 The following log information indicates that the **bootanimation** service is started. 95 96 ``` 97 [10.175192] [pid=1] [Init] [INFO] [init_service_manager.c:1088]Start service bootanimation 98 ``` 99 100 6. Cause analysis: The **data** partition is not properly mounted. 101 102 - The **userdata** partition is not configured in the device partition table. 103 104 - The **fstab** file of the device does not have the mounting configuration of the **data** partition. 105 106 - 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. 107 108 Solution: 109 110 Check the kernel log and rectify the fault based on the log information. 111 112 1. "wait for file:/dev/block/platform/soc/10100000.himci.eMMC/by-name/userdata failed after" 113 114 2. No mounting information of the **userdata** partition in the log 115 116 3. "Mount /dev/block/platform/soc/10100000.himci.eMMC/by-name/userdata to /data failed" 117 118 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. 119 120 121### System Stuck at the Startup Animation Screen 122 123**Cause Analysis** 124 125- The startup animation does not exit properly. 126 127- System application spawning fails. 128 129- The reported boot events are incomplete. Not all services that have registered bootevent reported a boot event. 130 131**Solution** 132 1331. Check whether any service is repeatedly restarted and whether **critical** is configured for the service. 134 1352. 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. 136 1373. 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. 138 139### Automatic Service Restart 140 141**Cause Analysis** 142 143- The **importance** attribute is defined in the init service. 144 145- If the **critical** attribute is configured for a service, key processes that meet specified conditions will restart. 146 147- A panic occurs because the init process is suspended. 148 149**Solution** 150 1511. 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. 152 1532. Determine whether to configure the **critical** attribute for a service. 154 1553. Execute **execv ("/bin/sh", NULL)** before **CloseStdio();**. 156 157### Failed to Restart the System Using the reboot Command 158 159**Cause Analysis** 160 161- Unsuccessful reboot plug-in installation 162 163- Incorrect **reboot** command 164 165- Invalid parameter setting of **ohos.startup.powerctrl reboot** 166 167- Restricted permission of **reboot selinux** 168 169**Solution** 170 1711. Check whether **/system/lib/init/reboot/librebootmodule.z.so** is successfully installed on the board. 172 1732. Run the **begetctl setloglevel 0** command to set the log level. The log information is as follows: 174 175 ``` 176 08-10 18:48:07.653 1421 1421 D C02c0b/BEGET: [init_reboot_innerkits.c:51]Reboot cmd reboot 177 ``` 178 179 Check the number of **reboot** commands and make sure that it does not exceed 96. 180 1813. 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. 182 1834. 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. 184 185### System Startup Interrupted Due to "parse failed!" Error 186 187**Symptom** 188 189During 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. 190 191**Figure 1** Error information 192 193 194 195**Possible Causes** 196 197During 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. 198 199**Solution** 200 201Check the **init.cfg** file and ensure that its format meets the JSON specifications. 202 203### Requesting FD Proxy for Other Services Failed 204 205**Symptom** 206 207"Service' xxx '(pid = xxx) is not valid or request with unexpected process(pid = xxx)" is recorded in the kernel log. 208 209**Cause Analysis** 210 211The 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. 212 213**Solution** 214 215Request FD proxy for the current service, but not other services. 216