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. Python开发者年度调研,结果出乎意料!

    来源商业新知网,原标题:Python开发者年度调研:一半Python用户也用JS,2/3选择Linux系统 作为高级编程语言,Python的受欢迎程度近几年一直在往 上涨.每年,Python官方都会针 ...

  2. 交叉熵理解:softmax_cross_entropy,binary_cross_entropy,sigmoid_cross_entropy简介

    cross entropy 交叉熵的概念网上一大堆了,具体问度娘,这里主要介绍深度学习中,使用交叉熵作为类别分类. 1.二元交叉熵 binary_cross_entropy 我们通常见的交叉熵是二元交 ...

  3. Game Engine Architecture 9

    [Game Engine Architecture 9] 1.Formatted Output with OutputDebugString() int VDebugPrintF(const char ...

  4. python 并发编程 锁 / 信号量 / 事件 / 队列(进程间通信(IPC)) /生产者消费者模式

    (1)锁:进程之间数据不共享,但是共享同一套文件系统,所以访问同一个文件,或同一个打印终端,是没有问题的,而共享带来的是竞争,竞争带来的结果就是错乱,如何控制,就是加锁处理. 虽然使用加锁的形式实现了 ...

  5. Beanstalkd消息队列 -- php类Pheanstalk使用

    业务场景 商城订单生成30分钟后 如果未支付关闭订单 解决办法 可以使用延迟消息队列   这里我们用的是beanstalkd Beanstalkd介绍 Beanstalk,一个高性能.轻量级的分布式内 ...

  6. python之全局变量与局部变量

    全局变量: -   在书写中顶格开始: -   一旦定义完毕在整个文件生效: -   在函数内如果定义了同名全局变量名,会“覆盖”掉全局变量: -   在函数中同名的变量,当在函数退出后消失,全局的同 ...

  7. SpringMVC中注解@RequestBody和@ResponseBody的使用区别

    首先上源码 在面试时经常会问到我们如何使用SpringMVC将Http请求转换为java对象,或者又是问如何将结果转换为java的呢? SpringMVC在接收到请求之后HandlerMapping像 ...

  8. leetcode 字谜

    242. Valid Anagram Easy 66298FavoriteShare Given two strings s and t , write a function to determine ...

  9. 安装centos 6.7&7.4

    1.安装centos 6.7 1) 2)检查软件有无故障.没有必要检查.选择skip,跳过 3) 4) 5) 6)选择存储设备,第一个为基本存储设备,比如ssd,scsi等常见笔记本.电脑,服务器都选 ...

  10. CentOS7+CDH5.14.0安装CDH错误排查: HiveServer2 该角色的进程已退出。该角色的预期状态为已启动

    错误提示: HiveServer2 该角色的进程已退出.该角色的预期状态为已启动 解决办法:出现此问题应该是内存不足造成的,重启相应的组件即可.比如Hive报错,重启Hive,YARN报错,重启YAR ...