General Discussion General discussion on...anything!

Reply
 
Thread Tools Display Modes
  (#1) Old
seltaeb7 seltaeb7 is offline
Junior Member
 
Posts: 16
Join Date: Mar 2009
Location: USA
Default Boot from internal SD card slot [HOWTO] [WORKAROUND]!!! - 04-20-2009, 12:56 AM

Keywords: Dual boot, linux, windows, boot SD card, SD card reader, Bootable device, BIOS.

This is in response to the half-correct fact

Quote:
It is not possible to boot from the built-in SD card reader.
that I have seen so many times. I say half correct because it is technically impossible to do it as the reader is not seen as a bootable device by the BIOS but as I point out in the title, this is more of a workaround. And as matter of fact, if you drop the condition on the built-in card reader then you can use an external one and life becomes simpler... (meaningless perhaps??? :shock: )

Anyway, first "Honor a quien honor merece". In other words, I did not come up with this myself and I am not planning on taking credit for it. I was just elaborating on some of the details posted by Garie Renny here:

http://www.osnews.com/story/20743/Eeebu ... Aspire_One

************************************************** ************************************************** ****************
Terminology:
SSD = Solid State Drive. In other words, your internal Hard Drive.
HCSD = High Capacity SD.
MBR = Master Boot Record.
************************************************** ************************************************** ****************

Case one: Linux in the SSD and linux from the HCSD built-in card reader.
My choice: Dell mini 9, Ubuntu 8.04 Hardy in the SSD and Ubuntu 8.10 Intrepid in a HCSD card.

Howto: Fine, If i have to admit it I will... I am very lazy and I already wrote a howto. Check it out here:

booting-from-sd-card--t615.html

************************************************** ************************************************** ****************

Case two: Windows in the SSD and linux from the HCSD built-in card reader.
My choice: Acer AspireOne, Windows Xp in the SSD and Xubunutu Intrepid in a HCSD card.

The twist: Rather than installing grub to the MBR of the SSD I wanted to use the Windows XP bootloader. The (silly or rather dumb) excuse behind it is that windows users are more likely to get scared if they see grub menu when booting the machine. The real excuse: I grew tired of the windows boot loader messing up my grub setup every time I reinstalled windows.

HOWTO:

To make this compatible with (in principle) any SSD, I am going to assume that it has the following structure:

Full SSD
BIOS name in grub: (hd0)
Device name in Linux: /dev/sda

1st Primary partition on the SSD
BIOS name in grub: (hd0,0)
Device name in Linux: /dev/sda1
File system:
* Fat or ntfs (here is where windows is installed).

2nd Primary partition on the SSD
BIOS name in grub: (hd0,1)
Device name in Linux: /dev/sda2
File system:
* ext2 (This partition does not exist in the Acer, you can go ahead and use the unused file space left in the SSD (96Mb in my case, or you can resize the 1st partition and create a second tiny partition here. 50Mb should be enough).

Very good then, let us proceed with the outline:

1.- Using an external card reader, install linux to the HCSD card.
2.- Create a custom initrd that includes additional modules that make it possible for grub to 'see' the internal card reader.
3.- Copy the necessary files to the ext2 partion in the SSD. (In principle one only needs /boot/vmlinuz-x.y.z, /boot/initrd.img-.x.y.z, /boot/grub/menu.lst and the stageX files needed by grub from the installation on the SD card but I went ahead and copied the full /boot directory).
4.- Make the appropriate changes to menu.lst and install grub where it is needed (here you can just go ahead and install it in the MBR of the SSD, or you can copy the grub binary to your windows partition and use the windows boot loader).
5.- Set up the windows boot loader (again, this step is only needed if you don't want to install grub to the MBR of the SSD).


DISCLAIMER: This is a guide intended for people willing to experiment with their computers. I am not to be held responsible for any possible typos or errors in this guide and you should only attempt to follow these steps if you KNOW WHAT YOU ARE DOING. If some terminology used here is not at all familiar to you, or if you don't fully understand the specifics it is very likely that:
1) You will mess up your computer;
2) Your cat/dog will die from starvation; and
3) You will never be able to play the piano...

Ok, perhaps I am being obnoxious but you get the point.

Now let us proceed to the actual details:

STEP 1: Installation

