chroot
- /*********************************************************************************
- * Linux chroot 并使用之前系统设备节点
- * 说明:
- * 直接使用chroot结果/dev下没有设备,所有有些东西需要提前挂载,在进入chroot。
- *
- * 2016-12-30 深圳 南山平山村 曾剑锋
- ********************************************************************************/
- 一、参考文档:
- . mount dev, proc, sys in a chroot environment?
- http://superuser.com/questions/165116/mount-dev-proc-sys-in-a-chroot-environment
- 二、主要Linux Shell命令:
- . mount /dev/mmcblk0p2 /mnt
- . mount -t proc proc /mnt/proc
- . mount -t sysfs sys /mnt/sys
- . mount -o bind /dev /mnt/dev
- . chroot /mnt/
- 三、实际操作及数据:
- [zengjf@root ~]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/root % /
- tmpfs % /dev/shm
- tmpfs % /tmp
- tmpfs % /run
- [zengjf@root ~]# mount /dev/mmcblk0p2 /mnt
- EXT3-fs: barriers not enabled
- kjournald starting. Commit interval seconds
- EXT3-fs (mmcblk0p2): warning: checktime reached, running e2fsck is recommended
- EXT3-fs (mmcblk0p2): using internal journal
- EXT3-fs (mmcblk0p2): recovery complete
- EXT3-fs (mmcblk0p2): mounted filesystem with writeback data mode
- [zengjf@root ~]# mount -t proc proc /mnt/proc
- [zengjf@root ~]# mount -t sysfs sys /mnt/sys
- [zengjf@root ~]# mount -o bind /dev /mnt/dev
- [zengjf@root ~]# chroot /mnt/
- BusyBox v1.20.2 () built-in shell (ash)
- Enter ‘help’ for a list of built-in commands.
- [zengjf@root /]# ls /dev/
- alarm ptyr8 tty26 ttyr1
- apm_bios ptyr9 tty27 ttyr2
- buzzer ptyra tty28 ttyr3
- console ptyrb tty29 ttyr4
- cpu_dma_latency ptyrc tty3 ttyr5
- fb0 ptyrd tty30 ttyr6
- fb1 ptyre tty31 ttyr7
- fb2 ptyrf tty32 ttyr8
- full ptys0 tty33 ttyr9
- galcore ptys1 tty34 ttyra
- i2c- ptys2 tty35 ttyrb
- i2c- ptys3 tty36 ttyrc
- i2c- ptys4 tty37 ttyrd
- i2c- ptys5 tty38 ttyre
- input ptys6 tty39 ttyrf
- kmem ptys7 tty4 ttys0
- kmsg ptys8 tty40 ttys1
- log ptys9 tty41 ttys2
- mem ptyt2 tty5 ttysb
- mmcblk0 ptyt3 tty50 ttysc
- mmcblk0boot0 ptyt4 tty51 ttysd
- mmcblk0boot1 ptyt5 tty52 ttyse
- mmcblk0p1 ptyt6 tty53 ttysf
- mmcblk0p2 ptyt7 tty54 ttyt0
- mx6check ptyt8 tty55 ttyt1
- mxc_asrc ptyt9 tty56 ttyt2
- mxc_ipu ptyta tty57 ttyt3
- mxc_vpu ptytb tty58 ttyt4
- mxs_viim ptytc tty59 ttyt5
- network_latency ptytd tty6 ttyt6
- network_throughput ptyte tty60 ttyt7
- null ptytf tty61 ttyt8
- …
- [zengjf@root /]# ls sys
- block class devices fs kernel power
- bus dev firmware fsl_otp module
- [zengjf@root /]# ls proc
- cpuinfo mounts
- crypto mtd
- devices net
- diskstats pagetypeinfo
- dri partitions
- driver scsi
- execdomains self
- fb slabinfo
- filesystems softirqs
- fs stat
- interrupts swaps
- iomem sys
- ioports sysrq-trigger
- irq sysvipc
- kallsyms timer_list
- apm kmsg tty
- asound kpagecount uptime
- buddyinfo kpageflags version
- bus loadavg vmallocinfo
- cmdline locks vmstat
- config.gz meminfo zoneinfo
- consoles misc
- cpu modules
- [zengjf@root /]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/root % /
- devpts % /dev/pts
- tmpfs % /dev/shm
- tmpfs % /tmp
- df: /run: No such file or directory
- /dev/mmcblk0p2 % /
- /dev/root % /dev
- [zengjf@root /]# exit
- [zengjf@root ~]# df
- Filesystem 1K-blocks Used Available Use% Mounted on
- /dev/root % /
- tmpfs % /dev/shm
- tmpfs % /tmp
- tmpfs % /run
- /dev/mmcblk0p2 % /mnt
- /dev/root % /mnt/dev
- [zengjf@root ~]#
把/etc/default/grub 中上面红框中的内容去掉,再执行grub2-mkconfig -o /boot/grub2/grub.cfg。
在grub启动命令行中把resume=xxxxxx去掉。