主要用到的命令为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. 踩的ssh坑

    先说下事情的起因,手贱删掉了~/.ssh下的所有文件,包括authorized_keys,id_rsa,id_rsa.pub,以及known_hosts.其实,这四个文件本来就是没有的,id_rsa和 ...

  2. tomcat访问(access)日志配置、记录Post请求参数(转)

    一.配置与说明 tomcat访问日志格式配置,在config/server.xml里Host标签下加上 <Valve className="org.apache.catalina.va ...

  3. C#Windows服务:一些方法(启动、停止等)

    前面讲述了如何创建和安装服务(创建windows服务),下面把启动.停止.判断是否启动的方法也写一下. /// <summary> /// 判断是否安装了某个服务 /// </sum ...

  4. 一道综合练习题实践list及dictionary集合类

    定义一个员工的集合,对员工集合内的元素进行查询和删除.实现员工的签到和签退,要求如下: //A:每天只能签到一次 //B:签退前必须已经签到 //C:显示打卡记录 代码如下:员工信息类: using ...

  5. 用Thunderbird以HTML发邮件,收件人却总是收到文本邮件

    要在通讯录里面,把你要发送的人设置可以接收HTML格式的邮件,那么你才能发出HTML格式. 否则,Thunderbird默认你所发的收件人无法接收HTML格式邮件.

  6. IOS研究之多个UITextField的键盘处理

    在IOS开发中使用UITextField时常须要考虑的问题就是键盘的处理. 有时候,弹出的键盘会将UITextField区域覆盖,影响用户输入.这个时候就要将视图上移.这个时候我们须要考虑两点: 1, ...

  7. 无password身份验证:安全、简单且部署高速

    Passwordless authentication: Secure, simple, and fast to deploy [编者按]本文作者为 Florian Heinemann 与 Rober ...

  8. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何把FBD功能块转换成ST语言

    假如我定义了一个MC_Power的标准功能块,我想知道它对应的ST语言   在MAIN(ST语言界面下)右击,Input Assistant,然后找到Standard Function Blocks, ...

  9. Quora使用到的技术

    本文主要参考了Phil Whelan的这篇文章<Quora’s Technology Examined>.关于Quora是个什么网站我就不多说了,国内对他的C2C网站叫“知乎”.呵呵.我们 ...

  10. Tp框架—方法中处理数据

    Tp框架-方法中处理数据 可以使用函数过滤处理内容. $data[$key]['content_title'] = mb_substr(strip_tags($val['content']) ,0,4 ...