* Crate a live USB image of your favorite linux distribution for instance using USB Creator or UNetbootin; or use a live CD together with an external CD drive with a USB-IDE/SATA adapter.

* With the card reader attached to your netbook, use the CD or USB flash drive to install linux into the SD card that you want to boot from. Feel free to set up your system in any way you want but for the purposes of this 'how to' I will assume that:

1) Your /dev/sda1 fat or ntsf windows partition will be mounted in /windows
2) Your /dev/sda2 ext2 partition will be mounted in /BOOT_SD_FILES
3) [optional] You will install grub to the MBR of the HCSD card. Depending on the amount of USB devices used when performing the installation this could be /dev/sdb, /dev/sdc or other. If you decide not to install grub, you will need to find a way to obtain the unique UUID assigned to the various partitions you are using.

* Make sure that your netbook boots from the card reader (you might need to mess around with your BIOS booting options).

* Obtain the UUID that was assigned to your /dev/sda2 ext2 partition and the one assigned to your linux installation. If you installed grub, go to /boot/grub, open up menu.lst and you should be able to locate them. WRITE THEM DOWN as you will need them later. If you did not install grub simply take a look at the file /etc/fstab or /etc/mtab and you should be able to get them.

STEP 2: Custom initrd.img file

* Using the external card reader boot in to your linux system and edit the file /etc/initramfs-tools/modules. Add the lines
Code:
mmc_core
mmc_block
sdhci
sdhci-pci
and save it (this is a system file and you will need root privileges to modify it).

* At the command line, as root type:
Code:
 $update-initramfs -u
This rewrites ( -u means updates and overwrites) the Linux initrd.img-x.y.z file in the /boot directory. The new initrd.img now has some extra modules preloaded so it can boot a SDHC device.

STEP 3: The /boot directory

* This is the easiest step if we decide to play safe and use all of the files in /boot. As root issue the command
Code:
$cp -R /boot /BOOT_SD_FILES
The -R switch stands for recursive. At the end you should have a copy of the /boot directory in your /dev/sda2 ext2 partition.

STEP 4: The menu.lst file and installation of grub

If you did install grub to the MBR of the HCSD card then you already have a menu.lst file in your ext2 partition. In case you do not have this file you need to create one. For ubuntu users this is rather simple ($update-grub) and if that doesn't work for you google a possible workaround.

Here is where the UUID's that I mentioned before will come in handy. I doubt this info is useful but in my case I have
something like this
/dev/sda1 UUID=9AC5-AECF mounted at /windows
/dev/sda2 UUID=93bec1a9-e5ca-4958-8212-b3e3dc7ff141 mounted at /BOOT_SD_FILES
/dev/sdb UUID=c1b2fc9b-bdb5-408d-9ae5-d3c822fbb72f monted at /

* Open the file /BOOT_SD_FILES/boot/grub/menu.lst and look for the line similar to
Code:
#groot=c1b2fc9b-bdb5-408d-9ae5-d3c822fbb72f
containing the UUID of your HCSD card and either replace it with the uuid corresponding to your /dev/sda2 or add another line with the new information and comment the old one. In my case it now looks like this
Code:
##groot=c1b2fc9b-bdb5-408d-9ae5-d3c822fbb72f
#groot=93bec1a9-e5ca-4958-8212-b3e3dc7ff141
Now look for the existent title, root, kernel and initrd lines and modify them accordingly (or add them if they do not exist)
Code:
    title       The title of your linux distro
    root        (hd0,1)
    kernel      /boot/vmlinuz-x.y.z  root=UUID=zzzzzzzz-zzzz-zzzz-zzzzzzzzzzzz  ro quiet splash
    initrd      /boot/initrd.img-x.y.z
    quiet
Save the file.

Here the title line is up to you, in my case:
title Xubuntu 8.10, kernel 2.6.27-7-generic (booting from the SD slot)

Here I am using root (hd0,1) as for this guide we are assuming that this is the BIOS device name of the ext2 partition of the SSD hard drive.
The x.y.z in vmlinuz and initrd.img are the numbers and characters that correspond to your kernel. In my case 2.6.27-7-generic.
And finally zzzzzzzz-zzzz-zzzz-zzzzzzzzzzzz is the UUID of your SD card that you obtained from step 1. Again in my case c1b2fc9b-bdb5-408d-9ae5-d3c822fbb72f.

OK. We are almost done. With the menu.lst file in order we can now proceed to install grub.

