主要用到的命令为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. Android中选项卡功能的实现

    Android中选项卡功能的实现 Android中使用TabHost和TabWidget来实现选项卡功能.TabHost必须是布局的根节点,它包含两个子节点: TabWidget,显示选项卡: Fra ...

  2. 用fastjson反序列化 带泛型的类

    ServiceResult<User> serviceResult = JSON.parseObject(obtainResult, new TypeReference<Servic ...

  3. 【转载】linux2.6内核initrd机制解析

    题记 很久之前就分析过这部分内容,但是那个时候不够深入,姑且知道这么个东西存在,到底怎么用,来龙去脉咋回事就不知道了.前段时间工作上遇到了一个initrd的问题,没办法只能再去研究研究,还好,有点眉目 ...

  4. MathType输入矩阵或者向量的注意事项

    如图A区域是换行搞得,BC是插入矩阵,AC明显看着不一样,就是说行间不要使用换行,列间隔不要用空格(ctrl+shift+space),直接插入矩阵,向量就是矩阵的行或者列数目是1. 还有就是需要注意 ...

  5. nodeJs的模块依赖

    1.require载入依赖 var http = require('http');//http为路径,可以忽略后缀 2.exports输出依赖 exports.add=add;//add为方法 3.只 ...

  6. PHP文件包含漏洞总结

    0x00 前言 PHP文件包含漏洞的产生原因是在通过PHP的函数引入文件时,由于传入的文件名没有经过合理的校验,从而操作了预想之外的文件,就可能导致意外的文件泄露甚至恶意的代码注入. 最常见的就属于本 ...

  7. cdev结构体及其相关函数

    一.在Linux2.6内核中一个字符设备用cdev结构来描述,其定义如下: struct cdev { struct kobject kobj; struct module *owner; //所属模 ...

  8. OpenGL.Vertex Array Object (VAO) [转]

    http://www.cppblog.com/init/archive/2012/02/21/166098.html 一 OpenGL抛弃glEnable(),glColor(),glVertex() ...

  9. Java笔记7:最简单的网络请求Demo

    一.服务器端 1 新建一个工程,建立一个名为MyRequest的工程. 2 FileàProject StructureàModulesà点击最右侧的“+”àLibraryàJava 找到Tomcat ...

  10. 数据挖掘算法之关联规则挖掘(一)apriori算法

    关联规则挖掘算法在生活中的应用处处可见,几乎在各个电子商务网站上都可以看到其应用 举个简单的例子 如当当网,在你浏览一本书的时候,可以在页面中看到一些套餐推荐,本书+有关系的书1+有关系的书2+... ...