how to fix the devices name ordering in guest vm (devices name ordering changed after reboot vm by virsh)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2














my devices xml define:



first vm only has a root volume,



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/70395cacf62e49ec95246a919d449f64'/>
<backingStore type='block' index='1'>
<format type='qcow2'/>
<source dev='/dev/967b07c5ca8f429b9647785e942cbb4b/ce7774f0634a4d098a8d4e37838f4b6f'/>
<backingStore/>
</backingStore>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>


then I hot plug two disks on scsi.



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/6d38ee3091f64ca2bcb47b9dbd3c5901'/>
<backingStore/>
<target dev='sdb' bus='scsi'/>
<wwn>0x000fefc4071262fb</wwn>
<alias name='scsi0-0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/b1dcd7497e544284aba954b52ffc4754'/>
<backingStore/>
<target dev='sdd' bus='scsi'/>
<wwn>0x000f0683ab0ad875</wwn>
<alias name='scsi0-0-0-2'/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>


the device name order in guest vm match the plug order:
separate by disk size.



Disk /dev/sda: 6 MB, 6291456 bytes
1 heads, 12 sectors/track, 1024 cylinders
Units = cylinders of 12 * 512 = 6144 bytes
.
Disk /dev/sdb: 7 MB, 7340032 bytes
1 heads, 14 sectors/track, 1024 cylinders
Units = cylinders of 14 * 512 = 7168 bytes


But after reboot vm by virsh,
the disk name ordering is reversed. xml define is not changed.
how can I fix the devices name ordering?










share|improve this question























  • That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste.
    – dirkt
    Dec 13 at 9:47










  • udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way
    – MaximJ
    Dec 14 at 8:56











  • So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.)
    – dirkt
    Dec 14 at 9:11















2














my devices xml define:



first vm only has a root volume,



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/70395cacf62e49ec95246a919d449f64'/>
<backingStore type='block' index='1'>
<format type='qcow2'/>
<source dev='/dev/967b07c5ca8f429b9647785e942cbb4b/ce7774f0634a4d098a8d4e37838f4b6f'/>
<backingStore/>
</backingStore>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>


then I hot plug two disks on scsi.



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/6d38ee3091f64ca2bcb47b9dbd3c5901'/>
<backingStore/>
<target dev='sdb' bus='scsi'/>
<wwn>0x000fefc4071262fb</wwn>
<alias name='scsi0-0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/b1dcd7497e544284aba954b52ffc4754'/>
<backingStore/>
<target dev='sdd' bus='scsi'/>
<wwn>0x000f0683ab0ad875</wwn>
<alias name='scsi0-0-0-2'/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>


the device name order in guest vm match the plug order:
separate by disk size.



Disk /dev/sda: 6 MB, 6291456 bytes
1 heads, 12 sectors/track, 1024 cylinders
Units = cylinders of 12 * 512 = 6144 bytes
.
Disk /dev/sdb: 7 MB, 7340032 bytes
1 heads, 14 sectors/track, 1024 cylinders
Units = cylinders of 14 * 512 = 7168 bytes


But after reboot vm by virsh,
the disk name ordering is reversed. xml define is not changed.
how can I fix the devices name ordering?










share|improve this question























  • That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste.
    – dirkt
    Dec 13 at 9:47










  • udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way
    – MaximJ
    Dec 14 at 8:56











  • So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.)
    – dirkt
    Dec 14 at 9:11













2












2








2







my devices xml define:



first vm only has a root volume,



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/70395cacf62e49ec95246a919d449f64'/>
<backingStore type='block' index='1'>
<format type='qcow2'/>
<source dev='/dev/967b07c5ca8f429b9647785e942cbb4b/ce7774f0634a4d098a8d4e37838f4b6f'/>
<backingStore/>
</backingStore>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>


then I hot plug two disks on scsi.



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/6d38ee3091f64ca2bcb47b9dbd3c5901'/>
<backingStore/>
<target dev='sdb' bus='scsi'/>
<wwn>0x000fefc4071262fb</wwn>
<alias name='scsi0-0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/b1dcd7497e544284aba954b52ffc4754'/>
<backingStore/>
<target dev='sdd' bus='scsi'/>
<wwn>0x000f0683ab0ad875</wwn>
<alias name='scsi0-0-0-2'/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>


the device name order in guest vm match the plug order:
separate by disk size.



Disk /dev/sda: 6 MB, 6291456 bytes
1 heads, 12 sectors/track, 1024 cylinders
Units = cylinders of 12 * 512 = 6144 bytes
.
Disk /dev/sdb: 7 MB, 7340032 bytes
1 heads, 14 sectors/track, 1024 cylinders
Units = cylinders of 14 * 512 = 7168 bytes


But after reboot vm by virsh,
the disk name ordering is reversed. xml define is not changed.
how can I fix the devices name ordering?










share|improve this question















my devices xml define:



first vm only has a root volume,



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/70395cacf62e49ec95246a919d449f64'/>
<backingStore type='block' index='1'>
<format type='qcow2'/>
<source dev='/dev/967b07c5ca8f429b9647785e942cbb4b/ce7774f0634a4d098a8d4e37838f4b6f'/>
<backingStore/>
</backingStore>
<target dev='vda' bus='virtio'/>
<boot order='1'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>


then I hot plug two disks on scsi.



<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/6d38ee3091f64ca2bcb47b9dbd3c5901'/>
<backingStore/>
<target dev='sdb' bus='scsi'/>
<wwn>0x000fefc4071262fb</wwn>
<alias name='scsi0-0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='disk' snapshot='external'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/dev/967b07c5ca8f429b9647785e942cbb4b/b1dcd7497e544284aba954b52ffc4754'/>
<backingStore/>
<target dev='sdd' bus='scsi'/>
<wwn>0x000f0683ab0ad875</wwn>
<alias name='scsi0-0-0-2'/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>


the device name order in guest vm match the plug order:
separate by disk size.



Disk /dev/sda: 6 MB, 6291456 bytes
1 heads, 12 sectors/track, 1024 cylinders
Units = cylinders of 12 * 512 = 6144 bytes
.
Disk /dev/sdb: 7 MB, 7340032 bytes
1 heads, 14 sectors/track, 1024 cylinders
Units = cylinders of 14 * 512 = 7168 bytes


But after reboot vm by virsh,
the disk name ordering is reversed. xml define is not changed.
how can I fix the devices name ordering?







devices libvirtd libvirt virsh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 12 at 18:40









Filipe Brandenburger

6,8752734




6,8752734










asked Dec 12 at 16:28









MaximJ

111




111











  • That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste.
    – dirkt
    Dec 13 at 9:47










  • udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way
    – MaximJ
    Dec 14 at 8:56











  • So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.)
    – dirkt
    Dec 14 at 9:11
















  • That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste.
    – dirkt
    Dec 13 at 9:47










  • udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way
    – MaximJ
    Dec 14 at 8:56











  • So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.)
    – dirkt
    Dec 14 at 9:11















That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste.
– dirkt
Dec 13 at 9:47




That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste.
– dirkt
Dec 13 at 9:47












udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way
– MaximJ
Dec 14 at 8:56





udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way
– MaximJ
Dec 14 at 8:56













So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.)
– dirkt
Dec 14 at 9:11




So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.)
– dirkt
Dec 14 at 9:11















active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487609%2fhow-to-fix-the-devices-name-ordering-in-guest-vm-devices-name-ordering-changed%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487609%2fhow-to-fix-the-devices-name-ordering-in-guest-vm-devices-name-ordering-changed%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?