您尚未登录。

楼主 #1 2019-08-29 13:09:22

阿黄
会员
注册时间: 2018-10-03
已发帖子: 298
积分: 133

求助,overlayfs 应该在什么地方进行切换根目录

请教下,切换根目录应该在哪一步切换,povit_root /merged /merged/rom。我尝试了在inittab中,执行rcS之前,执行是对的,但就是一直报 can't open /dev/console: No such file or directory和can't open /dev/ttyGS0: No such file or directory

# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
::sysinit:/bin/mount -a
::sysinit:/sbin/swapon -a
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
::sysinit:/bin/hostname -F /etc/hostname
# Load Wifi driver
::sysinit:/sbin/modprobe r8723bs 
# now run any rc scripts
::sysinit:mount -n -t overlay overlayfs:/overlay -o lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/workdir /merged/
::sysinit:pivot_root /merged /merged/rom

::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
ttyGS0::respawn:/sbin/getty -L ttyGS0 0 vt100 # GENERIC_SERIAL
console::respawn:/sbin/getty -L  console 0 vt100 # GENERIC_SERIAL

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r

系统启动日志

U-Boot 2018.01-05679-g013ca45-dirty (Jul 08 2019 - 05:04:44 -0700) Allwinner Technology

CPU:   Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

In:    serial@1c25000
Out:   serial@1c25000
Err:   serial@1c25000
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  0 
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
device 0 offset 0x70000, size 0x10000
SF: 65536 bytes @ 0x70000 Read: OK
device 0 offset 0x80000, size 0x400000
SF: 4194304 bytes @ 0x80000 Read: OK
## Flattened Device Tree blob at 80c00000
   Booting using the fdt blob at 0x80c00000
   Loading Device Tree to 816fa000, end 816ff43e ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.15.0-rc8-licheepi-nano+ (njatech@ubuntu) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #55 Tue Aug 27 00:47:58 PDT 2019
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: Lichee Pi Nano
[    0.000000] Memory policy: Data cache writeback
[    0.000000] random: fast init done
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=squashfs
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 56232K/65536K available (5120K kernel code, 217K rwdata, 1040K rodata, 1024K init, 221K bss, 9304K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xc4800000 - 0xff800000   ( 944 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (6112 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 218 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   ( 222 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000045] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[    0.000110] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000639] Console: colour dummy device 80x30
[    0.000726] Calibrating delay loop... 203.16 BogoMIPS (lpj=1015808)
[    0.070229] pid_max: default: 32768 minimum: 301
[    0.070535] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.070576] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.071946] CPU: Testing write buffer coherency: ok
[    0.073508] Setting up static identity map for 0x80100000 - 0x80100058
[    0.075989] devtmpfs: initialized
[    0.082758] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.082820] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.083069] pinctrl core: initialized pinctrl subsystem
[    0.084984] NET: Registered protocol family 16
[    0.086191] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.087888] cpuidle: using governor menu
[    0.106547] SCSI subsystem initialized
[    0.106848] usbcore: registered new interface driver usbfs
[    0.106987] usbcore: registered new interface driver hub
[    0.107161] usbcore: registered new device driver usb
[    0.107549] pps_core: LinuxPPS API ver. 1 registered
[    0.107578] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.107635] PTP clock support registered
[    0.109064] clocksource: Switched to clocksource timer
[    0.134427] NET: Registered protocol family 2
[    0.135785] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.135858] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.135909] TCP: Hash tables configured (established 1024 bind 1024)
[    0.136164] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.136224] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.136697] NET: Registered protocol family 1
[    0.138944] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.140781] Initialise system trusted keyrings
[    0.141313] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.155964] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.156529] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    0.171007] Key type asymmetric registered
[    0.171048] Asymmetric key parser 'x509' registered
[    0.171241] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.171271] io scheduler noop registered
[    0.171289] io scheduler deadline registered
[    0.172032] io scheduler cfq registered (default)
[    0.172065] io scheduler mq-deadline registered
[    0.172083] io scheduler kyber registered
[    0.173151] sun4i-usb-phy 1c13400.phy: Couldn't request ID GPIO
[    0.182560] suniv-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.346331] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.352870] console [ttyS0] disabled
[    0.373113] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 22, base_baud = 6250000) is a 16550A
[    0.812106] console [ttyS0] enabled
[    0.838007] 1c25400.serial: ttyS1 at MMIO 0x1c25400 (irq = 23, base_baud = 6250000) is a 16550A
[    0.847644] suniv-pinctrl 1c20800.pinctrl: unsupported function uart2 on pin PD14
[    0.876866] 1c25800.serial: ttyS2 at MMIO 0x1c25800 (irq = 24, base_baud = 6250000) is a 16550A
[    0.887665] SCSI Media Changer driver v0.25 
[    0.895490] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.900384] 5 ofpart partitions found on MTD device spi0.0
[    0.905869] Creating 5 MTD partitions on "spi0.0":
[    0.910755] 0x000000000000-0x000000070000 : "u-boot"
[    0.918127] 0x000000070000-0x000000080000 : "dtb"
[    0.925286] 0x000000080000-0x000000480000 : "kernel"
[    0.932753] 0x000000480000-0x000000c00000 : "rootfs"
[    0.940150] 0x000000c00000-0x000001000000 : "overlayfs"
[    0.950543] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.957078] ehci-platform: EHCI generic platform driver
[    0.962667] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.968888] ohci-platform: OHCI generic platform driver
[    0.974552] usbcore: registered new interface driver usb-storage
[    0.981714] i2c /dev entries driver
[    0.988643] NET: Registered protocol family 17
[    0.993319] Key type dns_resolver registered
[    0.999615] Loading compiled-in X.509 certificates
[    1.012417] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.024204] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.030113] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[    1.038552] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.045440] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.052698] usb usb1: Product: MUSB HDRC host driver
[    1.057663] usb usb1: Manufacturer: Linux 4.15.0-rc8-licheepi-nano+ musb-hcd
[    1.064734] usb usb1: SerialNumber: musb-hdrc.1.auto
[    1.071248] hub 1-0:1.0: USB hub found
[    1.075168] hub 1-0:1.0: 1 port detected
[    1.080960] hctosys: unable to open rtc device (rtc0)
[    1.086483] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.103942] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.110749] vcc3v3: disabling
[    1.114526] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    1.123240] cfg80211: failed to load regulatory.db
[    1.133930] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    1.145509] devtmpfs: mounted
[    1.153006] Freeing unused kernel memory: 1024K
[    1.396362] random: crng init done
modprobe: can't change directory to '/lib/modules': No such file or directory
[    2.253216] overlayfs: upper fs does not support tmpfile.
[    2.258645] overlayfs: upper fs does not support xattr.
[    2.263967] overlayfs: upper fs does not support file handles, falling back to index=off.
Starting syslogd: OK
Starting klogd: OK
Configure the USB Gadget: [    2.585666] using random self ethernet address
[    2.590268] using random host ethernet address
/usr/bin/gadget_init: line 41: udevadm: not found
ls: /sys/class/udc/: No such file or directory
FAIL
Starting album: /etc/init.d/S36album: line 9: can't create /sys/class/graphics/fbcon/cursor_blink: nonexistent directory
/etc/init.d/S36album: line 10: can't create /sys/class/vtconsole/vtcon1/bind: nonexistent directory
OK
/etc/init.d/S36album: cd: line 11: can't cd to /overlay/album: No such file or directory
Starting ntpd: /etc/init.d/S39ntpd: line 9: /usr/sbin/ntpd: not found
FAIL
Starting udhcpd: /etc/init.d/S39udhcpd: line 9: /usr/sbin/udhcpd: not found
FAIL
Starting network: ifup: interface lo already configured
ip: can't find device 'usb0'
ip: SIOCGIFFLAGS: No such device
ip: can't find device 'usb0'
random: Cannot open /dev/random: No such file or directory
Successfully initialized wpa_supplicant
Failed to open config file '/overlay/etc/wpa_supplicant.conf', error: No such file or directory
Failed to read or parse configuration '/overlay/etc/wpa_supplicant.conf'.
FAIL
Starting wpa_cli: Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
FAIL
Starting sshd: OK
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory
can't open /dev/console: No such file or directory
can't open /dev/ttyGS0: No such file or directory

