1. pivot_root can/should be used together with chroot
       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.
       cd new_root
pivot_root . old-root
exec chroot . command umount /old-root

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.


2. switch_root newroot init [arg...]
       switch_root moves already mounted /proc, /dev and /sys to newroot and
makes newroot the new root filesystem and starts init process. switch_root is typically used with initramfs. WARNING: switch_root removes recursively all files and directories on
the current root filesystem.
   The following shell script fragment demonstrates how to use switch_root:
  # First, find and mount the new filesystem.
mkdir /newroot
mount /dev/whatever /newroot # Unmount everything else you've attached to rootfs. (Moving the filesystems
# into newroot is something useful to do with them.) mount --move /sys /newroot/sys
mount --move /proc /newroot/proc
mount --move /dev /newroot/dev # Now switch to the new filesystem, and run /sbin/init out of it. Don't
# forget the "exec" here, because you want the new init program to inherit
# PID 1. exec switch_root /newroot /sbin/init

switch_root vs pivot_root vs chroot【转】的更多相关文章

  1. slax linux的定制

    由于数据结构教学的需要,需要用到linux,要求就是小,启动快,可定制性强,恰好slax正好满足要求,以下就是定制slax linux的过程记录: 什么是Slax Slax是一个基于Linux的Liv ...

  2. linux系统 initrd.img中init启动脚本分析

    概述:这篇文章主体内容来源于网上转载.前面几篇文章倾向于制作initrd.img,这篇文章更倾向于initrd.img的运行过程:加载framebuff驱动 ide驱动和文件系统驱动,最后进入到真正的 ...

  3. Docker 核心技术与实现原理

    提到虚拟化技术,我们首先想到的一定是 Docker,经过四年的快速发展 Docker 已经成为了很多公司的标配,也不再是一个只能在开发阶段使用的玩具了.作为在生产环境中广泛应用的产品,Docker 有 ...

  4. mount rootfs

    主要用到的命令为pivot_root,可man 8 pivot_root了解用法. 1. pivot_root - change the root filesystem pivot_root new_ ...

  5. [转载] Docker 实现原理

    目录 Namespaces 进程 网络 libnetwork 挂载点 chroot
 CGroups UnionFS 存储驱动 AUFS 其他存储驱动 总结 原文链接:https://dravenes ...

  6. 后端技术杂谈10:Docker 核心技术与实现原理

    本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 https://github.com/h2pl/Java-Tutorial 喜欢的话麻烦点下 ...

  7. docker 学习路线

    docker 学习路线 参考资料 知乎 docker 的学习路线 Docker - 从入门到实践 Docker 核心技术与实现原理 Docker 入门 <Kubernetes in Action ...

  8. 【转】Docker 核心技术与实现原理

    转自:https://draveness.me/docker 提到虚拟化技术,我们首先想到的一定是 Docker,经过四年的快速发展 Docker 已经成为了很多公司的标配,也不再是一个只能在开发阶段 ...

  9. 理解 chroot

    什么是 chroot chroot,即 change root directory (更改 root 目录).在 linux 系统中,系统默认的目录结构都是以 `/`,即是以根 (root) 开始的. ...

随机推荐

  1. .net 语音,视频等格式转换

    最近在做微信公众号开发的时候遇到一个问题,就是微信接收到语音消息的格式为amr,在网页上通常不能直接播放,需要先转为mp3,于是找到了一个办法,使用ffmpeg.exe,网上可以搜一下ffmpeg.e ...

  2. Homework:工作日 还是周末

    /* 程序功能: 要求用户从键盘输入1~7之间的整数 如果输入的是1~5, 提示用户是工作日,要努力工作: 如果输入的是6或7,提示用户是休息日,放松休息: 否则,提示用户输入不在合法范围 */ #i ...

  3. JQ滚动条监听事件

    版权归作者所有,任何形式转载请联系作者.作者:帅阿猪(来自豆瓣)来源:https://www.douban.com/note/637256366/ 先来一个小例子: $(document).ready ...

  4. Win10 for Docker 安装 K8S

    win 10 docker安装K8S中遇见的一些问题,记录下来方便自己以后避免采坑. 安装步骤: 1.安装Docker for windows.在docker官方下载,然后傻瓜式安装. 安装成功以后再 ...

  5. 深入理解C++11【4】

    [深入理解C++11[4]] 1.基于范围的 for 循环 C++98 中需要告诉编译器循环体界面范围.如for,或stl 中的for_each: int main() { ] = { , , , , ...

  6. C#使用Owin技术部署轻量级webApi服务

    写在前面: 除了使用IIS可以启用WebApi之外,微软还提供了Owin技术,免除了IIS繁琐的部署配置,只需要运行编写好的程序,即可启用webApi服务,是不是很爽呢? 对于Owin技术的详细介绍这 ...

  7. SQLAlchemy介绍

    SQLAlchemy 增删改查 一对多 多对多   Python 的 ORM 框架 SQLAlchemy 有些同学已经听说过这个框架的大名了,也听说了 SQLAlchemy 没有 Django 的 M ...

  8. C/C++扩展Python的时候数据类型转换的对应:

  9. input控制输入保留一位小数

    function zlip(obj){ obj.value = obj.value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符 obj.val ...

  10. VLC 用到的那些 YUV 格式

    YUV是视频应用中使用的一类像素格式.YUV实际上是所有“YUV”像素格式共有的颜色空间的名称. 与RGB格式(红 - 绿 - 蓝)相对应,YUV颜色用一个称为Y(相当于灰度)的“亮度”分量和两个“色 ...