Mic92/nixos-shell

Can I mount a direct partition like /dev/sdc in the vm?

Closed this issue · 3 comments

I tried setting /dev/sdc as a mount but get an error of:

qemu-system-x86_64: -virtfs local,path=/dev/sdc,security_model=none,mount_tag=a457b9c00b7152b02ceea27e7fe1a07: cannot initialize fsdev 'a457b9c00b7152b02ceea27e7fe1a07': failed to open '/dev/sdc': Not a directory

From reading further it seems I need to set a -hda option, but once again I can't seem to find this in https://github.com/NixOS/nixpkgs/blob/b0df5a6816b644c2e0b6ebcde6ad0784b07205e0/nixos/modules/virtualisation/qemu-vm.nix either.

Not sure if this is the greatest place to ask, but if anyone know that would be appreciated.

Mic92 commented

virtfs expects a directory because it does filesharing with the host through 9p I would say. You can add your own flags by setting the QEMU_OPTS environment variable or by using config.virtualisation.qemu.options in your vm.nix.

Ohh so simple! Thank you! Hope you have a great weekend!

The final command I used was:

QEMU_OPTS="-hdc /dev/disk/by-uuid/836d83ab-cba5-4eb4-a7c8-09911cd67403" nixos-shell
Mic92 commented

Sometimes I feel that all I am doing with nixos-shell is documenting how our qemu abstractions works.