mkdir -p ~/guests/crux/lala/
cd ~/guests/crux/
dd if=/dev/zero of=crux.reiser4 bs=1GB count=0 seek=8
mkfs.reiser4 -fy crux.reiser4
mount crux.reiser4 lala/
#tar xJf /data/ISO-IMAGES/loop/rootfs.tar.xz -C lala/
for pkg in /data/ISO-IMAGES/loop/crux/core/*.tar.xz; do
    echo -n $pkg ...
    bsdtar xJf $pkg -C lala/ && echo done
done; unset pkg
du -sh lala/
#v3.5: 1.6G
tar xzf /data/kernels/5.2.21.domureiser4.modules.tar.gz -C lala/lib/modules/
echo modprobe tmem >> lala/etc/rc.modules
ls -lF lala/etc/rc.modules #already executable
vi lala/etc/rc #remove hwclock
vi lala/etc/rc.shutdown #remove hwclock
vi lala/etc/fstab

/dev/xvda1 / reiser4 defaults 0 1

vi lala/etc/inittab

c1:2:respawn:/sbin/agetty --noclear 115200 hvc0 xterm

vi lala/etc/rc.conf

SERVICES=(lo net crond sshd)

vi lala/etc/profile

case "$-" in *i*)
    alias ll='ls -alhF'
    alias cp='cp -i'
    alias mv='mv -i'
    alias rm='rm -i'

define a password first (renewal is enforced somehow) and then delete it

chroot lala/ passwd root
chroot lala/ passwd --delete --unlock root
#chroot lala/ usermod --expiredate "" --inactive -1 --unlock root
#chroot lala/ usermod -p '*' root

setup networking

vi lala/etc/rc.d/net


cat > lala/etc/resolv.conf <<EOF
search nethence.com

ready to go

umount lala/
rmdir lala/
vi crux

kernel = "/data/kernels/5.2.21.domureiser4.vmlinuz"
root = "/dev/xvda1 ro console=hvc0 net.ifnames=0 biosdevname=0 mitigations=off"
name = "crux"
vcpus = 3
maxvcpus = 8
memory = 7168
disk = ['file:/data2/guests/crux/crux.reiser4,xvda1,w']
vif = [ 'bridge=br0,vifname=crux.0' ]

xl create crux -c

Ready to leave

curl -I https://www.opendns.com/

history -c
#rm -f .bash_history
xl shu crux
tar cSf /data/templates/crux.reiser4.tar crux.reiser4


You are required to change your password immediately (administrator enforced)
login[266]: pam_unix(login:account): expired password for user root (root enforced)

I did not manage to avoid this issue while trying to setup a password-less root account

You are required to change your password immediately (administrator enforced)
usermod: PAM: Authentication token is no longer valid; new one required

Their kernel and RAMDISK load fine as PV guest (and displays with console=hvc0). However their rootfs does not show any prompt. This is what we are fixing over here.


Get the latest CRUX release

mkdir -p /data/ISO-IMAGES/
cd /data/ISO-IMAGES/


wget http://ftp.spline.inf.fu-berlin.de/pub/crux/crux-$rel/iso/crux-$rel.iso
#wget http://mirror.neolabs.kz/crux/crux-$rel/iso/crux-$rel.iso
wget http://ftp.morpheus.net/pub/linux/crux/crux-$rel/iso/crux-$rel.md5
md5sum crux-$rel.iso
cat crux-$rel.md5

#wget https://crux.ninja/updated-iso/crux-3.4-updated.iso
#wget https://crux.ninja/updated-iso/crux-3.4-updated.md5
#md5sum crux-3.4-updated.iso
#cat crux-3.4-updated.md5

Create a XEN/PV skeleton for it

mkdir -p /data/guests/crux/lala/
cd /data/guests/crux/
dd if=/dev/zero of=crux.reiser4 bs=1M count=0 seek=8191
mkfs.reiser4 -fy crux.reiser4

Fixing the rootfs

Mount the install media,

mkdir cdrom/
mount /data/ISO-IMAGES/crux-$rel.iso cdrom/

Make the PV compatible kernel and initramfs available

cp cdrom/boot/vmlinuz cdrom/boot/initramfs ./

Fix the agetty console thing for it to be XEN/PV ready

mkdir lala/ etc/
tar xJf cdrom/rootfs.tar.xz -C lala/
#less lala/usr/bin/serial_console
cp lala/etc/inittab etc/
rm -rf lala/
vi etc/inittab

#c1:2:respawn:/sbin/agetty --autologin root --noclear 38400 tty1 linux
c1:2:respawn:/sbin/agetty --autologin root --noclear 38400 hvc0 linux
#c1:2:respawn:/sbin/agetty --autologin root --noclear 115200,38400,9600 hvc0 linux

and APPEND it to the existing rootfs (otherwise you would face issues with /dev)

#tar: Cannot update compressed archives
xzcat cdrom/rootfs.tar.xz > rootfs.tar
tar --append -f rootfs.tar etc/inittab
tar tvf rootfs.tar | tail
time xz -z rootfs.tar 

Now enable your fix into a new install media image,

ls -lhF /data/ISO-IMAGES/crux-$rel.iso 
dd if=/dev/zero of=media.reiser4 bs=1G count=0 seek=1
mkfs.reiser4 -fy media.reiser4
mkdir media/
mount media.reiser4 media/
cp -a cdrom/* media/
cp -f rootfs.tar.xz media/
du -sh media/
umount media/
rmdir media/

Further clean-up

rm -f rootfs.tar.xz
rm -rf etc/
umount cdrom/
rmdir cdrom/

Ready to run the XEN/PV guest

vi crux

kernel = "/data/guests/crux/vmlinuz"
ramdisk = "/data/guests/crux/initramfs"
extra = "console=hvc0"
#root = "/dev/xvda ro"
name = "crux"
memory = 4096
vcups = 4
disk = ['file:/data/guests/crux/crux.reiser4,xvda,w',
vif = [ 'vifname=crux.0' ]

xl create crux -c

System Installation

mount /dev/xvda /mnt

add xvda and eventually tmpfs

#devpts /dev/pts devpts noexec,nosuid,gid=tty,mode=0620 0 0
#shm /dev/shm tmpfs defaults 0 0
cat >> /mnt/etc/fstab <<EOF
/dev/xvda / ext4 defaults 0 1
tmp /tmp tmpfs defaults 0 0
cat /mnt/etc/fstab

cp -pi /mnt/etc/rc.conf /mnt/etc/rc.conf.dist
vi /mnt/etc/rc.conf


do not forget to fix the inittab YET AGAIN

cp -pi /mnt/etc/inittab /mnt/etc/inittab.dist
vi /mnt/etc/inittab

#c1:2:respawn:/sbin/agetty --noclear 38400 tty1 linux
c1:2:respawn:/sbin/agetty --noclear 38400 hvc0 linux

cp -pi /mnt/etc/securetty /mnt/etc/securetty.dist
echo hvc0 >> /mnt/etc/securetty
cat /mnt/etc/securetty

ls -lkF /lib/modules/4.14.40/

umount /mnt/

Now disable the customized install media and boot normally

vi crux

root = "/dev/xvda ro"

disk = ['file:/data/guests/crux/crux.ext4,xvda,w']
#        'file:/data/guests/crux/media.ext4,xvdb,r']

NOTE THAT WE ARE KEEPING THE RAMDISK (see Troubleshooting to see what happens if not) – that seems to be the CRUX way to boot normally.

xl create crux -c

Additional Notes & Maintenance

In case you need to chroot into it for some reason

#mount --bind /dev lala/dev
#mount --bind /tmp lala/tmp
#mount -t proc proc lala/proc
#mount -t sysfs none lala/sys
#chroot lala/ /bin/bash
#localedef -i en_US -f UTF-8 en_US.UTF-8
#umount lala/{dev,tmp,proc,sys}

and eventually make a template out of this

cd /data/guests/
time tar cSf /data/templates/crux.`date +%s`.tar crux/
ls -lhF /data/templates/crux.*.tar


   * Copying devices from rootfs... cp: can't create '/newroot/dev/btrfs-control': No such file or directory

==> do not copy rootfs’s /dev/, use tar --append instead

blkfront: xvda: flush diskcache: enabled; persistent grants: enabled; indirect descriptors: enabled;
xenbus_probe_frontend: Device with no driver: device/vif/0
hctosys: unable to open rtc device (rtc0)
List of all partitions:
ca00         4194304 xvda 
 driver: vbd
No filesystem could mount root, tried: 

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(202,0)
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.40 #1
Call Trace:
 ? set_debug_rodata+0xc/0xc
 ? rest_init+0xa0/0xa0
Kernel Offset: disabled

==> keep the RAMDISK installer (seems to be the CRUX way to boot normally)

HVM Mode

cd /data/guests/cruxhvm/
dd if=/dev/zero of=cruxhvm.ext4 bs=1G count=0 seek=4
mkfs.ext4 cruxhvm.ext4

vi cruxhvm

#type = "hvm"
builder = "hvm"
sdl = 1

name = "cruxhvm"
memory = 1024
vcups = 4
disk = ['file:/data/guests/cruxhvm/cruxhvm.ext4,xvda,w',
vif = [ 'vifname=cruxhvm.0' ]

on_reboot = "preserve"
on_crash = "preserve"

xl create cruxhvm -c