As root type in a terminal
Code:
$grub
and you should see a prompt that looks like this: grub>

Find the menu.lst that you want to use
Code:
 grub> find /boot/grub/menu.lst
The output will vary depending on whether or not your SD card is seen by the BIOS. But if everything went fine your output should include the line (hd0,1) which corresponds to the /dev/sda2 ext2 partition.

Change root to /dev/sda2
Code:
grub> root (hd0,1)
And finally install grub and exit
Code:
    grub> setup (hd0,1)
    grub> quit
Here some remarks are in order:
1) If you replace setup (hd0,1) by setup (hd0) you will install grub to the MBR of the SSD and in turn you will be (in principle) done with this 'how to', however at the time of this writing I I had not tested this method and if you are going to go for it you should be ready to further tweak the menu.lst settings so that you can boot into windows. In my case with grub installed in the MBR of my HCSD card I was not able to boot into windows (presumably because I was using an external card reader). I did not perform any additional tweaking to try to fix this though!
2) If you replace setup (hd0,1) by setup (hd0,0) you should now be unable to boot into windows. So don't do it .
3) The current line setup (hd0,1) sets up grub in a place where it is unaccessible for the windows boot loader and you might think that it is useless, however read on to see how we actually fix this situation.

STEP 5: The windows boot loader C:\BOOT.INI

Here we are going to deal with the highest potential of messing up your widows system so be prepared to be extra cautious.

* First obtain a copy of the grub binary that was installed at the beginning of the /dev/sda2 ext2 partition. As root issue the command.
Code:
dd if=/dev/sda2 of=/windows/grub.bin bs=512 count=1
This will place a copy of the grub binary in a place that is accessible by the windows boot loader, namely C:\grub.bin (again, I am assuming the your windows file system is mounted in the /windows directory)

* Second add an entry to the file windows file BOOT.INI for the execution of grub.bin.

IMPORTANT: Make a backup copy of this file before you attempt to modify it as it is an essential file for your windows system. Also, depending on whether your windows file system is fat or ntfs the file might be called BOOT.INI or boot.ini.

Using your favorite editor, as root open the file /windows/BOOT.INI and add the line to the end of the file
Code:
c:\grub.bin="My linux distro"
IMPORTANT: The end of lines need to be windows-end-of-lines rather than unix/linux ones. For instance if you opened the file with the vi editor you would see something like
Code:
Blah... blah.. blah^M
The ^M is the windows end of line and needs to be present in the line that you just added. In my case I simply duplicated (copied) the last line of the file and then replaced the characters in front of ^M with the appropriate code.

That's it (finally). If everything is ok you should now be able to boot into your linux system regardless of whether you are using an external card reader or any (if several present) of the internal ones.

Cheers,

P.S. As I said before I am a little lazy... I wanted to leave a thank you message for Garie Renny in his blog but apparently after 5 days you cannot post any more, so I gave up trying. But if you find this info useful thank him (that is if you can find his info). Although he didn't specifically elaborated on this method his idea is the one that should be acknowledged.


================================================== ==
Mini Dell 9. 2Gb Ram. 4Gb SSD.
Running: Ubuntu Hardy, Intrepid and Puppy Linux 4.12 retro.
================================================== ==
Reply With Quote
  (#2) Old
displacedtexan displacedtexan is offline
Junior Member
 
Posts: 3
Join Date: Aug 2009
Default 08-12-2009, 03:43 PM

Great topic! Thanks for the detailed how-to...

I am trying to do the same thing, but get dropped to a BusyBox shell after selecting Ubuntu from grub. Specifically I get:

Quote:
ALERT! /dev/disk/by-uuid/[uuid of my sd card] does not exist. Dropping to
shell!
Now here is the interesting thing... when I rent cat /proc/modules at the BusyBox shell, sdhci_pci, sdhci, and mmc_block are listed but mmc_core is NOT!

I have followed the above instructions, making sure that mmc_core is included in the /etc/initramfs-tools/modules, etc.

Any ideas how I can boot from my SD when in the SD card slot? It does work just fine when booted from my USB SD card reader.

Thanks!
Reply With Quote
Reply

« Hey Im new here! and i want my laptop to look like a mac | Gizmodo shows off 11" Dell Inspiron 11z! »
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Copyright © 2008-2016 MyDellMini.com.