Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to boot Linux kernel version 3.2.0 from USB drive.

I formatted the USB drive with ext4 partition. I installed GRUB on it, and I copied two files, vmlinuz-3.2.0-29-generic and initrd.img-3.2.0-29-generic from my laptop's /boot folder into USB drive's boot folder.

Then, I mounted the USB drive to /mnt and ran grub-mkconfig -o /mnt/boot/grub/grub.cfg to make grub.cfg file in it.

Then, I tried to add my kernel details to grub.cfg file as follows :

menuentry "my kernel" --class gnu-linux --class gnu --class os
recordfail
    insmod gzio
    insmod part_msdos
    insmod ext4
set root='(hd0)'
echo "Loading my kernel"
linux    /boot/vmlinuz-3.2.0-29-generic root=UUID=db2687dc-8c42-485e-a152-ef821590b113 ro  quiet splash
    echo    'Loading initial ramdisk ...'
    initrd  /boot/initrd.img-3.2.0-29-generic

However, the GRUB list does not show my kernel but just lists the same OS lists when I boot GRUB from my laptop's hard disk. Is the kernel really on the (hd0)? How to add the kernel's entry in the GRUB menu of USB drive? Also, is this way correct to boot a kernel from USB drive? Does the initrd.img file, which is there in my /boot directory still valid when I copied the kernel to USB drive? If not, How to generate new initrd.imf file for the kernel on USB?

share|improve this question

migrated from stackoverflow.com Feb 13 '13 at 3:30

This question came from our site for professional and enthusiast programmers.

    
What you did, was make the grub config for your current install, so you just installed a boot loader on the USB key that would boot off the internal drive. if you try it with the internal drive disconnected, you should see your usb boot menu, and then failure to find hd0 –  Justin Feb 13 '13 at 3:51

1 Answer 1

I once had an issue with this.

It was because booting from my harddrive and adding the USB later, rather than booting with the USB in meant that the devices were enumerated differently.

Fixed it by manually assigning boot device order in BIOS.

share|improve this answer
    
I am booting from my USB drive..When I start laptop, I go to boot device selection menu and then select my 'Kingston DataTraveler' (USB drive) from the list and boot... –  Shaarad Dalvi Feb 12 '13 at 17:01
    
I guess it might depend on your laptop BIOS. The devices list (HDD0, USB) needs to be in the same order it was when you ran grub-mkconfig. What was happening to me was that when I booted linux to make my USB stick, I had '0) HDD0, 1) USB'. When I tried to boot off the USB key, the BIOS said '0) USB, 1) HDD0'. –  paul Feb 12 '13 at 17:09
    
Hmm. Mine might not be the answer you're looking for - I'm not sure this situation can arise when you are using UUIDs in your config. –  paul Feb 12 '13 at 17:10
    
so instead of (hd0) written in the grub.cfg, what should I write? Is it possible to set the root by UUID? if possible, then how? In the subsequent lines shown above, the UUID corrosponds to the USB drive only... –  Shaarad Dalvi Feb 12 '13 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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