主要用到的命令为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. JavaScript中的模块化之AMD和CMD

    前言: 为什么我们需要模块化开发,模块化开发的好处有哪些? 首先我们先说一下非模块化的开发方式带来的弊端. 非模块化开发中会导致一些问题的出现,变量和函数命名可能相同,会造成变量污染和冲突,并且出错时 ...

  2. 【java】在分页查询结果中对最后的结果集List进行操作add()或remove()操作,报错:java.lang.UnsupportedOperationException

    场景: 在分页查询结果中对最后的结果集List进行操作add()或remove()操作,报错:java.lang.UnsupportedOperationException 错误: java.lang ...

  3. Editplus格式化代码

    Editplus格式化代码插件(CSS,JS)今天在BlueIdea看到有人发了一篇名 为“让Editplus自动格式化css和js”的文章,看完后觉得写的很好,我也突然来了灵感,为什么不把前端开发常 ...

  4. WebLogic MBean Monitor

    weblogic server提供了一个dashboard让我们对mbean进行图形化的展现和分析,地址是 http://localhost:7001/console/dashboard 但有时候总是 ...

  5. insert语句太长,有StringBuilder优化一下

    private void btnSave_Click(object sender, RoutedEventArgs e) { if (IsInsert) { //假设日历控件没有选日期,那帮它赋一个当 ...

  6. JavaScript获取table中某一列的值的方法

    1.实现源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...

  7. 用C++实现Huffman文件编码和解码(2 总结)

    这个是代码是昨天写完的,一开始的时候还出了点小bug,这个bug在晚上去吃饭的路上想明白的,回来更改之后运行立刻完成最后一步,大获成功. 简单说下huffman编码和文件压缩主要的技术. Huffma ...

  8. selenuim-webdriver注解之@FindBy、@FindBys、@FindAll的区别

    selenium-webdriver中获取页面元素的方式有很多,使用注解获取页面元素是其中一种途径, 方式有3种:@FindBy.@FindBys.@FindAll.下文对3中类型的区别和使用场景进行 ...

  9. 【Dos】Dos命令大全

    dos命令大全 AT 计划在计算机上运行的命令和程序.ATTRIB 显示或更改文件属性.BREAK 设置或清除扩展式 CTRL+C 检查.CACLS 显示或修改文件的访问控制列表(ACLs).CALL ...

  10. jQuery OCUpload ——> 一键上传插件

    OCUpload为jQuery的插件(One Click Upload),意思为一键上传,封装了对于文件上传的一些方法,只需几行代码,文件上传优雅而简洁.      对于传统的文件上传,只是通过inp ...