dev@devhost:/opt/vm/xpvm1$sudo virsh attach-device < domain-name> filename |
Where filename is a file defined in XML format (we’ll call it Disk.xml) :
< Disk type = “file” device = “cdrom” & gt; < The source file = “/ opt/vm/drivers. Iso/& gt;” < Target HDC dev = “”/& gt; < readonly/> < /disk> |
The virtual machine was originally mounted ona CD-ROM called Windows_xp_professional_sp3_x89.ISO:
< domain type=’kvm’> & lt; name> XP_VM< /name> & lt; uuid> 91f15b08-e115-4016-a522-b550ff593af9< /uuid> & lt; memory> 1024000< /memory> & lt; currentMemory> 1024000< /currentMemory> & lt; vcpu> 1< /vcpu> & lt; os> & lt; Type the arch = ‘x86_64 machine =’ PC ‘& gt; hvm< /type> & lt; boot dev=’hd’/> & lt; boot dev=’cdrom’/> & lt; Bootmenu enable = ‘yes’/& gt; & lt; /os> & lt; features> & lt; acpi/> & lt; apic/> & lt; pae/> & lt; /features> & lt; cpu> & lt; The topology sockets = ‘1’ cores = ‘1’ threads = ‘1’/& gt; & lt; /cpu> & lt; = ‘localtime’ clock offset/& gt; & lt; on_poweroff> destroy< /on_poweroff> & lt; on_reboot> restart< /on_reboot> & lt; on_crash> restart< /on_crash> & lt; devices> & lt; emulator> /usr/bin/qemu-system-x86_64< /emulator> & lt; = ‘disk disk type =’ file ‘device’ & gt; & lt; Qemu driver name = ‘ ‘type =’ qcow2 ‘/ & gt; & lt; The source file = ‘/ opt/vm/xpvm1 xp_c. Img’ lock = ‘exclusive’/& gt; & lt; Target dev = ‘hda bus =’ ide ‘/ & gt; & lt; /disk> & lt; = ‘disk disk type =’ file ‘device’ & gt; & lt; Qemu driver name = ‘ ‘type =’ qcow2 ‘/ & gt; & lt; The source file = ‘/ opt/vm/xpvm1 xp_d. Img’ lock = ‘exclusive’/& gt; & lt; target dev=’hdb’ bus=’ide’/> & lt; /disk> & lt; = ‘cdrom disk type =’ file ‘device’ & gt; & lt; source file=’/opt/vm/windows_xp_professional_sp3_x86.iso’/> & lt; target dev=’hdc’/> & lt; readonly/> & lt; /disk> & lt; The channel type = ‘spicevmc & gt; & lt; Target type = ‘virtio’ name = ‘com. Redhat. Spice. 0’/& gt; & lt; Alias name = ‘virserial – channel1’/& gt; & lt; /channel> & lt; Interface type = ‘bridge’ & gt; & lt; MAC address = ’52:54:00:7 b: a8: d8’/& gt; & lt; The source bridge = ‘virbr0/& gt; & lt; = ‘vnet1’ target dev/& gt; & lt; The model type = ‘virtio/& gt; & lt; /interface> & lt; Input type = ‘tablet’ bus = ‘usb’/& gt; & lt; Graphics type=’spice’ port=’4000′ autoport=’no’ listen=’0.0.0.0′> & lt; Listen type = ‘address’ address = ‘0.0.0.0’/& gt; & lt; Agent_mouse mode = ‘off’/& gt; & lt; /graphics> & lt; Memballoon model = ‘virtio & gt; & lt; alias name=’balloon0’/> & lt; /memballoon> & lt; Sound model = ‘ac97 & gt; & lt; Address type=’ PCI ‘domain=’0x0000′ bus=’0x00′ slot=’0x04’ function=’0x0’/> & lt; /sound> & lt; video> & lt; The model type = ‘QXL vram =’ 65536 ‘heads =’ 1 ‘/ & gt; & lt; /video> & lt; /devices> & lt; qemu:commandline> & lt; Qemu: arg value = “-” CPU/& gt; & lt; Qemu: arg value = “kvm64″/& gt; & lt; /qemu:commandline> < /domain> |
After installing the system, what you see in the virtual machine is:
Instead of re-closing and defining a new disc file, we can change the disc using the Virsh Attach – Device command:
dev@devhost:/opt/vm/xpvm1$sudo virsh attaching -device XP_VM disk.xml |
The advantage of doing this is that in some cases we can achieve the effect of a hot plug disc without having to restart the virtual machine.
Note: It should be noted that, after testing, there must first be an initial optical device in the defined XML, otherwise the execution of another optical device will fail: internal Error No device with bus ‘ide’ and target ‘HDC’ reported error.
That is, this is actually a swap, not a dynamic mount, and the cd-ROM device itself must be defined in XML before the virtual machine can be started.
Read More:
- Solve the problem that the virtual machine can’t be opened? Tips on VMware Workstation cannot connect to the virtual machine
- Problem solving: this application cannot run under a virtual machine arcmapr, but you are not using a virtual machine
- Ubuntu xshell cannot connect to VMware virtual machine solution
- Solution of Prophet error reporting when installing R package in Kubuntu virtual machine environment
- Win10 system virtual machine installation of Ubuntu system failed, prompt: UBI language failed with exit code 1
- Install Xen virtual machine using virt-manager
- (Virtual machine monitor failed and Virtual ethernet failed)
- Modify the VDI path of VirtualBox on MacOSX, and transfer the virtual machine
- Quickly solve the problem of Vmware virtual machine “\\.\Global\vmx86”: the system cannot find the specified file
- A new virtual machine cannot be connected to the network (error fetching interface information device not found),
- Error report when Hyper-V creates virtual machine
- The solution to the problem that the virtual machine and the host SSH can’t connect on vmvare
- Putty remote login VMware virtual machine Linux
- VirtualBox reports an error supr3hardenedwinrespawn what 5 when opening the virtual machine
- Record of solutions to internal error when VMware starts virtual machine
- How to Fix VMware Taking ownership of this virtual machine failed
- Error: could not create the Java virtual machine
- VMware virtual machine installation of vmware tools, VMware shared folder location
- VirtualBox + CentOS 7 virtual machine setting static IP address of host only NIC
- Nat mode of network configuration for VMware virtual machine