There is a way to indicate to grub to install on a device MBR by UUID instead of using /dev/sdX ? I'm setting a external eSATA hard disk with NixOS, and obviusly, the hard disk not would be always the same /dev/sdX device ?

I see that I can config it with boot.loader.grub.device = "/dev/sdX", but could set it to something like "/dev/disk/by-uuid/...." ??

  • Did you try it? What were the results?
    – user
    Feb 5 '15 at 9:42
  • I'm just trying it ... /dev/disk/by-uuid/XXX not would work as on my case, the hard disk alone not have a UUID. But /dev/disk/by-id/XXX looks that could work. nixos-rebuild dry-run don't output any error, so I would try it now.
    – Zardoz89
    Feb 5 '15 at 18:15

grub-install /dev/by-uuid/XXX not would work becasue the whole hard disk not gets a UUID (at least on my machine). Instead, we could use /dev/by-id/XXX that is generated using the serial number of the hard disk.

On NixOS configuration file would be :

boot.loader.grub.device = "/dev/by-id/XXXX"

try grub-install "UUID=700C663F-4183-4A8D-BAC2-EE34E5518B9C" /dev/sda0 UUID is "/" partition sda0 is "/" device Source is grub2 manual /dev/disk/by-uuid/ does not work because this directory does not exist until is booted it is preferred to use partuuid as this dos not change with reformatting- uuid changes with formatting

  • As I said "not would work becasue the whole hard disk not gets a UUID (at least on my machine).". Using /dev/by-id/XXXXX just works fine on my case. Also, I'm configuring nixos, so I need to setup it on text config file, not run directly grub with a parameter.
    – Zardoz89
    May 13 '15 at 7:07

Yes, modify /boot/grub/menu.cfg


...give it a whirl.

For example

set root=/dev/disk/by-uuid/'3a2adf19-8685-483c-9889-1b4d56788486'

  • I was thinking this is useful for the times you use a LiveCD to recover an installation and for some reason the LiveCD become /dev/sda1, and the internal HD is assigned /dev/sdbX...except when you re-boot and it re-verts to the re-verse. Assign a UUID and be done with it.
    – Nodak
    Feb 5 '15 at 10:16
  • No no no .. You don't understand me. I don't asking if I can set the /boot partition by UUID (I did... piece of cake!). I'm asking how INSTALL GRUB on a disk using the disk drive UUID ... on other words ... I could do "grub-install /dev/disk/by-uuid/...." ?
    – Zardoz89
    Feb 5 '15 at 10:45
  • Oops, sorry. Then I'll echo Michael Kjörling, above...did you try it? The worst that can happen is you would learn something.
    – Nodak
    Feb 5 '15 at 10:55

No, you cannot grub-install /dev/disk/by-uuid/foo. This is not saying it is impossible, one might concoct a method, but it is impractical at the least.

UUIDs (universally unique identifier) are practically unique identifiers for partitions, and not the device itself. That is partitions have a UUID, but the location of the MBR that grub-install addresses does not have a UUID.

If you generate a UUID for the device (e.g.,uuidgen /dev/sdb) you then encounter a device.map problem within GRUB. grub-mkdevicemap fails to rectify the problem automagically.

If you grub-install /dev/disk/by-uuid/de305d54-75b4-431b-adb2-eb6b9e546013, for example, you will receive errors like

grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning:  Embedding is not possible.   GRUB can only be installed in this setup  by using blocklists. <blah, blah, blah>

...and so it goes.

More info can be found https://unix.stackexchange.com/questions/174206/warning-file-system-ext2-doesnt-support-embedding-but-my-system-isnt-emb

This was a fun experiment. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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