主要用到的命令为pivot_root,可man 8 pivot_root了解用法。

1. pivot_root - change the root filesystem

pivot_root new_root put_old

pivot_root  moves  the  root  file  system of the current process to the directory put_old and makes new_root the new root file system.

Note  that, depending on the implementation of pivot_root, root and cwd of the caller may or may not
change. The following is a sequence for invoking pivot_root that works in either case, assuming that
pivot_root and chroot are in the current PATH:

       cd new_root
pivot_root . put_old
exec chroot . command

Note that chroot must be available under the old root and under the new root, because pivot_root may
or may not have implicitly changed the root directory of the shell.

Note that exec chroot changes the running executable, which is necessary if the old  root  directory
should be unmounted afterwards.  Also note that standard input, output, and error may still point to
a device on the old root file system, keeping it busy. They can  easily  be  changed  when  invoking chroot.

2. 应用

pivot() { # <new_root> <old_root>
/bin/mount -o noatime,move /proc $/proc && \
pivot_root $ $$ && {
/bin/mount -o noatime,move $/dev /dev
/bin/mount -o noatime,move $/tmp /tmp
/bin/mount -o noatime,move $/sys /sys >&-
/bin/mount -o noatime,move $/overlay /overlay >&-
return
}
}

mount rootfs的更多相关文章

  1. android使用mount挂载/system/app为读写权限,删除或替换系统应用

    注意:以下代码中#开头的则为需要执行的shell命令,其他的为打印的结果.#代表需要使用ROOT权限(su)执行,所以想要修改您android手机某个目录挂载为读写,首先需要有ROOT权限! 先要得到 ...

  2. ubifs概述

    UBIFS无排序区块图像文件系统(Unsorted Block Image File System, UBIFS)是用于固态存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一.真正开 ...

  3. easycwmp在开发板上的配置

    原创作品,转载请注明出处 copyright:weishusheng   2015.3.18 email:642613208@qq.com 平台: Linux version 2.6.32-279.e ...

  4. Android shell 下 busybox,clear,tcpdump、、众多命令的移植

    http://my.oschina.net/mopidick/blog/167372 作为一名Android开发者,经常需要进入Android 的shell终端运行一些命令.但是我们发现Android ...

  5. Android 启动过程简析

    首先我们先来看android构架图: android系统是构建在linux系统上面的. 所以android设备启动经历3个过程. Boot Loader,Linux Kernel & Andr ...

  6. 用Qemu模拟vexpress-a9 (四) --- u-boot引导kernel,用nfs挂载根文件系统

    环境介绍 Win7 64 + Vmware 11 + ubuntu14.04 32 u-boot 版本:u-boot-2015-04 Linux kernel版本:linux-3.16.y busyb ...

  7. Nexus4铃声目录

    1. 我的铃声 是通过下面的命令 传到手机上面去的: “ adb push fringe_01_long.mp3 /sdcard/ZC/ adb push fringe_02_short.mp3 /s ...

  8. Linux_常用命令_03_磁盘/挂载_信息查看

    1. 1.1. mount 不带参数的话,显示的是 当前已经挂载的情况 1.2. df 不带参数的话,硬盘分区状况查询 2. 2.1. cat /proc/partitions 2.2. fdisk ...

  9. 自己搭建Wifi Pineapple Mark V

    创业搞得自己很累,不过一切都是值得的.抽空写下文章,确实好久未更新了. 前段时间由于项目需要,所以就折腾了下wifi pineapple.时间间隔有点久,根据回忆记录下. 淘宝货:TP-Link TL ...

随机推荐

  1. Oracle RAC 环境下的 v$log v$logfile

    通常情况下,在Oracle RAC 环境中,v$视图可查询到你所连接实例的相关信息,而gv$视图则包含所有实例的信息.然而在RAC环境中,当我们查询v$log视图时说按照常理的话,v$log视图应当看 ...

  2. HDU 4606 Occupy Cities (计算几何+最短路+二分+最小路径覆盖)

    Occupy Cities Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  3. Node.js的集群功能以及在Express的配置

    Node.js在v0.6.0版本下内置了集群功能,作为cluster模块,用于nodejs的多核处理,也比较容易通过脚本实现一个负载均衡的集群. 脚本参考了其他人的材料,建立一个server.js(因 ...

  4. nullptr 与 constexpr

    nullptr   nullptr出现的目的自然是替换NULL的低位.C++可能会将NULL.0视为同一种东西.这取决于编译器是如何定义的,有的编译器定义NULL为 ( (void * )0) ,有的 ...

  5. scrapy安装使用教程

    1. 安装Python,我用的是Python2.7.11,你喜欢用什么版本,你开心就好,只是后面的软件有些可能需要配套. 2. 安装pip,下载pip-8.1.2.tar.gz (md5, pgp). ...

  6. 各种分布 高斯 Gamma Beta 多项分布

  7. 后台SQL注入实例

    简要描述: 汉庭连锁酒店后台SQL注入,可绕过登陆限制进入后台,可脱库. 详细说明: 问题发生在这个站点.http://miaosha.htinns.com/ 标题内没有写具体信息.因为怕发布后被人入 ...

  8. Yii2系列教程三:Database And Gii

    上一篇文章我们理了一下Yii2的MVC,Forms和Layouts,这篇文章就直接按照约定来说说Yii2与数据库相关的一些事情,如果你觉得不够的话,不急,更具体的用法我会在后续的教程给出,并且这里也会 ...

  9. android: android中dip、dp、px、sp和屏幕密度

    android中dip.dp.px.sp和屏幕密度 转自:http://www.cnblogs.com/fbsk/archive/2011/10/17/2215539.html 1. dip: dev ...

  10. unity3d NGUI 本地化 多语言

    原地址:http://cl314413.blog.163.com/blog/static/1905079762014421115528670/ NGUI的本地化操作: Localization UIL ...