Diskless Debian 12 using iSCSI #1254
Replies: 2 comments
-
Ayayay, the solution to the bootloader problem is to not use a bootloader at all! After several attempts to use or build a bootloader (with So I simply extracted kernel and ramdisk from my Debian image and now pass them to the V86 constructor directly together with the iSCSI-rootfs kernel command line, like so (this boots without grub): const v86 = new V86({
// ...
bzimage: { url: 'img/vmlinuz-6.10.11+bpo-686-pae' },
initrd: { url: 'img/initrd.img-6.10.11+bpo-686-pae' },
cmdline: 'quiet vga=normal nomodeset root=UUID=8a4e2c74-e406-405c-a91e-9fd9bb4aeb5a ip=dhcp ISCSI_INITIATOR=iqn.2010-04.org.ipxe:client123 ISCSI_TARGET_NAME=iqn.2025-02.com.example:debian ISCSI_TARGET_IP=10.0.0.44 ISCSI_TARGET_PORT=3260',
// ...
}); And it works! I will post a full description with all details soon. Until then, I will bang my head against the wall. A few details from the system
|
Beta Was this translation helpful? Give feedback.
-
This is the complete setup procedure for a diskless Debian 12 (Bookworm) guest using iSCSI. This guide uses:
In iSCSI terminology, the iSCSI server is called the iSCSI target and the client the iSCSI initiator. Each iSCSI disk has a unique iSCSI Qualified Name (IQN). Three iSCSI software packages are used in this setup: The in-kernel iSCSI server The setup procedure is split into 6 sections:
In all, given sufficient network performance this setup works remarkably well. Scroll down to the last section Summary for more details. 1. Disk image setup and file exportThe instructions below create an 8G image file named Login to the iSCSI host and run the commands below to create the image and install Debian into it. Unless stated otherwise, commands can be copy-pasted, only 1.1 Prepare host# install required apt packages
sudo apt update && sudo apt upgrade
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install qemu-utils qemu-system-x86 debootstrap fdisk util-linux e2fsprogs
# create and enter working directory
sudo mkdir -p /var/local/debian-iscsi/mnt
sudo chown -R $USER:$USER /var/local/debian-iscsi
cd /var/local/debian-iscsi 1.2 Create, partition and format image file# create blank 8G disk image file
dd if=/dev/zero of=debian_iscsi.img bs=1M count=8K
# interactive: create a single partition, label type "dos":
# Device Boot Start End Sectors Size Id Type
# debian_iscsi.img1 2048 16777215 16775168 8G 83 Linux
sudo cfdisk debian_iscsi.img
# mount disk into loop0 and first partition into loop0p1
sudo losetup -f debian_iscsi.img && sudo partx -a /dev/loop0
# create ext4 file system
sudo mkfs.ext4 -L debian /dev/loop0p1
# unmount loop0[p1]
sudo partx -d /dev/loop0p1 && sudo losetup -d /dev/loop0 1.3 Install Debian root filesystem# mount debian_iscsi.img into ./mnt
# NOTE: 1048576 is the start offset of the first partition in bytes, block 2048 with
# a block size of 512 bytes (2048*512 = 1048576, also see see cfdisk above)
sudo mount -o loop,offset=1048576 debian_iscsi.img mnt
# install base system includig iSCSI client "open-iscsi"
sudo debootstrap --arch i386 --include=ca-certificates,linux-image-686,open-iscsi,nano bookworm mnt
# --- begin chroot ---
sudo chroot mnt /usr/bin/bash
# setup /etc/fstab
cat <<EOF > /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext4 errors=remount-ro 0 1
EOF
# setup /etc/apt/sources.list
cat <<EOF > /etc/apt/sources.list
deb https://deb.debian.org/debian bookworm main non-free-firmware
deb https://deb.debian.org/debian bookworm-updates main non-free-firmware
deb https://security.debian.org/debian-security bookworm-security main non-free-firmware
EOF
# setup hostname "debian-iscsi"
echo "debian-iscsi" > /etc/hostname
echo "127.0.0.1 debian-iscsi" >> /etc/hosts
# set root password to "root"
echo "root:root" | chpasswd
# update initrd
LC_ALL=C update-initramfs -u -k all
# --- end chroot ---
exit 1.4 Export kernel and initrd, finish# export "debian_iscsi-initrd.img" and "debian_iscsi-vmlinuz" (replace example kernel version "6.1.0-29")
cp mnt/boot/initrd.img-6.1.0-29-686 debian_iscsi-initrd.img
cp mnt/boot/vmlinuz-6.1.0-29-686 debian_iscsi-vmlinuz
# unmount debian_iscsi.img
sudo umount mnt 2. iSCSI server setupThis setup serves the image file created in the previous section named 2.1 Prepare host# install CLI frontend "targetcli" to access in-kernel iSCSI server LIO
sudo apt install targetcli-fb
# enable targetclid service, see https://manpages.debian.org/bookworm/targetcli-fb/targetclid.8.en.html
sudo systemctl enable targetclid
sudo systemctl start targetclid 2.2 Write server configurationFor additional information about these commands, see "Configuring and using iSCSI". # register iSCSI image file
sudo targetcli backstores/fileio create debian /var/local/debian-iscsi/debian_iscsi.img
# create target IQN
sudo targetcli iscsi/ create iqn.2025-02.com.example:debian
# create target LUN (Logical Unit Number)
sudo targetcli iscsi/iqn.2025-02.com.example:debian/tpg1/luns create /backstores/fileio/debian
# disable authentication and write-protection
sudo targetcli iscsi/iqn.2025-02.com.example:debian/tpg1/ set attribute \
authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1 Example output of
2.3 Store server configurationTo store the iSCSI server configuration persistently for the next reboot use: sudo targetcli saveconfig 2.4 Undo server configurationTo delete the server configuration while keeping the image file use: sudo targetcli /iscsi delete iqn.2025-02.com.example:debian
sudo targetcli /backstores/fileio delete debian To clear the persistent server configuration used at reboot use: sudo targetcli clearconfig 3. V86 boot setupExample code for an embedded V86 instance booting into the iSCSI root filesystem, replace const v86 = new V86({
// ...
bzimage: { url: 'debian_iscsi-vmlinuz' },
initrd: { url: 'debian_iscsi-initrd.img' },
cmdline: 'quiet acpi=off pnpbios=off nomodeset console=ttyS0,9600 console=tty0 root=/dev/sda1' +
' ip=dhcp ISCSI_TARGET_IP=10.0.0.44 ISCSI_TARGET_NAME=iqn.2025-02.com.example:debian',
// ...
}); Note that this example uses the two files exported earlier from the iSCSI image file (
4. First V86 boot and next stepsBoot, login and update apt, then install extra packages as needed ( apt update
apt install console-setup iperf htop pciutils To change timezone and keyboard layout (this requires extra support in v86, see v86-i18n) use: apt install locales
dpkg-reconfigure locales
dpkg-reconfigure tzdata A few additional
4.1 Enable Sound Blaster 16 sound cardIn order to load kernel module echo "options snd-sb16 isapnp=0 port=0x220 irq=7 dma8=1 dma16=5" > /etc/modprobe.d/sb16.conf
echo "snd-sb16" > /etc/modules-load.d/sb16.conf Reboot and ignore boot log message apt install alsa-utils Use aplay /usr/share/sounds/alsa/Front_Center.wav See here for more information. 4.2 Use
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
EDIT: See this comment further below for the full guide.
This is an experiment about running a diskless Debian 12 guest in v86 with its root filesystem externally stored in an iSCSI disk on a remote server. The iSCSI disk can be of any size, and anything written to it is permanently kept across v86 reboots.
The quality of this obviously depends on v86's network performance. The
iperf
network benchmark reports around 330 MBits/sec up- and downstream bandwidth for my v86 setup using my websock proxy serverwsnic
and I thought that's good enough to give it a try. See here for a v86 buildroot image that includesiperf
.Here the general steps (iSCSI host is also Debian 12):
debian_hda.img
, export image.debian_hda.img
and install apt packageopen-iscsi
, export image.debian_hda.img
to your iSCSI host, mount it and pack the entire root filesystem into a tar filedebian_rootfs.tar.gz
, unmount.debian_iscsi.img
, mount it, partition it with a single partition, install ext4fs and then unpackdebian_rootfs.tar.gz
into it, unmount.targetcli-fb
and make it servedebian_iscsi.img
(that part is actually pretty wild).debian_hda.img
and changegrub
configuration to mount our iSCSI network disk as the root file system, export image.Now, if I boot
debian_hda.img
normally it boots with the 8G iSCSI disk as the root filesystem, and if I boot into grub rescue mode it boots with the normal 2G hda rootfs.In all, it does not feel different from a normal v86 Debian 12 installation, I ran a few tests and it's quite snappy and usable. I'm not sure how to best measure harddisk performance, see "iSCSI rootfs benchmark" below in the Details section which came up with a write speed of 65,4 MB/s, which I'm sure sucks under normal circumstances.
The biggest obstacle was how to boot the iSCSI disk (iPXE doesn't work at all with v86), and I'm sure there are better ways like booting with a kernel and an initrd instead of from an image with a hacked up grub. All of this is still work-in-progress, and there are many variants for this and certainly better ones or involving less steps, but it's a start.
The setup is not simple, but I kept extensive notes and I'll post all details here if anyone is interested.
Details
iSCSI rootfs boot messages
iSCSI rootfs "fdisk -l"
Note:
/dev/sda1
is the hda disk and/dev/sdb1
the iSCSI disk./dev/sda1
is not mounted.iSCSI rootfs "df -h"
iSCSI rootfs benchmark
Beta Was this translation helpful? Give feedback.
All reactions