Why initrd?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View

Can someone answer a question that has been bothering me for a long time

Why do usb sticks require the need for an initrd in order to boot linux?


We've slightly trimmed the long signature. Click to see the full one.
Re: Why initrd?
On March 14, 2009 14:59, in comp.os.linux.embedded, Jerry McBride

Quoted text here. Click to load it

I would imagine that the reason is that the distro /on/ the stick includes
the [v]fat driver as a module, rather than as a builtin. IMHO, that is
the /only/ reason to use initrd (if your kernel internally supports the
filesystem that your root fs is recorded in, you don't need initrd to

Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
We've slightly trimmed the long signature. Click to see the full one.
Re: Why initrd?

Quoted text here. Click to load it

Initrd is a quick way of hiding details of a file system.
Every file system like FAT, FAT32, EXT2, EXT3 would need a file system
driver in the kernel to access the hundreds of files while Linux is
booting. If instead it had to deal with opening a single file and having a
specially crafted file system inside it containing all the hundreds of
files Linux needs while booting, then the kernel won't have to deal with
all the issues of many different file systems and hundreds of files spewn
across that new file system and the file management to open all those files
in turn. Instead, if it has an initrd, then all it needs to do open the
single initrd file without managing it and it will always find all the
files it needs within it without searching for it all over the drive.
Initrd can be compressed - which makes it ideal for embedded systems.

Re: Why initrd?

Quoted text here. Click to load it

That makes good sense, 7. But why am I unable to get a usb stick to boot
without using an initrd?


We've slightly trimmed the long signature. Click to see the full one.
Re: Why initrd?
Quoted text here. Click to load it
I'd be interested in that as well as I'm just starting out in the world of
embedded linux. In theory, I believe that if you have all the filesystem
and other drivers that you need compiled into the kernel, you should'nt
need an initrd.

As an aside, is this an appropriate forum for me to be posting "newbie"



Re: Why initrd?
Quoted text here. Click to load it

Right - if you build a customized kernel with
all the necessary drivers built in, you may
be able to start without an initrd.

However, the kernel may grow so large that
the boot cannot load it anymore - this depends
on the bootstrap loader used.

Another reason for an initrd is that there may
be utilities that have to run before the main
file system can be used, An example is a LVM
volume as the root file system, it needs to
be started up.

Quoted text here. Click to load it

Yes - as long as they are not obviously:

  - a trolling attempt, or
  - homework.


Tauno Voipio
tauno voipio (at) iki fi

Re: Why initrd?

Quoted text here. Click to load it

You can.

I have an EEE and I boot 32Gb USB stick formatted as EXT2.
I have installed Ubuntu into it.

All the directories in initrd (about 500 files and directories) are now in
the root directory of the USB stick e.g. etc, bin, sbin, lib, usr and so

If you need more details, just post an additional request for the details.

Re: Why initrd?

Quoted text here. Click to load it

Here's that request for additional details. Thanks 7!

We've slightly trimmed the long signature. Click to see the full one.
Re: Why initrd?

Quoted text here. Click to load it

1. Get Ubuntu (http://www.ubuntu.com ) and make liveCD.
2. Boot up on liveCD and run a shell and then
     sudo -s
   to become root user and then enter gparted to run
   gparted software.
3. Put in a USB stick 8Gb or more in size, format the USB
   stick to EXT2 using gparted software.
4. Right click the EXT2 partition and select manage flags.
   Set the partition to bootable.
5. Now install Ubuntu on to the 8Gb stick
6. When it comes to partitioning, select the manual operation
   Point at the flash drive and type in / as the mount point
   for the root partition
7. At some stage it asks if you want to format it and also
   preserve the home partition. Preserve home partition
   and try not to reformat the the flash disk.
8. Just before install, the installer will tell you all the operations
   is about to perform. Make sure it doesn't reformat the ext2 partion
   (because it will format it to EXT3) - go back and redo step 7
   until it gives up trying to format the USB stick.
9. After installation, set the PC to boot from flash drive.

   At this point your Linux should boot from the flash drive.
   The 500+ files that were in initrd are now on the flash
   drive as separate files. Plus about 4Gb of other stuff
   which is why you need a minimum 8Gb flash disk to do this.

   (Old BIOSes don't like doing the boot from flash - get
    an Asus motherboard for about 50 pounds
    with Express Gate feature - that is bound
    to work very well with the bootable flash disk.)


Re: Why initrd?
Quoted text here. Click to load it

Excuse me for my ignorance, but why would that be undesirable?


Re: Why initrd?

Quoted text here. Click to load it

EXT3 uses a journal to back out of transactions. So if data write went
bad, it can back out - its good for data but bad for a USB stick and SDCard
because each memory location can be written to between 100k and 1M - after
that it begins to loose data. The journal is frequently written to.
Hence its bad for USB stick and SDCard to use EXT3 (or NTFS).
It will wear out your memory. SSDs on the other
hand cycle the sectors transparently so that wear effect is less visible.
USB Stick can use EXT2 OK (very fast) and FAT32 (slow).

[You can check out speed difference between EXT2 and FAT32 by
 installing Linux on a USB stick SDCard with initrd and
 extlinux boot loader for EXT2 and syslinux boot loader for FAT32.
 extlinux wins hands down. The syslinux method is described below.
 The extlinux method is similar - google for it.]

Converting distros to boot from SD Cards and USB flash drives

Got me self an EEE but the EEE has no optical drives (no CDROMs).
So I'm having to convert every install CD or liveCD into a
bootable SD card or USB flash drive to boot on the EEE.

Without being able to convert a distro into a bootable USB flash /SD Card,
that distro can't be easily loaded into netbook like EEE
and stand to miss out on users installing it into netbooks.

So I would recommend all distro mainters look at their netbook
boot strategy and offer something to boot their distros
from USB flash and SD cards or miss out on users installing it into

Having done a few conversions, a pattern emerges that works well for
most syslinux / isolinux based distros.

1. Put your SD card or USB flash drive into your desktop Linux PC and
   then open a console and type dmesg
   You should see some line indicating your flash drive as
   being picked up and allocated with a comment like sdc / sdc1 etc..
   Remember both names - the first is /dev/sdc which is your
   device name, and the second is /dev/sdc1 which is your partition name.
   (Don't get confused between drive /dev/sdc and partition /dev/sdc1
   or your drive could become scrambled eggs later on. Also remember
   it may be called sdg or sdh etc depending what you see when you
   plug in device and type dmesg)

2. Install gparted on your machine using synaptic.
   To run it you can type
     sudo gparted
   in a console window and select on the right side the drive name allocated
   in step 1. Right click on the bar that represents the partition
   and click on manage flags.
   Enable the boot flag and click OK. This makes the SD Card / USB
   stick bootable.

3. Identify that you have syslinux or isolinux in your liveCD by
   opening the .ISO file in archive manager and checking that it has
   isolinux or syslinux directory somewhere in the liveCD.

4. Extract all the files in the .ISO file to the
   root directory of the SD card or USB flash stick.

5. Go to the flash drive and locate the syslinux (or isolinux) directory.
   Copy its entire content to the root directory of the flash drive.
6. If you have a syslinux.cfg file in the root directory of the
   flash drive, then you are OK for step 6.
   Otherwise if you have a isolinux.cfg file, then rename it to syslinux.cfg

7. Get syslinux - this is a boot loader and menu system for FAT based
   file systems. Download the latest version from here...
   http://www.kernel.org/pub/linux/utils/boot/syslinux /
   Unzip it and go to the linux directory.
   Run the program there by typing this - (note this command is updating
   the partition /dev/sdc1)

   ./syslinux -s /dev/sdc1 

   This puts a new file into your SD card / USB flash disk

8. from the linux directory change to the mbr directory
   cd ../mbr
   and then run this - again note this time its updating the device by
   writing data to the first sector as opposed to the first partition.

   sudo cat mbr.bin > /dev/sdc

   This makes the card bootable and useable in an Asus EEE and many other
   PCs with SD card or USB flash disk boot facility.

A. You can skip steps 2 and 8 if you don't format your card again
   when you want to try out another distro.
B. Step 5 is messy but quick. You can figure out and copy just
   the files needed.
C. In step 6, editing the syslinux.cfg files can allow you to put
   more than 1 distro on the flash drive. But beware, many distros
   use default paths and names that can conflict.

This method tested and works for

1. Ubuntu
2. Slax
3. Knoppix
4. Puppy
5. DSL
6. GParted
7. gOS
8. Dynabolic
9. MoonOS

Does not work for DVD distros with files greater than 2Gb size inside
the .ISO file -  - need a different install method using grub bootloader
instead of syslinux (not covered here)

Does not work for .ISO files built with grub bootloader - need a different
install method with grub boot loader instead of syslinux.

The latest EEE1000 has fast enough graphics for translucent
3D desktops.

An easy way to do all this:

Install Ubuntu on EEE (compiz itself
appears to be installed by default in the default install),
then install compiz settings manager using Synaptic
which allows compiz to be fully 'exercised'.
And then do the following to get the 3D cube desktop

 Go to General > Display Settings > Lighting and turned it off
 Enable Desktop Cube and then Desktop Cube > Transparent Cube and set the
 two opacity  settings to 30%
 then Desktop Cube > Skydome and check the skydome check mark
 Enable Rotate Cube
 Enable Enhanced Zoom Desktop
 Right click the virtual workspaces panel and increase the number
 of colums to 8.

And hey presto - 100% 3D translucent desktop with 8 screens!!!!!!!!!!

 [Some shortcuts for the 3D screen
  ctrl + alt + left or right arrow to spin cube
  ctrl + alt + down arrow and then left or right arrow for a ring switcher
  super + E for yet another switcher
  super + mouse wheel scroll to zoom in and out of the 3D desktop.


Site Timeline