Well that was annoying.. I had a rather large post ready to go, and my machine dutifully crashed and I lost what I wrote.
So here's take two.
A video of the entire bootstrap process probably would not be of much use.. it's effectively about ten commands, and lots of waiting for things to happen! So a very boring video it would make, indeed.
That said, I'm going to redo the process now, and type it up in a more comprehendable manner than the original post, as this'll get pushed to the Pandora Wiki as well.
I'll also hopefully try and cover booting Debian from SD card.. depending on if I manage to get it to work on the first few tries!
Part One - Setting Up
I'm going to do this entirely on the Pandora for the most part.
Everyone that wants to do this is likely to have a Pandora, but they may not have access to a Linux PC for example. Granted, the PC is going to be many times faster at performing the initial bootstrap, but a lot of the configuration has to be done on the Pandora anyway.
We'd also have needed to do a partial bootstrap on the PC, and transfer it over to the Pandora in order for it to work, and that's a pain in the backside to do, so we shall skip this altogether and perform everything on the Pandora.
This however, presents a couple of caveats:
i. We need to sacrifice a (possibly) large SD card.
ii. We also need to install a small application to the NAND.
If you're unhappy with these, stop now!
Otherwise, continue on...
To keep us all on the same path, put your sacrificial SD card into Slot 1 - this is the right slot, next to the volume wheel.
It needs to be at least 1GB, but if you're going to be running Debian directly from it; the bigger, the better.
Now open up Terminal from the menu.
We'll be using Terminal a lot, so in order to keep us sane, I'll use the following stylings.
Commands you should run will be in bold, like this Additional information about the commands will be formatted like this, where keywords from the command will be in bold to help identify bits and pieces.
I'll try to keep commands on a new line as well, so it's easier to follow.
Right, now we need to re-partition our card, as it's likely formatted to FAT32, and we need it as ext2 at least.
sudo cfdisk /dev/mmcblk1 You'll probably get prompted for your password, and given the usual warning about using commands as root. Either way, what we're doing is launching cfdisk to repartition our Slot 1 card; which again is the right slot next to the volume wheel.
This tool is relatively straight forward to use.
You'll want to highlight [ Delete ] via using the dpad, and wipe out all the partitions on the card - probably just the one W95 LBA partition, or FAT32 - by pressing Enter.
Next, we shall create a [ New ] partition. If we just want to use the whole card ( which by default, we do ) just hit return. If however, you want a swap partition for whatever reason, you'll need to cut this number down a bit ( say by 512 ) to fit it on.
If you've created a Swap Parition, you'll need to change the type, so highlight the swap partition using the dpad, and select [ Type ] from the commands. You'll get a huge list of partition types, but you can ignore them all, as swap is what it picks by default.
Once you've finished gutting your SD card, highlight [ Write ] and press Enter. You'll need to actually type
yes in order to proceed, but don't just hit enter if you only see
y, you still need to type the rest of the
es in.
Finally, highlight [ Quit ] and hit Enter.
We now need to format it, which can be done as follows:
sudo mke2fs /dev/mmcblk1p1 We're making an Ext2 filesystem on Partition 1 on the SD card in Slot 1.
And if you created swap, probably need to format too:
sudo mkswap /dev/mmcblk1p2 We're making Partition 2 on the SD card in Slot 1 be registered as Swap space, which we can then activate via sudo swapon /dev/mmcblk1p2 when we need it.
If you get an error about the partition being mounted:
sudo umount /dev/mmcblk1p1 should fix it, then try again.
If you get an error about it not recognising the partition, eject and reinsert the card to refresh it's mount list and try again - though it'll likely have tried to automount the partition for you, and you'll need to do the above umount command!
That's our SD card setup.
Part Two - Bootstrap Fun
Now we need to get a bootstrap of Debian up and running on our newly created space.
To do this, we'll use cdebootstrap.. and this is the one small application we need to install.
Grab it from here: http://packages.debian.org/sid/cdebootstrap-static and select the armel package.
Download it to /tmp preferably, but your home folder will do, or anywhere you like. For now, I shall assume you downloaded it to /tmp
Let's get back to the Terminal.
cd /tmp Again, if you downloaded elsewhere, change to that directory instead.
ar xv cdebootstrap*.deb We're using the archive tool to extract with verbosity our cdebootstrap package.
sudo tar -zxvf data.tar.gz -C / Now we're using tar to extract, with gzip support, again with verbosity, the file data.tar.gz, changing the Current directory to / so that it extracts systemwide on our NAND. We're running this command sudo so we have write permissions.
Now we just run cdebootstrap-static with a few parameters, and wait.
cdebootstrap-static --allow-unauthenticated -f minimal lenny /media/mmcblk1p1 What we're doing here, is we're allowing "unauthenticated" packages to be installed. As we don't, or probably don't, have the gnupg keychain stuff configured, all packaged will be "unauthenticated" regardless of whether they are or not. We're telling it we also want a minimal install of the lenny release, and to install to where we have the mount point of Partition 1 of the SD card in Slot 1. We could've used sid, sarge, potato, squeeze, etc.. in place of lenny, or chosen a standard install. Curiously, we also could've specified an Ubuntu release - perhaps that's something to look into another time?
[edit]
Annoyingly, after just getting Debian booted via SD card, it seems you'd actually be better off grabbing
sid here, instead of
lenny if you want your X server to work -
lenny doesn't have the omapfb driver available.
So keep this in mind.. if you want Debian to boot from SD, you'll want to grab
sid here, rather than
lenny!
[/edit]
Part Three - Debian in an Extend
Technically, once the bootstrap finishes, you're done.
You could just
sudo chroot /media/mmcblk1p1 and you'd be in Debian and can do as you please ( or continue down to Part Four for some tweaks, or perhaps Part Five to boot from it. )
If however, your goal is to compress this into an Extend file to use with my Extend Utils suite, and have a completely customised version of Debian to start with, continue on.
Pushing this into an Extend file is incredibly easy.
At this point, if you've done the minimal install, you should have about 120MB of installed stuff. You may want to jump to Part Four, install some things and set stuff up before continuing here, or this might be all need - and you'll use the Overlay support of Extend Utils to create extensions to the minimal Debian install you now have.
Either way, you'll need to create the actual Extend file itself.
This is really easy, just takes some space and time.
Back to your Terminal. I'm going to assume you've got a FAT32 formatted SD card in Slot 0 - the one next to your power switch - and that it has a fair amount of space on it.
cd /media/mmcblk0p1
dd if=/dev/zero of=debian.extend bs=1MB count=2048 This command will take an age, and is also important to understand what it's doing. It's creating an Output File of debian.extend, populating it with zeros from /dev/zero - this makes it very compressable. We're using a Block Size of 1MB, and we're wanting the file to contain 2048 of them - essentially being around 2GB. Be aware that a 2GB SD card is not going to give you the whole 2GB and you'll like need to specify about 1700 at most. You can ofcourse change this to whatever size you like, as long as it's about 150MB to store your Debian system as it currently stands.
sudo mke2fs -F debian.extend We've seen this before, of sorts.. we're now Forcing mke2fs to turn our debian.extend file into an Ext2 formatted filesystem.
mkdir /tmp/debian.extend
sudo mount -o loop debian.extend /tmp/debian.extend We're mounting the debian.extend file as a loopback filesystem on our created folder in tmp.
sudo cp -R /media/mmcblk1p1/* /tmp/debian.extend Finally, we copy everything from our Debian filesystem over to our Extend file. The -R option ensures it recursively copies everything - ie: traverses the folder structure.
sudo umount /tmp/debian.extend
That's it
Your debian.extend file now contains your Debian install, so you can either wipe your Debian install SD card back to FAT32, or perhaps contine on with it to use for booting into Debian in Part Five.
Part Four - Configuration Tips and Tricks
You now have a Debian install somehow, be it in an Extend or on SD card. Let's add some stuff to bring it up from a minimal system, to a usable system.
First thing you'll want to do is ensure you've chrooted into the Debian install. So do so if you haven't already.
I shall assume you're continuing on with the Debian install on your SD card.
sudo chroot /media/mmcblk1p1
I'll now prepend Debian to all commands we'll perform in the Debian Chroot, and Angstrom to any commands to be done in an Angstrom Terminal.
Unless you're used to messing with apt, you'll probably want Synaptic - which is a graphical front end to apt. Apt being Debian's Package Manager - opkg being Angstrom's if you're wondering.
Debian:
apt-get install synaptic
This'll take up another 230MB as it installs a HUGE amount of stuff, but it should set you up for various things you might want to fiddle with, so it's all good.
Once that finishes ( and it does take a while ) you'll probably want to run it. However, as it's an X application, it needs access to Angstrom's X server, or access to it's own. Getting Debian's X server running shall be something we tackle next, but for now, we'll use Angstrom's X server.
You'll need to either open another Terminal, or go to File->Open Tab in your current Terminal. This'll be our Angstrom Terminal.
Angstrom:
xhost local:localhost We're telling our X server to accept all connections on localhost - our machine - as we're about to start programs it's not aware of - our Debian applications.
Angstrom:
sudo mount --rbind /tmp /media/mmcblk1p1/tmp We're doing a recursive bind of /tmp to our Debian's /tmp. This is so X apps in Debian can access our Angstrom's X authority files and such... as /tmp is in volatile space anyway, we should be fine here.
Debian:
synaptic You may also want to add & to detach it from the Terminal so we can launch other things from our Debian Terminal.
You can now go and install things till your heart's content, with a rather large 21509 packages at your disposal in the standard Lenny release. There's more in Sid, and there's even more if you add the contrib repositories.
I shall stop the guide here for the moment, and shall continue with getting Debian's X server up and running alongside Angstrom's X server, and getting Debian running from a bootable SD card later on ( IE: I shall start it in a few hours and see where it takes me! )
Hopefully this is clearer than the brain dump I did on the original post!
Part Five continues on here: http://www.gp32x.de/board/index.php?/topic/57097-debian-on-an-sd-card/