Mounting root partition by UUID (no initrd needed)
(I'm separating this from the grub2 stuff because it works with any
bootloader that allows you pass a boot parameter to your kernel.)
This turned out to be easier than I thought -- but be aware that your
kernel must have "EFI GUID partition table support" compiled in before
you start anything else. (See the File Systems/Partition Types menu.)
BTW, you don't need to have a newer computer with EFI support. An old
BIOS machine uses a GPT just fine as long as your kernel knows about it.
The only other tool you need is sys-apps/gdisk, which will convert your
traditional DOS partition table to GPT -- and back again if you want.
I strongly suggest that you practice on a USB thumb drive before you
risk your real partition table!
There is one small complication with thumb drives that you won't run
into with real hard drives: gdisk may complain that the thumb drive's
partition table overlaps a partition.
If you don't want to delete your thumb drive's partition you can use
gparted (or parted) to shrink the drive's partition to leave 3 megabytes
or so at the end of the drive. Again, you won't need to worry about
this if/when you work on a real hard drive.
# gdisk /dev/sdd (assuming your USB stick is sdd and newer than FAT16)
After reading the horrifying warnings you can type ? to see a list of
gdisk commands. If you know fdisk, most of the commands will be old
friends by now.
You want "recovery and transformation options (experts only)". You'll
soon be an expert, so worry not.
Next: "load MBR and build fresh GPT from it". You can ignore the next
horrifying warning because gdisk will give you yet another last chance
to quit without saving your disgusting changes.
When you're finally ready: "write table to disk and exit". Done!
Now unplug/replug your thumb drive to force the kernel to re-read its
shiny new GPT partition table.
If you see errors, you probably forgot step number one: build and boot
a kernel with CONFIG_EFI_PARTITION=y. Otherwise you should be able to
use the thumb drive as you always do.
I suggest that you use gdisk to convert the thumb drive's GPT back to
the traditional DOS/MBR partition table, just so you know you can do it
if you really need to. And then convert it back again to GPT so you can
try the next part of our experiment.
Now, the point of this whole exercise (IIRC) is to allow your kernel to
mount your root partition without knowing its name (/dev/sdxx).
You can now try it without risking your hard drive, thanks to the new
GPT on your thumb drive. (This will work only for kernels >=2.6.37!!!)
The secret is to use your bootloader (e.g.grub) to pass a kernel boot
parameter like this: root=PARTUUID=<your partition UUID>.
Ah, but exactly what *is* your partition UUID? This is important!
The only way I've discovered to find the correct UUID (out of the many
possible choices) is to use gdisk, which created the UUID in the first
Note: the UUID you need is *not* the one you see in /dev/disk/by-uuid.
This is indeed very stupid, and I'm hoping that someone will fix it.
# gdisk /dev/sdd (again assuming that your thumb drive is sdd)
Use the "i" command to display detailed info about the partition where
you plan to save a copy of your kernel. For example:
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Linux/Windows data)
Partition unique GUID: 6BAD4248-FC6D-4487-A255-A3B57504BE10
First sector: 16065 (at 7.8 MiB)
Last sector: 131106464 (at 62.5 GiB)
Partition size: 131090400 sectors (62.5 GiB)
Attribute flags: 0000000000000000
Partition name: Linux/Windows data
The one you need is the "unique GUID": 6BAD4248-FC6D-4487-A255-A3B57504BE10
(I wish I could tell you what the "GUID code" is for, but I have NFI.)
So, in this specific example, the kernel boot parameter I would use is:
Note that the "PARTUUID" keyword was introduced very recently in linux kernel
2.6.37, and it has nothing whatever to do with the "UUID" keyword used in the
many online tutorials on how to build an initrd!
The whole point of this exercise is to show you how to avoid the need for an
initrd in the first place.
I've run out of steam for today. Questions/corrections are welcome :)
|All times are GMT. The time now is 07:51 AM.|
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.