"Installing non-distro Linux on USB key" or "Using syslinux to boot a jffs2"
I have a 2GB Apacer USB Flash Drive (i.e. sda) and for the last few days I've been trying install Linux onto it. I have already tried distros such as DSL, Feather and Puppy (on that specific key and it went ok), but they're all just so ... static, even on writeable USB drives. But I was looking for the real thing, not just some compressed derivatives of LiveCD's, and couldn't sleep because of it, too!
What I'd like to ask of you is - how do you manually install a Linux distribution onto that key so that at any time there will be a jffs partition residing somewhere on there without being on a FAT partition in a compressed form (such as knoppix)???? I'm talking something along the lines of FlashLinux, but I need one that'll use syslinux to boot(why? read on) and not GRUB.
My AmiBIOS recognizes my key as "USB RMD-FDD" and for some reason ("FDD") it ignores the key's MBR completely and just looks for the first valid FAT/FAT32 partition boot sector and executes that, and if none is found, it freezes with no output whatsoever. I'm not trying to make this a BIOS-bug-thing, what I mean to say is that I can't use GRUB(Ext2) as a bootloader (it froze on boot with non-distro FlashLinux). I want to use syslinux(FAT), since it worked fine with the usb distros.
My knowledge on this sofar..phew:
1.I need a FAT partition (sda1) for the syslinux bootloader (does LILO work under FAT???)
and a Linux partition with the actual root filesystem (the one I'm after:)
The Linux partition should be JFFS2 and not Ext2 because of the Flash memory properties, but the former needs a mtd block device to access it, which makes things complicated when handing control to the filesystem on it...
2.So I do the partitioning using fdisk, create the filesystems and mount them:
(I don't have Linux on my HDD, I only have different LiveCD's to use the linux prompt....)
modprobe blkmtd device=/dev/sda2 (*)
flash_eraseall -j /dev/mtd/0
mount -t jffs2 /dev/mtdblock/0 <somewhere>
mkfs -t msdos /dev/sda1
mount /dev/sda1 <somewhere>
3.Then I copy the files onto sda2, but I'm not sure which ones do I need to get the X11 up and running, possibly everything in "/"??? Is the root structure distribution specific?
4. (I would appreciate if you got me on the right track, as to what really happens here)
And for the boot partition (sda1), I know syslinux needs the kernel of my chosen distribution (reduced to 2-3MB, but I'm not sure how) and the ramdisk initrd-thing(1MB). If I researched correctly, at boot the minikernel is supposed to use the ramdisk utility to create a temporary filesytem and then load the actual jff2s filesystem and let it takecontrol.
I don't know how the syslinux is to figure out where the jffs2 is and that it needs mtdblk to mount it, where do I pass the parameters to it or to the kernel or linuxrc? I don't have to recompile the whole kernel to add the (*) lines, right? I mean, there's gotta be a way to pass it to those programs....
Please help me with this...I can't passively surf the web forever....:)))
Anything is appreciated...
syslinux itself doesn't need to figure out where the jff2s filesystem is. It will point to your kernel in the /boot partition on the USB drive, and the kernel will then resort to its initrd and such, which will take things from there.
I've never used syslinux, but I know with LILO and GRUB you need to specify a "root" partition for an entry. The "root" partition is where / is located, however you will also have to supply where the boot image (kernel) and initrd are located, which is the partition on the drive, and the full pathname. A *theoretical* example would be:
Hope that helps. :)
Alright.. syslinux has a "syslinux.cfg" file, just as grub has "grub.conf". I know that you specify the kernel and the inird items here, but that's as far as the tweaking goes.
APPEND root=/dev/sda2 ramdisk_size=100000 lang=us apm=power-off vga=normal initrd=initrd.gz nomce quiet
APPEND root=/dev/sda2 ramdisk_size=100000 lang=us apm=power-off vga=normal initrd=initrd.gz nomce quiet
So syslinux loads up the minikernel that's in the root directory of the first partition (FAT -the one the machine booted from), unpacks the initrd.gz (also on that FAT), which produces a temporary ramdisk filesystem and now what? How does the kernel then switch to the JFFS2 that succeeds the FAT? Or rather how does it know that there's even another partition with the desired filesystem? Do I have do "make" the minikernel myself from the 50MB versions online?
When I tried FlashLinux, the kernel (2.6.11-gentoo 2.4MB) managed to take over, but it failed to find the taget USB partition even though I set the root to "/dev/sda2". When I switched to the command line (while still using the minikernel and temp ramdisk), the MTD was not even available, so how is it supposed to access or mount that JFF2 without it?
Okay, given that I'm no embedded linux coding expert whatsoever, IS IT EVEN POSSIBLE TO HAVE A USB LINUX THAT WOULD NOT WORK IN THE LIVECD FASHION?:confused:
If so, which distribution should I try if I need to boot from a FAT, but transfer the final control to the JFFS2 following it????:confused:
Spelling note: I thought "distro" was short for "embedded Live distribution", so when I said I needed "non-distro linux", I meant to have it work in the same fashion as if I put it on a hard drive as a solo OS, in other words the Full Install LiveUSB type http://en.wikipedia.org/wiki/Live_USB....
Don't worry about getting too much into the filesystem switching and all that jazz. The initrd.gz will have to be created after the distro (distribution) is installed on the USB thumbdrive. initrd.gz takes care of the "filesystem switching" and it will know which files to load, and all that good stuff.
Now, with all this discussion concerning "minikernels", I have no idea what they are. Any kernel I've ever had has never been any bigger than 2MB. Some versions of LILO won't let you use large kernels. So, when you go to compile your own kernel, it's quite simple (just make sure you have the kernel sources installed):
"make menuconfig" brings up a menu-based kernel tweaker so you can fine-tune your kernel and all its modules (Key Note: If you don't know what it is LEAVE IT AS IS - if it's not selected, don't select it; if it is select, leave it selected).
"make bzImage" makes a very small kernel image, and when the compiling process has finished, the resulting kernel is located at /usr/src/linux/arch/i386/boot/bzImage.
"make modules" and "make modules_install" compile and install all of the options in the menuconfig that were set to "<M>". (Note: It is widely preferred that you don't hard-compile all of the options. Some you can only hard-compile in to the kernel, which is fine, but if the option to leave it as a module is available, leave it as a module).
I think there are rules governing the filing system in a memory stick and not-fat filing system is not universally supported. I haven't worked with with the JFFS2 filing system but even standard Ext2/3 filing systems may have difficulties to Linux if they are in a flash drive.
I am pretty sure DSL and Puppy work fine with memory stick as I have installed them before. The way Puppy did it may be of interest to you. In a standard installation to an internal hard disk Puppy uses Grub and the partition can be formatted to Ext2/3. However for a memory stick Puppy changes the boot loader to syslinux and requires only one fat partition in the device.
I know for a fact Grub has a difficulty in recognising a flash drive because it can't see a USB disk. If a Linux recognises a flash drive it does so only with the assistance of the kernel. Boot loader like Lilo and Grub on booting up a Linux have no access to the kernel initially. Thus users need to tweak the booting process.
Thanks, now I'm staring to get the point. Now I know that the "vmlinuz" name is a convention that can refer to any distribution, and not a separate distribution (don't laugh):)
So what you say is that after compiling the 2M kernel, it has no "embedded" situation-specific parameters, and that the tweaking is done is the "APPEND" section of the .cfg file (syslinux.cfg, grub.conf,lilo.conf) and in the initrd.gz file, right?
In that case how do I create my initrd.gz, it's a compressed ram-disk temp filesystem, right? Is there some kind of "make" command to compile this one as well?
If I install an additional application on this system, I want the /lib /usr/bin or /usr/share/apps to be reflected on the REAL filesystem (in my case the JFFS2, but I can substitute it for Ext2, if it proves too much a pain in the ass), and not just on the ramdisk filesystem that's erased on reboot not-saving all the chamges!!! This is the main reason why I even bother going through this "filesystem jazz":) I can't go with DSL or Feather Linux!
Update: I managed to boot the "FlashLinux" kernel and initrd.gz with syslinux. It's clear that the control is successfully passed to the kernel and the ram-disk is ok as well, but then I get:
sda .... (is recognized as USB)
VFS: Cannot open root device <NULL> or unknown -block(3,6)
Kernel panic - VFS: Unable to mount root fs...
APPEND "root=/dev/sda2 rootfstype=jffs2 devfs=mount nomce quiet initrd=initrd.gz"
Do you think it has to do with JFFS2 support that may not be included in the 2M kernel?
Have you taken a look at knopperdisk? I started pulling it apart (I am a technician, not a programmer :)) and found that syslinx works in this manner, first it loads your kernel, then it loads the initrd. Basically your initrd is a gzipped filesystem that contains a handful of directories, and a main executable script (typically called initrc). The script then runs and makes/chroots into your working filesystem. Mainly what I can tell you is that you should grab a copy of knopperdisk and extract the initrd file then change the initrd to initrd.gz "mv initrd initrd.gz" then "gunzip initrd.gz", do a "mkdir /mnt/initrd", next "mount -o loop initrd /mnt/initrd". Once there you can poke around inside the initrd environment. If you make changes do a "cd /" then "umount /mnt/initrd" then "cd path.to.initrd.file" then "gzip initrd" then "mv initrd.gz initrd", and finally place it back on the thumbdrive. I know its alot, but I am sure its the solution your looking for.
As I am still learning about this myself, I can only provide limited help, but if you need some help email me or post to this thread, and I will try to give you the answer :)
|All times are GMT -5. The time now is 05:56 AM.|