debian

制作debian chroot

1
2
apt-get install binutils debootstrap
debootstrap --foreign --no-check-gpg --arch amd64 buster buster "http://mirrors.aliyun.com/debian/"

下载完成后打包并拷贝到群晖

1
tar -zcvf buster.tar.gz buster

群晖:

解压,初始化安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mkdir -p /volume1/chroot
cd /volume1/chroot && tar zxf buster.tar.gz
CHROOT=/volume1/chroot/buster

# 设置基础配置
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
cp /etc/hosts $CHROOT/etc/hosts
cp /etc/hostname $CHROOT/etc/hostname

# 挂在载文件系统
mount -o bind /dev $CHROOT/dev
mount -o bind /proc $CHROOT/proc
mount -o bind /dev/pts $CHROOT/dev/pts
mount -o bind /sys $CHROOT/sys

# 初始化安装
chroot $CHROOT /debootstrap/debootstrap --second-stage

# 进入chroot系统
chroot $CHROOT /bin/bash

# 有几个软件包依赖ischroot来确定chroot中的正确行为,识别正确的系统环境
ln -s /bin/true /usr/bin/ischroot

设置软件源

1
2
3
deb http://mirrors.aliyun.com/debian buster main contrib non-free
deb http://mirrors.aliyun.com/debian buster-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security buster/updates main

设置地区和时区

1
2
3
apt-get install locales
dpkg-reconfigure locales
dpkg-reconfigure tzdata

退出chroot 卸载文件系统

1
2
3
4
5
6
umount $CHROOT/dev/pts
umount $CHROOT/dev
umount $CHROOT/proc
umount $CHROOT/sys
umount $CHROOT/mnt/volume1
umount $CHROOT/mnt/volume2

在群晖系统里设置debian chroot开机启动

1
2
3
4
5
6
7
8
9
10
11
cat > /usr/local/etc/rc.d/chrootbuster.sh << EOF
CHROOT=/volume1/chroot/buster
mount -o bind /dev \$CHROOT/dev
mount -o bind /proc \$CHROOT/proc
mount -o bind /dev/pts \$CHROOT/dev/pts
mount -o bind /sys \$CHROOT/sys
mount -o bind /volume1 \$CHROOT/mnt/volume1
mount -o bind /volume2 \$CHROOT/mnt/volume2
EOF
chmod +x /usr/local/etc/rc.d/chrootbuster.sh
/usr/local/etc/rc.d/chrootbuster.sh