You are not logged in.

#1 2016-01-12 10:02:19

ruinland
Member
Registered: 2013-11-06
Posts: 3

pass a directory as rootfs with 9pfs to qemu, fallback to initramfs

Hello all, sorry for my bad English in advance.

What I was doing is :
To pass a existing filesystem tree to qemu guest as rootfs with virto-9p.
Somehow, it complains that rootfs is not available.

Here's my command line to launch qemu - -

qemu-system-x86_64 -enable-kvm -m 2G -smp 2 -cpu host -nographic \
-kernel /boot/vmlinuz-4.4-x86_64 -initrd /boot/initramfs-4.4-x86_64.img \
-fsdev local,id=root,path=/path/to/jail_filesystem/,security_model=none \
-device virtio-9p-pci,fsdev=root,mount_tag=rpart \
-append 'root=rpart rw rootfstype=9p rootflags=trans=virtio,version=9p2000.L console=ttyS0'

and I tried to mount it from initramfs fallback shells but in vain - -

$ sh ~/start_9pfs_qemu.sh
:: running early hook [udev]
starting version 228
:: running hook [udev]
:: Triggering uevents...
:: running hook [resume]
ERROR: resume: no device specified for hibernation
:: running hook [keymap]
:: Loading keymap...kbd_mode: KDSKBMODE: Inappropriate ioctl for device
done.
ERROR: device 'rpart' not found. Skipping fsck.
ERROR: Unable to find root device 'rpart'.
You are being dropped to a recovery shell
    Type 'exit' to try and continue booting
sh: can't access tty; job control turned off
[rootfs /]# dmesg | grep -i 9p
[    0.000000] Command line: root=rpart rw rootfstype=9p rootflags=trans=virtio,version=9p2000.L console=ttyS0
[    0.000000] Kernel command line: root=rpart rw rootfstype=9p rootflags=trans=virtio,version=9p2000.L console=ttyS0
[    0.267425] 9pnet: Installing 9P2000 support
[    0.269640] 9p: Installing v9fs 9p2000 file system support
[    0.269671] FS-Cache: Netfs '9p' registered for caching
[rootfs /]# mount -t 9p -o trans=virtio rpart /new_root/
[   46.957535] 9pnet_virtio: no channels available
mount: special device rpart does not exist
[rootfs /]#

I've already added 9p & 9pnet_virtio kernel module into MODULES section in /etc/mkinitcpio.conf,
and regenerate initramfs.
"lsinitcpio -l /boot/initramfs-4.4-x86_64.img | grep 9p" also shows that 9p.ko, 9pnet.ko, 9pnet_virtio.ko are included.

/etc/mkinitcpio :

# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES="piix ide_disk reiserfs"
MODULES="9p 9pnet_virtio intel_agp i915"

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image.  This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=""

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way.  This is useful for config files.
FILES=""

# HOOKS
# This is the most important setting in this file.  The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added.  Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
##   This setup specifies all modules in the MODULES setting above.
##   No raid, lvm2, or encrypted root is needed.
#    HOOKS="base"
#
##   This setup will autodetect all modules for your system and should
##   work as a sane default
#    HOOKS="base udev autodetect block filesystems"
#
##   This setup will generate a 'full' image which supports most systems.
##   No autodetection is done.
#    HOOKS="base udev block filesystems"
#
##   This setup assembles a pata mdadm array with an encrypted root FS.
##   Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
#    HOOKS="base udev block mdadm encrypt filesystems"
#
##   This setup loads an lvm2 volume group on a usb device.
#    HOOKS="base udev block lvm2 filesystems"
#
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr, fsck and shutdown hooks.
HOOKS="base udev resume autodetect modconf block keyboard keymap filesystems fsck"

In the end,
my qemu version:
qemu-2.5.0 (build from AUR)

My guest linux kernel version :
4.4.0 (build with 9p fs support)
Here's my build:
kernel - -  (password is 0000)
http://box.nctu.edu.tw/index.php/s/3Rshp8xQIFsSQkS
Headers - - (password is 0000)
http://box.nctu.edu.tw/index.php/s/6Pc6HcySanbKmCZ


All advice, comments are appreciated, I really need to figure out what goes wrong ......

Offline

#2 2016-01-13 11:47:54

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: pass a directory as rootfs with 9pfs to qemu, fallback to initramfs

[tom@localhost ~]$ ls abc/
def
[tom@localhost ~]$ qemu-system-x86_64 -enable-kvm -m 2G -smp 2 -cpu host -nographic -kernel /boot/vmlinuz-linux -initrd /boot/initramfs-linux-fallback.img -fsdev local,id=root,path=/home/tom/abc,security_model=none -device virtio-9p-pci,fsdev=root,mount_tag=rpart -append 'console=ttyS0'
:: running early hook [udev]
starting version 228
:: running hook [udev]
:: Triggering uevents...
ERROR: device '' not found. Skipping fsck.
ERROR: Unable to find root device ''.
You are being dropped to a recovery shell
    Type 'exit' to try and continue booting
sh: can't access tty; job control turned off
[rootfs /]# mount -t 9p -o trans=virtio rpart /new_root/
[rootfs /]# ls /new_root/
def

Works here with repo kernel and default mkinitcpio.conf.

[   46.957535] 9pnet_virtio: no channels available
mount: special device rpart does not exist

These error will pop out if I try to mount with a wrong mount tag.

Also the stock init scripts in mkinitcpio need some modification for 9p rootfs anyway:
https://bugs.archlinux.org/task/45117
https://bugs.archlinux.org/task/45118

Offline

#3 2016-01-13 12:00:32

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,787
Website

Re: pass a directory as rootfs with 9pfs to qemu, fallback to initramfs

ruinland, please use code tags, rather than quote tags when pasting terminal output/config files/logs.

https://wiki.archlinux.org/index.php/Fo … s_and_code


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB