Virsh - Auto attach disk at boot

General support questions
L4celek
Posts: 7
Joined: 2014/01/09 23:58:30

Virsh - Auto attach disk at boot

Postby L4celek » 2018/01/27 05:51:15

Hi all,

not sure where to find this info

Every so often my server is rebooted (wife clips the plug, power outage etc..) and when this happens I have to go and rerun all the attach-disk commands and do a vgchange on my guest.

Is there some way of saving the current used config so this automatically happens in the future?

User avatar
TrevorH
Forum Moderator
Posts: 21715
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Virsh - Auto attach disk at boot

Postby TrevorH » 2018/01/27 14:03:58

Do your virsh attach-disk commands but use --config to affect the xml it uses to start it up next time. Or use virsh edit to edit the xml and add the disks there.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Emma Taylor
Posts: 58
Joined: 2015/04/11 04:59:25
Location: United Kingdom

Re: Virsh - Auto attach disk at boot

Postby Emma Taylor » 2018/01/31 05:51:51

Attach a disk image to a guest's CD-ROM drive:

Code: Select all

# virsh attach-disk <GuestName> sample.iso hdc --type cdrom --mode readonly


Disk attached successfully

L4celek
Posts: 7
Joined: 2014/01/09 23:58:30

Re: Virsh - Auto attach disk at boot

Postby L4celek » 2018/01/31 07:52:10

TrevorH wrote:Do your virsh attach-disk commands but use --config to affect the xml it uses to start it up next time. Or use virsh edit to edit the xml and add the disks there.


Thanks Trevor,

I saw this in the docs with a <config file> marker and didn't know which file to put there. It worked without the filename, and so I suspect this has done the trick :)