LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 02-13-2020, 10:21 AM   #1
ZH_Y
LQ Newbie
 
Registered: Feb 2020
Posts: 16

Rep: Reputation: Disabled
Initramfs started, init pid is not 1, please help me


Board: i.MX6Q
Uboot:2019-04
kernel:4.1.15

My file system was built with buildroot-2019.02.9 and works fine on the board.I added the init script file under /, which is as follows:
Code:
#!/bin/sh
echo "sleep 10s"
sleep 10
echo "finished sleep"
echo "current pid is $$"
Use the following command for cpio packaging.
Code:
find . | cpio --create --format='newc' | gzip > ../ramdisk.img
mkimage -A arm -O linux -T ramdisk -C none -a 0x12c00000 -n "Label you want" -d ./ramdisk.img ./uramdisk.img
On the uboot command line, type the following command, copy the initramfs of the usb disk into the DDR, and start the kernel
Code:
Hit any key to stop autoboot:  0
=> usb start;fatload usb 0 0x12c00000 uramdisk.img;fatload mmc 3:1 0x12000000 zImage;fatload mmc 3:1 0x18000000 topeet_9.7inch.dtb;run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
starting USB...
USB0:   Port not available.
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
2036176 bytes read in 174 ms (11.2 MiB/s)
8306792 bytes read in 235 ms (33.7 MiB/s)
46349 bytes read in 15 ms (2.9 MiB/s)
Kernel image @ 0x12000000 [ 0x000000 - 0x7ec068 ]
## Loading init Ramdisk from Legacy Image at 12c00000 ...
   Image Name:   Label you want
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    2036112 Bytes = 1.9 MiB
   Load Address: 12c00000
   Entry Point:  12c00000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Using Device Tree in place at 18000000, end 1800e50c

Starting kernel ...
After starting initramfs, I found that my /init file was not executed and the process in pid = 1 was {linuxrc} init.According to the busybox documentation, when the kernel goes into initramfs, it calls the /init file first with PID = 1,and can then use switch_root for system switching. But that's not what my board looks like. What's the problem?
Quote:
Starting syslogd: OK
Starting klogd: OK
Starting mdev...
modprobe: can't change directory to '/lib/modules': No such file or directory
Initializing random number generator... random: dd urandom read with 16 bits of entropy available
done.
Starting network: OK
# top
Mem: 79348K used, 1982272K free, 4168K shrd, 0K buff, 4168K cached
CPU: 0% usr 2% sys 0% nic 97% idle 0% io 0% irq 0% sirq
Load average: 0.07 0.02 0.01 1/86 240
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
240 233 root R 2164 0% 2% top
233 1 root S 2268 0% 0% -/bin/sh
1 0 root S 2164 0% 0% {linuxrc} init
205 1 root S 2164 0% 0% /sbin/syslogd -n
209 1 root S 2164 0% 0% /sbin/klogd -n
87 2 root SW 0 0% 0% [kworker/1:1]
6 2 root SW 0 0% 0% [kworker/u8:0]
90 2 root SW 0 0% 0% [kworker/u8:1]
24 2 root SW 0 0% 0% [kdevtmpfs]
88 2 root SW 0 0% 0% [scsi_eh_0]
2 0 root SW 0 0% 0% [kthreadd]
3 2 root SW 0 0% 0% [ksoftirqd/0]
4 2 root SW 0 0% 0% [kworker/0:0]
5 2 root SW< 0 0% 0% [kworker/0:0H]
7 2 root SW 0 0% 0% [rcu_preempt]
8 2 root SW 0 0% 0% [rcu_sched]
9 2 root SW 0 0% 0% [rcu_bh]
10 2 root SW 0 0% 0% [migration/0]
11 2 root SW 0 0% 0% [migration/1]
12 2 root SW 0 0% 0% [ksoftirqd/1]
# pwd
/
# cat init
#!/bin/sh
echo "sleep 10s"
sleep 10
echo "finished sleep"
echo "current pid is $$"

# ls
bin init linuxrc opt run tmp
dev lib media proc sbin usr
etc lib32 mnt root sys var
# echo $$
233
#
 
Old 02-14-2020, 03:05 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Duplicate - reported.
 
Old 02-14-2020, 08:28 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

https://www.linuxquestions.org/quest...sc-4175669539/
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
initramfs - why do we need "init" in root instead of /sbin/init? ranshalit Linux From Scratch 2 01-02-2019 06:00 PM
[SOLVED] xfce not started in init 4, kde is started, although xfce was chosen during installation apmount Slackware 4 11-21-2018 11:20 AM
rootdev not found by /sbin/init from initramfs Bourdieu Slackware 32 09-14-2015 09:36 AM
Kernel panic - not syncing: Attempted to kill init, Pid: 1, comm: init Not tainted 2. morriset Linux - Kernel 3 07-02-2011 08:04 AM
(bind) named: couldn't open pid file '/var/run/named/named.pid' - any help? samengr Linux - Server 6 04-01-2009 06:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration