一个简洁实用的进入 Chroot 环境的脚本

之前在某处看到了这么一份用于进入 Chroot 环境的 Bash 脚本,感觉不错就收藏了。先贴一下原始脚本: 1#!/bin/bash 2 3CHROOT_DIR=$(dirname $(readlink -f $0)) 4 5USAGE=" 6Usage: sh $0 [option] 7 8Warning: This script cannot be used in compile_env 9Options: 10 init init compile_env and mount the required directories 11 no option default to init 12 umount clean up …

Create a Minimalist `Chroot` Environment

Learnt from this article by Dave McKay . Create the root directory of the chroot environment if it doesn’t exist. 1chr=/home/ricky/testroot 2mkdir -p $chr Create necessary directories and then get into the environment. 1mkdir -p $chr/{bin,lib,lib64} 2cd $chr Copy the binaries we need for surviving on this …