Ubuntu debootstrap 工具使用介绍
debootstrap是debian/ubuntu的工具,用来构建基本的操作系统,它比发行版的Linux小很多,本文介绍如何使用。
介绍
- 仅适用于
debian/ubuntu系统 - 使用场景
- 生成干净的测试环境,如编译环境
- 制作Docker镜像等
使用
- 安装
sudo apt-get install debootstrap- Help
$ debootstrap --help
Usage: debootstrap [OPTION]... <suite> <target> [<mirror> [<script>]]
Bootstrap a Debian base system into a target directory.
...说明:
suite可以在/usr/share/debootstrap/scripts中获取对应的名称--verbose显示更多日志
示例
- 创建基础镜像
$ mkdir foo-os && cd foo-os
$ sudo debootstrap --arch amd64 bionic . https://mirrors.tuna.tsinghua.edu.cn/ubuntu/成功标识 I: Base system installed successfully.,完成后将得到一个系统的基础文件,使用 chroot 命令,可以切换到以 ./foo-os/ 为根的系统中。