[SOLVED] Need help chainloading grub to my SD card
Linux - Laptop and NetbookHaving a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
But they don't seem to work. Here's the lowdown:
Hardware is an older Dell laptop. It has an SD card slot but doesn't support booting from SD. I've been told grub can chainload another bootloader on another drive. What I want to do is have it chainload the bootloader on my SD card.
Software is Ubuntu 10.10. For testing purposes I have loaded the same version on both the hard drive and SD card, so they use the same kernel.
My hard drive is sda and is partitioned as follows:
sda1 Windows
sda2 NTFS partition for sharing files between OS
sda3 ext3 /boot
sda5 LVM volume containing 4 smaller volumes, one each for / /var /swap /home
SD card shows as sdc when plugged into a USB SD reader and /media/mmc(long string of numbers) when in the internal slot.
sdc1 ext3 /boot
sdc5 ext3 /
I have downgraded grub2 to grub legacy since there is more documentation and it is easier to understand. Grub legacy is loaded on MBR of both sda and sdc. I edited the menu.lst on sda to create an entry to point to the UUID of sdc. I just copied the entry from the menu.lst on sdc. Since the versions are the same they use the same vmlinuz and initrd files already found in sda1.
I added the following lines to my initramfs-tools/modules file on sda: mmc_core, mmc_block, sdhc, sdhc_pci then rebuilt the initrd. lsmod shows the modules as loaded on boot. Everything boots fine when the SD is plugged into the USB SD reader. I can boot from grub on sdc or chainload it into sdc from sda. Both boot into the SD card when its in the USB dongle. When its in the internal SD card slot, neither boots and I get Error 15 file not found.
I've tried specifying the full path to the kernel in menu.lst, ie (hd0,2)/vmlinuz.x.y.z.img The idea being if I load the kernel from sda3 (hd0,2) it can load the rest of the files from the sd card at that point, but it doesn't happen.
My research so far has suggested Error 15 relates to a missing stage2 grub loader. The instructions I followed said the only files I needed to copy from sdc to sda were the initrd and vmlinuz but then suggested to be on the safe side to copy all of /boot. I did not do this because I didn't want to overwrite my existing stage1 and stage2 files which would make my sda unbootable. Is there a way to have 2 sets of these? Is there something else I'm overlooking?
That link looked promising initially, but after having tried to follow the author's steps, I've gotten bogged down again. The problem is that the instructions the author gives are for Arch linux, and I'm not able to translate them into the steps for Ubuntu.
He's also being rather vague about exactly what he's doing, ie "I chrooted into my system according to this wiki link" Did he only chroot into the sd card or did he follow other steps on the wiki? And a fairly critical piece of it seems to be this mkinitcpio which I gather is exclusive to Arch Linux, so how that applies to initramfs in Ubuntu I don't know.
I followed all the links referenced in the thread and in one of them 2 people discussed installing Ubuntu on an SD card by mapping / to the sd card and /boot to a usb drive. I figured that was worth a try, so I reinstalled Ubuntu and mapped / to the sd card and /boot to my hard drive sda3. That didn't work out well and the new grub2 didn't want to play nicely with the exiting grub on sda3, so I ended up having to restore /boot from backup. I'm going to try installing /boot onto a usb drive to see if that works but even if it does I'm not sure how to apply that to my current situation.
If you have an sdhc or a sdhc extreme card and this is an older internal reader it will not read the card. I have a 5yr old dell that will not read the newer cards. I did like you are doing and bought an external reader. I bought a new internal for my desktop, but you have to be careful because a lot of them are still the older ones.
@Larry Webb That is something to watch out for, but I checked the specs before I laid down money for the sdhc to make sure it would be supported and have no problems reading or writing to sdhc in windows or linux.
@aus9 I reinstalled ubuntu on the sd card using the usb dongle, during the install mounting /boot on a spare USB drive I had laying around. I added the sdhc modules to initramfs-tools/modules and used update-initramfs to update the kernel with sdhc support. At that point I was able to take the sd card out of the dongle and put it in the internal slot, and boot from the USB into root filesystem on the sd card in the internal sd slot. This is making me hopeful I may be able to figure a way to make this work. Now I just need to figure out how to make it boot from the hard drive instead of the USB without hosing my existing installs.
I think the original problem with that was trying to install grub2 onto sda3 which already has grub, which hosed both enough I could boot into neither. But the distro I want to live on the sd card is based on Ubuntu 7 so it uses the old grub by default so the mixing grub thing won't be a problem. However, won't installing grub onto a partition that already contains grub still end up overwriting files I need to boot into my existing hard drive based Ubuntu install? During the install on the sd card, I told it to mount sda3 as /boot but without formatting it to preserve the existing files but it overwrote anyway. Is there a way to have it mount sda3 as /boot in parallel without hosing the existing boot files? I would like to have a unified boot loader menu with all my OS options on it and pick to boot from the hard drive or sd card.
Last edited by shadowbox12; 03-20-2011 at 01:12 PM.
@aus9 I wasn't referring to having 2 /boot partitions, but having 2 sets of boot files, ie vmlinuz, initrd, stage1, stage2, etc on the same /boot partition. Maybe that's impossible, I don't know, I'm still fairly new to this. I'm just trying to wrap my head around how to chainload from grub on one drive to grub on another drive.
It seems to work if I have a /boot for the sd card on my usb stick and another /boot for my hard drive on the hard drive. Then I can boot from one or the other. The problem is getting all my boot options on a single menu.lst with some pointing to the local hard drive and some pointing to the sd card.
@Larry Webb I'm not sure I follow you. You mean sda1 vs sda3? Why does this make a difference? I have grub installed on the MBR of sda and /boot on sda3. How does the partition number apply to whether I can chainload to the sd card?
What the problem is that which mbr will be read first, h/d or flash/usb. You can install all of grub files in one partition then chainload that partition and it will not care which grub boots it if that is what you are referring to. If using grub2 you will probably have to use the -force option. I am like aus9 and not sure I understand what you want to do.
Is this a 'live media' or a distro install on your sd card? If you have ubuntu 10.10 on h/d how do you use grub legacy to boot it - chainload?
Last edited by Larry Webb; 03-29-2011 at 09:18 PM.
Can you have multiple kernels and initrds under the same folder /boot.......YES
2) The question on why you need to have a /boot folder on each DEVICE relates to which device is detected as the bootable device
eg bios jumps to device 1 (according to its order) finds the balance of its booting files and maybe.....chainloads to a different device
------the different device would normally need its own /boot folder
eg2...bios jumps looking for device1 and does not find it so jumps to device2.
device 2 can have a chainload entry to boot device 1
3) But the question is still limited by the bios detected the actual device
Can you have multiple kernels and initrds under the same folder /boot.......YES
Right but it takes more than vmlinuz and initrd to boot, if I understand this correctly. Grub also requires a stage1, a stage2, and sometimes a stage1.5. Since these files use default names and paths that means I can't have more than one copy in the same /boot. If I could have one file in /boot/grub/stage1 and another in /boot/grub_alt/stage1 that might work, but I don't know how to do that or whether it is possible.
FINALLY got an answer to this after going back and trying again. Updating this thread with the solution in case someone else finds this useful or I need to do it again and forgot how.
First thing is I updated to grub2. I just got tired of beating my head against the wall of grub. grub2 located the install on the sd card and added an entry to my grub.cfg, however this would not boot. It also made an entry for the copies of the SD installed kernel I made to my hard drive /boot partition. The idea being I could load the kernel and ramfs from hard disk and then point root to the sd card. Kernel loaded fine, problem was it couldn't find the sd card either by mount point /dev/mmcblk01 or UUID.
Then I realized I must be missing the correct sdhc modules and dug around for a while until I found the correct modules. Turns out the sdhc module names have changed between ubuntu versions. Now I had the correct names booting is no longer a problem. Modules are: sdhci, sdhci-pci, sdhci-platform, mmc_block, and cb710-mmc. modprobe -l *sdhc* *mmc* should help you find the correct modules on your distro.
For reference here is my modified grub.cfg. I created a custom script to make sure my menu entries don't disappear next time I update the kernel.
### BEGIN /etc/grub.d/55_backtrack ###
menuentry 'Backtrack 5 R1 Ubuntu 2.6.39.4' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd1,msdos3)'
search --no-floppy --fs-uuid --set a644e005-2450-4ae1-92d9-50cc69dc6d2a
linux /vmlinuz-2.6.39.4 root=/dev/disk/by-uuid/81001b25-f2d5-40fa-902e-d479a0ca79c9 ro quiet splash
initrd /initrd.img-2.6.39.4
}
those modules you refer to....ideally if all booting files are on your card it might be smarter to have those modules added to your initrd. I think yours is not a olde style initrd but an intramfs?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.