LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   nvme boot on qemu howto? (https://www.linuxquestions.org/questions/slackware-14/nvme-boot-on-qemu-howto-4175624073/)

timsoft 02-20-2018 03:47 AM

nvme boot on qemu howto?
 
hi all, I have an nvme disk on real hardware booting from the bios in csm mode using (a patched version of) lilo, and it works fine. however, I am trying to test the patch on a virtual machine as well, just to make sure it (the patch) is ok. I am using qemu.
If I have just nvme drive/s in the vm, how can I specify to boot on that drive?. According to some qemu mail log, nvme boot support was added in 2016, but I haven't been able to find the parameters to use. I don't want to use uefi as I am testing my lilo patch on csm. I know I can add a second none-nvme drive to the vm and do it that way, but that defeats the point of testing booting off nvme only, with lilo on the nvme mbr.
Any hints would be appreciated.

Ztcoracat 02-21-2018 09:39 PM

Hi:

I know you said that you don't want to use UEFI but don't you have to use it in order for a Volatile Memory Host Controller Interface to boot?

This technoligy is new to me. Looking here as I go.
https://wiki.archlinux.org/index.php...ate_Drive/NVMe

This might help; that is if your mobo recognizes the nvme as a bootable device.

https://delightlylinux.wordpress.com...en-using-nvme/

I've read on a handful of Arch pages that you can do it with a efi partition with grub and systemd.
I can't even begin to think on how you would get it to play nice with lilo.

I searched for a while and couldn't find anything, sorry.

Ztcoracat 02-21-2018 10:05 PM

Another thought:-

Depending on your nvme Intel? Samsung? Kingston? or other model, go to the manufactures website for the device and see if they offer any tips for getting it to boot in a vm.

Hope this helps.
https://openchannelssd.readthedocs.i...ettingstarted/

Good Luck-

timsoft 02-22-2018 12:25 PM

my real nvme is adata (the right price, but still fast). I got that to boot initially using sys/etxlinux, and then after patching lilo, got it to boot with lilo (the real bios is eufi but running in legacy (csm) mode. an ami bios on an asrock a320m-hdv)
I have found ovmf for qemu (on sbo) which has a csm module, and offers to boot from nvme, but I havn't got it working yet, and am not sure whether it is my patch, or the bios. I'll keep this LQ thread open, and update it with progress..
Just to clarify, I have it working on real nvme hardware already with patched lilo, I am just tring to test my patch with virtual hardware now, (it is easier for remote testing, and repeatability, without messing up my real development pc, and I want more testing before submitting the patch to Pat)

Ztcoracat 02-22-2018 12:34 PM

Quote:

Originally Posted by timsoft (Post 5822921)
my real nvme is adata (the right price, but still fast). I got that to boot initially using sys/etxlinux, and then after patching lilo, got it to boot with lilo (the real bios is eufi but running in legacy (csm) mode. an ami bios on an asrock a320m-hdv)
I have found ovmf for qemu (on sbo) which has a csm module, and offers to boot from nvme, but I havn't got it working yet, and am not sure whether it is my patch, or the bios. I'll keep this LQ thread open, and update it with progress..
Just to clarify, I have it working on real nvme hardware already with patched lilo, I am just tring to test my patch with virtual hardware now, (it is easier for remote testing, and repeatability, without messing up my real development pc, and I want more testing before submitting the patch to Pat)

Good luck with your patch on a vm.

Kind Regards

Ztcoracat

Didier Spaier 02-22-2018 01:11 PM

I didn't want to comment before Tim get other answers, but I have tried his patch on a VirtualBox VM, to no avail so far. The patched lilo runs with no errors after having edited the boot= option of /etc/lilo.conf but still the virtual machine didn't reboot yet.

Maybe Tim you could either post your patch as an attachment (just give it a .txt extension then so it be accepted by LQ) or upload it somewhere and provide a link to there.

This way others could have a chance to test it in more contexts (like another virtualization program, or another mobo on bare metal).

timsoft 02-23-2018 04:27 AM

1 Attachment(s)
good idea Didier, attached is the patch so far. just apply the patch to the lilo source and build. it doesn't patch liloconfig yet, just lilo, but allows it to write to nvme disks. copy patch to lilo.Slackbuild folder, and add
Code:

patch -p1 < $CWD/mylilo.patch.txt
to the slackbuild, just after the other patch. run the script and install the package. To run from boot, replace existing lilo package with this one and re-create your dvd iso.
You will need to manually edit lilo.conf and replace /dev/sdva references with your /dev/nvme0n1 references.

if anyone can test it on a vm I would be grateful. (I can't get qemu to boot with ovmf yet, and the standard qemu bios does not give the option to boot from the nvme). I can boot from sda with nvme present, but that doesn't really test lilo installing to nvme. Any imput from someone who has done this successfully would be wonderful.
as I mentioned earlier, it is booting on real hardware. I will remove the other disks on the real hardware just leaving the nvme and see if it still boots, just to make sure.

timsoft 02-23-2018 01:48 PM

i can boot to the ovmf uefi shell. the ouput of map shows the nvme as blk4, and dblk blk4 shows the lilo string in the boot sector of the virtual nvme disk. unfortunately, I think I need the nvme blk device aliased to an fs device to get legacy (csm) boot to work. any input on legacy booting from uefi shell is appreciated...

chemfire 02-23-2018 02:14 PM

I am not posting to be judgemental. I think "because I want to" is a perfectly good reason to justify about anything one might do with a computer but...Can I ask why you want to boot with the CSM? Again more curious than anything?

elilo is really quite nice, IMHO with its text config and not needing to be re-installed to change kernels and initrds....

timsoft 02-23-2018 04:35 PM

since you asked,I am of the view "if it ain't broke, don't fix it". Apart from gpt support, which could have been added to regular bios, uefi is overkill, and has all sorts of ideas - such as safeboot, which sound nice, but are overkill, and make it harder for people to use linux. -most bioses only have microsoft certs in them, and anyone who likes playing around with kernels will have great difficulties with this extra secuirty features, unless they are bypassed, in which case - what's the point!.

having said all that, I don't like having to learn new stuff all the time, and it is easier for me to patch lilo to work with nvme disks, than to learn another boot manager; well, i'll delay it as long as i can - call me a troglodyte, i don't mind :-)
As a number of modern motherboards work with nvme in legacy mode (including my own), it is worth while emulating that, so that testing can be done. I already have it working on my hardware. it is emulation that I am having difficulties with. If you can contribute in this it would be appreciated.

timsoft 02-24-2018 12:41 PM

success :-)
 
2 Attachment(s)
i re-tested my real hardware with just nvme drive and sata cdrw, and it boots fine.

good news :-). an updated version of qemu is available from sbo, and the newer version works. ie. I can boot from single virtual nvme drive (and virtual cdrom attached for the installation), using my patched lilo - using non-uefi bios!
For those interested in testing, I used the following qemu parameters
Code:

