Here is my grub.cfg:

menuentry 'Debian 6.0 on hard disk' {
    set  isofile="(hd0,6)/home/toinstall/debian.iso"
    loopback  loop  $isofile
    search --no-floppy --fs-uuid --set=root 8b29114c-4f89-4c96-b0c0-579ce58c7345
    linux  (hd0,6)/hd-media/vmlinuz  root=UUID=8b29114c-4f89-4$
    initrd (hd0,6)/hd-media/initrd.gz

It can run, it is ok. There are 3 hd0,6. Can I substitute partition number with uuid in the file?


Since my last answer was completely wrong, I did some reading on my own. And here is the solution you need: Run the following command on your terminal:

# blkid

This will output the UUIDs for each device on your system. For my system, the output looked something like:

/dev/sda1: LABEL="boot" UUID="aa84c5a8-6408-4952-b577-578f2a67af86" TYPE="ext2" 
/dev/sda2: LABEL="root" UUID="a430e0ef-fd35-432f-8b9a-75a49b89ad8a" TYPE="ext4" 
/dev/sda3: LABEL="swap" UUID="e388806a-dc27-4f4e-a136-3d1ff4e53962" TYPE="swap" 
/dev/sda4: UUID="088E027A8E026114" TYPE="ntfs" 
/dev/mspblk0p1: SEC_TYPE="msdos" TYPE="vfat" 

Next, open /etc/fstab in a text editor. Change the /dev/sdXY entries to UUID= and input he UUID's you got via the blkid command.

Now, I am assuming you are using the default grub2 config files. If you have manually edited them, I am sure you know what the edits are and how to make them again. Run

# update-grub

Make any customization changes you want to your grub.cfg

Also, in some cases, you may have to update your initramfs with:

# update-initramfs -u -k all
| improve this answer | |

Simply omit the (hd0,6) prefix. The search command locates the correct partition by UUID and sets the root directory to point there. Paths without a partition prefix are assumed to be relative to that root.

Also I'm not sure why you set up the loopback to the iso image since you don't bother actually using it after that.

| improve this answer | |

No. Your cannot substitute with the UUID in your grub.cfg file. Grub reads only via partition numbers.

| improve this answer | |
  • Wrong: grub understands UUIDs just fine. – psusi Aug 8 '12 at 14:52

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.