在过去的两天里,我一直在尝试创建可启动的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
Ensure that the kernel is installed, it should appear in /boot
within the chroot, that is /mnt/boot
with the following files:
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
install grub
grub-install --boot-directory=/mnt/boot --modules=part_msdos /dev/loop0
Set up APT
copy over the apt sources
cp /etc/apt/sources.list /mnt/etc/apt/sources.list
ensure the cdrom source is commented out
add the line:
deb http://ftp.debian.org/debian stable-backports main contrib non-free
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
Remount a subtree somewhere else (its contents are available in both places).
-t <type>
Mount of filesystem type, with this, mount
will attempt to auto determine
edit /etc/default/grub
:
Set GRUB_CMDLINE_LINUX=""
to:
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
Uncomment GRUB_TERMINAL=console
Beneath, add the line:
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
Make the grub config - This MUST be done in a non-systemd-nspawn
shell (that means chroot
)
grub-mkconfig -o /boot/grub/grub.cfg
exit
umount /mnt/sys
umount /mnt/dev
umount /mnt/dev/pts
umount /mnt/proc
Can check for additional mounts with: mount | grep /mnt
and then unmount them with umount
systemd-nspawn -D /mnt
# not you are in a special container
Set the password for root
with passwd
In /etc/ssh/sshd_config
comment out PermitRootLogin without-password
to read #PermitRootLogin without-password
and insert PermitRootLogin yes
beneath it
Now enable ssh on startup
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
Check for additional mounts with: mount | grep /mnt
If ANYTHING is returned, unmount them with umount
If you broke something, or need to retry, RE-MOUNT / SETUP CHROOT on existing .img
:
losetup --show -f 1445.img
# prints out `/dev/loopX`, enter this on the next lin
partprobe /dev/loop0
mount /dev/loop0p1 /mnt
qemu-system-x86_64 -hda 1445.img -m 1024 -vnc :0
Kept at it and figured it out, relatively straight forward from here, but not just a matter of setting up /etc/fstab
, here is the rest:
not necessary but a good idea to clean things up
apt-get autoclean
设置/etc/fstab
-检查mount
以确保您使用的是正确的文件系统类型
echo "/dev/sda1 / ext4 defaults,errors=remount-ro 0 1" > /etc/fstab
这将重建initramfs并使其干净启动
update-initramfs -u -k all
这样做,机器启动干净,在QEMU中进行了测试,然后我现在就在硬件上运行它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句