qemu-system-x86_64 -cpu qemu64 -m 6G -cdrom /data/images/slack64patched.iso \
-machine q35 \
 -net nic,macaddr=02:00:00:11:11:17,model=i82551 \
-net bridge,br=br0 -enable-kvm -k en-gb -display vnc=:3 \
-monitor telnet:localhost:7102,server,nowait,nodelay \
-device pcie-root-port,id=pcie_r0,bus=pcie.0,chassis=0,slot=0 \
-device nvme,bootindex=1,drive=nvdisk1,serial=foo,bus=pcie_r0 \
-drive file=/data/images/testnvme.qcow2,format=qcow2,if=none,media=disk,cache=none,aio=native,discard=unmap,id=nvdisk1

(obviously for installing, I added
Code:

-boot menu=on
to paramter list to get the bios boot menu and booted from the cdrom.)
defining a pcie root port is probably overkill, although you can use it if you want multiple nvme drives define another port the same bus but different id and slot, and change the second nvme device to point to the id of the second "bus". see here http://lists.gnu.org/archive/html/qemu-devel/2018-02/msg00022.html for details.
see attachements for lilo boot screen on the vm, and once booted and logged in.

timsoft 02-25-2018 04:39 PM

liloconfig patch
 
1 Attachment(s)
for those interested, a patch for liloconfig is attached. When applied along with the lilo patch and package created, and used in place of the original, the installation "just works". - at least testing with a single nvme drive and sata cd/dvd.
to apply, copy attachment to same directory as liloconfig, cd to that directory and run
Code:

patch liloconfig myliloconfig.patch.txt
add the lilo patch into the slackbuild, (after the other patch) and run it. replace the old lilo package with the new one and create a new bootable dvd and enjoy :-)
If you find any problems, please let me know so I can fix them.

The only omission I would like to do is change the lba32 option to make it the default if the bios is more recent than 2000 (all bioses after 1998 should support lba32). something like...
Code:

BIOSDATE=`dmidecode -t bios|grep -i date|awk -F"/" '{print $3}'`
if [ $BIOSDATE -gt 2000 ]; echo "lba32">>$T_PX/etc/lilo.conf



All times are GMT -5. The time now is 10:35 AM.