Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to get qemu-kvm to boot from my live usb stick. Is this possible?

share|improve this question

4 Answers 4

up vote 10 down vote accepted

qemu-kvm -hdb <device>, where <device> is the USB stick (e.g. /dev/sdb), should do it (tested with Ubuntu 12.04 on an USB stick and it works).

You will need write permission to the device (i.e. be root or change its permissions).

share|improve this answer
2  
Good answer. BTW if you need an easy interface to manage your VMs, give virt-manager a try. –  wazoox May 2 '12 at 21:19
    
Nice! That made my day. Thanks! –  Mike Williamson May 2 '12 at 21:22
1  
Just as a hint: I tried VirtualBox instead of kvm to test my live usb stick, and it's A LOT faster. You have to use this command as root to create a vmdk file to be used in VirtualBox: VBoxManage internalcommands createrawvmdk -filename .VirtualBox/HardDisks/usbdisk.vmdk -rawdisk /dev/sdb –  Marc MAURICE Mar 17 '13 at 8:37
1  
Just a small note to self here - use the disk/device node in -hdb (e.g. /dev/sdb); NOT the partition (as in /dev/sdb4) –  sdaau May 28 '13 at 14:10

I don't know why exactly, but Renan's answer didn't quite work for me. KVM said to me it couldn't find a bootable drive (despite the usb partition being marked as such).

However I've found another solution. Get the USB device VendorID:ProductID with lsusb. Example:

$ lsusb
...
Bus 002 Device 007: ID 0781:5406 SanDisk Corp. Cruzer Micro U3

Pass that to KVM, and ask for the boot menu:

sudo  kvm -m 512 -smp 1 -drive file=/path/to/hardisk/file.img -usb \ 
-usbdevice host:0781:5406 -boot menu=on

Press F12 for the menu, choose the usb device, it works. There's probably a way to command the usb boot without needing to call the boot menu, but I didn't find any in man kvm.

share|improve this answer

If you want to use an image of a liveusb, instead of a physical USB stick, you can do that with

$ kvm -usbdevice disk:/path/to/liveusb.img -boot menu=on ...

Without "-boot menu=on", kvm will always prefer the hard drive that you set with "-drive" or "-hd[a|b|c|d]".

share|improve this answer

qemu-kvm has disappeared. use the hint in start qemu by giving it a path to a linux root instead. this means

qemu-system-x86_64 -usb -usbdevice disk:/dev/sdb

where /dev/sdb is your raw device (not partition) of the usb stick that you want to boot.

(however, as of 12/2014, it's been flaky for me. booting ubuntu-gnome 14.10 results eventually in a kernel panic on a stick verified to boot just fine on the metal.)

/iaw

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.