Lost Password? No account yet? Sign up! Why bother?
  • Narrow screen resolution
  • Wide screen resolution
  • Auto width resolution
  • Increase font size
  • Decrease font size
  • Default font size

SmallNetBuilder - Small Network Help

  
Home arrow Tag Cloud
How To: Hacking the Linksys NSLU2 - Part 5- Moving to Unslung Print E-mail
Jim Buzbee   
October 07, 2004

Boot-time Alternatives

In order to understand how Unslung frees up the memory, we must understand the basic boot-time architecture of the NSLU2. As we touched on in my last article, the first code to run when the box is powered on is the RedBoot boot loader. Among other things, the boot loader is responsible for copying the Linux kernel and ram disk from flash into RAM.

When the copying is complete, control is handed over to the Linux kernel. The kernel starts up and mounts the RAMdisk as the root or base filesystem. It then starts up the initialization processes from within that root filesystem. The initialization processes mount the hard drive and/or the flash drive and then continue on to the web server, the network file servers, etc. At this point the box is running and ready for use.

All of the basic functionality of the NSLU2 is contained in the RAMdisk because the box is designed to boot even if there's no hard drive attached. That's a nice feature, but if you think about it, it can be very wasteful. You may have a world of free space on your 250 Gigabyte hard drive, but you're stuck trying to squeeze all desired executables, libraries, html files, etc into the filesystem on a tiny RAMdisk.

What if you could put all of the files on the disk drive instead of the RAM drive? Then you'd be able to allocate a much larger filesystem and in the process, free up the memory that was previously allocated to the RAM drive. It would also be nice if you could be backward compatible with the Linksys boot sequence. If the drive had the filesystem on it, you'd use it. If a disk was not plugged in or if the disk didn't have a filesystem on it, you'd use the filesystem on the RAMdisk just like before. This is the approach taken in the Unslung firmware. Now let's explore how it's done.

Pick your Filesystem

It's common practice to build a Linux kernel with a pre-specified indicator of which drive to use for the root filesystem. This can be done either in the kernel itself or it can be passed to the kernel from the boot loader. In the case of the NSLU2, Linksys hard-coded the kernel, specifying that the root filesystem was a RAMdisk . That's all Linksys ever intended to use. But like most things in Linux, there's a method to avoid the use of hard-coded variables such as the root filesystem designator.

Linux has the capability to make a run-time determination of where the root filesystem is located. This capability is commonly used where a single kernel is built to run on varying hardware platforms. For example, the same kernel image can boot on a system where the root can either be found on an IDE drive or a SCSI drive. Before Linux chooses where to find the root, it pokes around and determines what drivers to load and where to find the root. When Linux figures it out, the proper root is mounted and the boot continues normally. This is the feature used in Unslung.

The Unslung code for root detection is not part of the kernel proper. Instead it's found in a Linux feature called the initrd, or initial ram disk. The initrd is a special temporary ram disk designed to hold user-code that's executed before the root filesystem is mounted. The Unslung developers first put a dummy root designator in the kernel and then added code to the initrd to check the hard drives for the real root filesystem. If one of the attached drives has a root filesystem, Linux is told to use it rather than fall back to the RAMdisk. Once Linux decides to use the hard drive for the root filesystem, the 10 MegaByte RAMdisk is freed up, and the RAM falls back into the free pool for other uses.



Tags: BYOD, Hacking, How To, Linksys, NAS, NSLU2,

Related Articles:

How To: Hacking the Linksys NSLU2 - Part 4- Customizing the Flash
Hacking the Linksys NSLU2 Part VI - Installing a Media Server
How To: Hacking the Linksys NSLU2 - Part 2 - Adding NFS
How To:Hacking the Linksys NSLU2 - Part 3 - Adding an iTunes server
How To: Hacking the Linksys NSLU2 - Part 1
 

Most Read

 
 

Over At The Forums

Are Cat6 and Cat5e not perfectly compatible?
So, I was rearranging some of my network today (notably moving my router to a different room) and I noticed something very odd. When I...

Captive portal for security
I've read about this in the previous Bed & Breakfast thread. Our company wants to get wireless going on one of the floors. There is only personal...

D-Link DNS-323 Mysteries
Hello folks. I'm having issues with my Nas and looking for some thoughts. 1. The 323 gets recognised by Vista as a network device but...

Gigabit Network Help!
I have a gigabit NAS (D-link 323) that I have connected to a D-Link DGS-1005D gigabit switch. I then have my desktop connected to...

Synology DS-209+ review up!!
Looks real good. Now Netgear needs to play catchup and dump that old Infrant CPU for something more modern and powerful!! http://www.trustedreviews.com/networ...ion-DS-209-/p1

Slideshows

NETGEAR ReadyNAS Pro Western Digital ShareSpace QNAP TS-509 Pro D-Link DNS-343 4-Bay Network Storage Enclosure Thecus N3200 RAID 5 NAS D-Link DIR-628 RangeBooster N Dual Band Router More

Win This!

Enter to Win!

You could win a Trendnet TEW-633GR Wireless N Gigabit Router and two TEW-621PC 300Mbps Wireless N-Draft PC Cards

Learn How!

 

Ldr:0.00176405906677, Rct:0.00494909286499, Sky:0.00673699378967, Tlink:0.364785909653, TopPG:0.364873886108, GQV:0.365032911301 seconds to load.