switch_root vs pivot_root vs chroot【转】
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【转】的更多相关文章
- slax linux的定制
由于数据结构教学的需要,需要用到linux,要求就是小,启动快,可定制性强,恰好slax正好满足要求,以下就是定制slax linux的过程记录: 什么是Slax Slax是一个基于Linux的Liv ...
- linux系统 initrd.img中init启动脚本分析
概述:这篇文章主体内容来源于网上转载.前面几篇文章倾向于制作initrd.img,这篇文章更倾向于initrd.img的运行过程:加载framebuff驱动 ide驱动和文件系统驱动,最后进入到真正的 ...
- Docker 核心技术与实现原理
提到虚拟化技术,我们首先想到的一定是 Docker,经过四年的快速发展 Docker 已经成为了很多公司的标配,也不再是一个只能在开发阶段使用的玩具了.作为在生产环境中广泛应用的产品,Docker 有 ...
- mount rootfs
主要用到的命令为pivot_root,可man 8 pivot_root了解用法. 1. pivot_root - change the root filesystem pivot_root new_ ...
- [转载] Docker 实现原理
目录 Namespaces 进程 网络 libnetwork 挂载点 chroot CGroups UnionFS 存储驱动 AUFS 其他存储驱动 总结 原文链接:https://dravenes ...
- 后端技术杂谈10:Docker 核心技术与实现原理
本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 https://github.com/h2pl/Java-Tutorial 喜欢的话麻烦点下 ...
- docker 学习路线
docker 学习路线 参考资料 知乎 docker 的学习路线 Docker - 从入门到实践 Docker 核心技术与实现原理 Docker 入门 <Kubernetes in Action ...
- 【转】Docker 核心技术与实现原理
转自:https://draveness.me/docker 提到虚拟化技术,我们首先想到的一定是 Docker,经过四年的快速发展 Docker 已经成为了很多公司的标配,也不再是一个只能在开发阶段 ...
- 理解 chroot
什么是 chroot chroot,即 change root directory (更改 root 目录).在 linux 系统中,系统默认的目录结构都是以 `/`,即是以根 (root) 开始的. ...
随机推荐
- MATLA总结三
1.将分数表示转换为小数表示: vpa( ******(表达式或者变量), n(小数点后几位)) 2.将一个式子中的变量带入具体的值: subs( y, x, [2,3,4] ) 3.用工具箱确定阶 ...
- 20175314薛勐 MyCP(课下作业,必做)
MyCP(课下作业,必做) 要求 编写MyCP.java 实现类似Linux下cp XXX1 XXX2的功能,要求MyCP支持两个参数: java MyCP -tx XXX1.txt XXX2.bin ...
- vue根据路由变换,切换导航栏样式
<ul> <li> <router-link :to="{name: 'home'}" class="active_item" e ...
- [leetcode]149. Max Points on a Line多点共线
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...
- JavaSE基础知识(5)—面向对象(5.4面向对象三大特征:封装、继承、多态)
面向对象编程具有三大特征: 封装 继承 多态 一.封装 1.好处 狭义的封装:也就是属性的封装,避免了任意赋值的危险,提高了数据的安全性! ①隐藏一个类中不需要对外提供的实现细节 ②使用者只能通过实现 ...
- windows批量停止服务
此代码适合有一定windows操作系统基础的人使用 @echo off for %%i in ( mysql OracleDBConsoleleak OracleMTSRecoveryService ...
- svg绘制一个简单地饼图
一个简单地svg绘制饼图的demo,代码如下 <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...
- vuex状态管理
msvue组件间通信时,若需要改变多组件间共用状态的值.通过简单的组件间传值就会遇到问题.如:子组件只能接收但改变不了父组件的值.由此,vuex的出现就是用作各组件间的状态管理. 简单实例:vuex的 ...
- centos中病毒
嗯 很开中了病毒,,,而且这是第二次了.... 然后大佬说让我 crontab -l 一下 然后试了下 然后出来这个东东 执行下 crontab -r 这个 然后就crontab -l 就 ...
- mysql修改用户密码命令
C:\Users\20160216>mysql -h 10.180.6.183 -u root -pEnter password: ******Welcome to the MySQL moni ...