明显的,切换根目录已经成功,因为ssh可以生成key,不会报readonly fs了, 但执行完rcS之后(ssh是rcS中最后一个),就报错误。但如果我不切换跟目录,gadget是OK的,也不会报这个错误。

最近编辑记录 阿黄 (2019-08-29 13:09:47)

离线

#2 2019-08-29 13:37:28

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,224
积分: 9197

Re: 求助,overlayfs 应该在什么地方进行切换根目录

/dev/console 这个设备存在吗?





在线

楼主 #3 2019-08-29 14:30:21

阿黄
会员
注册时间: 2018-10-03
已发帖子: 298
积分: 133

Re: 求助,overlayfs 应该在什么地方进行切换根目录

晕哥 说:

/dev/console 这个设备存在吗?

一直在打印,按Enter也没法到登录那一步,因此也没法看/dev目录。 但如果只是挂载到/overlay,而不执行povit_root的话,就没问题

离线

#4 2019-08-29 14:44:19

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,224
积分: 9197

Re: 求助,overlayfs 应该在什么地方进行切换根目录

没有玩过 overlay, 只能围观了。





在线

楼主 #5 2019-08-29 16:30:51

阿黄
会员
注册时间: 2018-10-03
已发帖子: 298
积分: 133

Re: 求助,overlayfs 应该在什么地方进行切换根目录

阿黄 说:
晕哥 说:

/dev/console 这个设备存在吗?

一直在打印,按Enter也没法到登录那一步,因此也没法看/dev目录。 但如果只是挂载到/overlay,而不执行povit_root的话,就没问题

貌似切换后,/dev目录中的各个设备没有自动复制底层的/dev/,因此没有console之类的,也没有ttyS*,查了很多文章,需要把/dev中的加载到新的/dev中
mount -n -t overlay overlayfs:/overlay -o lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/workdir /merged
mount -n /proc -o noatime,--move /merged/proc
pivot_root /merged /merged/rom
mount -n /rom/dev -o noatime,--move /dev
mount -n /rom/tmp -o noatime,--move /tmp
mount -n /rom/sys -o noatime,--move /sys
mount -n /rom/overlay -o noatime,--move /overlay

我再试试看

最近编辑记录 阿黄 (2019-08-29 16:37:29)

离线

#6 2022-09-09 21:43:27

哇酷小二
wechat微信:whycan_cn
所在地: 你猜
注册时间: 2020-04-22
已发帖子: 3,378
积分: 1902
个人网站

Re: 求助,overlayfs 应该在什么地方进行切换根目录

@阿黄

https://www.jianshu.com/p/e24f9fc39008

最后到也不了登录界面,一直为:can't open /dev/console: No such file or directory,解决方法是配置CONFIG_DEVTMPFS_MOUNT

JL(TGZQ$WM5I05ZYMY1]9$X.png





离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn