在过去的两天里,我一直在尝试创建可引导的debian(jessie / 8.4)映像,据我所知,我拥有正确的过程,但无法获得正确的文件系统。我相对确定我在这里做错了什么,因为安装或丢失了一些/etc/fstab
((我的图像中没有)。我希望有经验的人能够帮助我/向我展示我所缺少的东西。
这是我启动qemu-system-x86时看到的错误:
作为文本,然后作为实际的屏幕截图:
错误:
fsck: error 2 (No such file or directory) while executing fsck.ext2 for /dev/sda1
fsck exited with status code 8
[FAILED] Failed to start Load/Save Random Seed
See `systemctl status systemd-random-seed.service` for details.
[FAILED] Failed to start Various fixups to make systemd work better on Debian.
See `systemctl status debian-fixup.service` for details.
...
[FAILED] Failed to start Update UTMP about System Boot/Shutdown.
See `systemctl status systemd-update-utmp.service` for details.
[DEPEND] Dependency failed for Update UTMP about System Runlevel Changes.
以下是我为自己写的说明/已采取的步骤:
cd ~
mkdir debootstrap
cd debootstrap/
# get newest
wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.80_all.deb
ar -x debootstrap_1.0.80_all.deb
zcat /root/debootstrap/data.tar.gz | tar xv
apt-get install parted
# 1.5Gbytes
dd if=/dev/zero of=1445.img bs=1024 count=1 seek=1536k
parted -s 1445.img -- mklabel msdos mkpart primary 1m 1.5g toggle 1 boot
losetup --show -f 1445.img
# prints out `/dev/loopX`, enter this on the next lin
partprobe /dev/loop0
# only have to make the filesytem once --> if you are troubleshooting steps, do not redo this line
mkfs -t ext2 /dev/loop0p1
mount /dev/loop0p1 /mnt
debootstrap --verbose --components=main,contrib,non-free \
--include=firmware-realtek,linux-image-amd64,grub-pc,ssh,vim \
--exclude=nano \
--arch amd64 jessie /mnt http://ftp.us.debian.org/debian
确保已安装内核,该内核应 与以下文件一起显示在
/boot
chroot中/mnt/boot
:initrd.img-3.16.0-4-amd64
vmlinuz-3.16.0-4-amd64
config-3.16.0-4-amd64
System.map-3.16.0-4-amd64
安装grub
grub-install --boot-directory=/mnt/boot --modules=part_msdos /dev/loop0
设置APT
复制适当的来源
cp /etc/apt/sources.list /mnt/etc/apt/sources.list
确保将cdrom源注释掉
添加行:
deb http://ftp.debian.org/debian stable-backports main contrib non-free
设置一个chroot
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev
# if you want your pushprofilesettings
cp ~/.bashrc /mnt/root/
cp ~/.vimrc /mnt/root/
# chroot -- enter the system as if it were thy own
chroot /mnt /bin/bash
export HOME=/root
export LC_ALL=C
export LANG=C.UTF-8
export TERM=xterm-256color
mount
from man mount:
--bind
在其他地方重新安装子树(其内容在两个地方都可用)。
-t <type>
挂载文件系统类型,mount
将尝试自动确定
设置串行/控制台访问
编辑/etc/default/grub
:
设置
GRUB_CMDLINE_LINUX=""
为:GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
取消评论
GRUB_TERMINAL=console
在下面,添加以下行:
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
使grub配置- 这 必须 在非做systemd-nspawn
外壳(这意味着 chroot
)
grub-mkconfig -o /boot/grub/grub.cfg
退出chroot
exit
清理chroot的
umount /mnt/sys
umount /mnt/dev
umount /mnt/dev/pts
umount /mnt/proc
可以检查额外的坐骑: mount | grep /mnt
然后卸载它们与 umount
输入systemd-nspawn
systemd-nspawn -D /mnt
# not you are in a special container
设置密码root
与passwd
在/etc/ssh/sshd_config
出评论PermitRootLogin without-password
阅读#PermitRootLogin without-password
并插入PermitRootLogin yes
其下方
现在在启动时启用ssh
systemctl enable ssh
清理
# this is needed to clean up both chroot and systemd-nspawn -D /mnt
# once this is run you can not do systemd-nspawn either so wait until you are entirely done
exit
umount /mnt
losetup -d /dev/loop0
使用以下命令检查是否有其他安装: mount | grep /mnt
如果 返回了ANYTHING ,请使用卸载它们 umount
恢复(仅在ERROR中是必需的)
如果分手的东西,或者需要重试,重新mount /对现有设置chroot的 .img
:
losetup --show -f 1445.img
# prints out `/dev/loopX`, enter this on the next lin
partprobe /dev/loop0
mount /dev/loop0p1 /mnt
测试img
qemu-system-x86_64 -hda 1445.img -m 1024 -vnc :0
sudo debootstrap --components=main,contrib,nonfree --variant=minbase --include=linux-generic,grub-pc --arch=i386 xenial /mnt
。