It's possible to boot from a memory stick / usb stick. If you have several drives attached to the NSLU2, see bootbydiskid, as otherwise the wrong device may be picked to be booted from.
Therefore: Minimise write/erase cycles!
How to do that:
My drive's LED flashes every now and then - how can I find out whether if it's being written to, and what's writing to it?
lsof (list open files) might be of use, but I don't know how to use it, since it only shows the current situation by default, and doesn't monitor things..!?
Minimum Size of Flash
Use at least 512MB.
How-to for Unslung
If you want a completely silent slug or, as in my case, you don't have a HDD yet and still want to have full functionality, you can use a memory stick as main drive. It is, alas, not so easy as clicking format in the web interface (at least, NOT with a 128MB stick as it is just too small, with 256MB it will work using the procedure on this page and for 512MB and larger it should just work). You'll have to do some things manually.
First, you'll have to make a correct partitioning manually. On a drive prepared by the slug the following partitions can be found:
On a standard slug drive, the swap partition is about 55MB (with 6.8beta this changed to 128MB it seems), the conf partition about 100MB (128MB in 6.8beta) and the data partition fills up the drive. When you'll try to format a memory stick with the web interface, it fails. This is because the standard partitioning doesn't fit on 128/256MB. If you have a stick that is at least 512MB, you can skip this guide.
(user comment): I have a 4GB stick, branded "integral ICE", which I just cannot get going on the slug. Formatting via the web interface fails within a few seconds, and "mount" can't see it, so neither can fdisk. Without another Linux machine to play with, I've given up.
Anyway, we'll have to prepare the stick ourselves. Just plug it into your Linux machine and fire up cfdisk (or, if you're really hardcore, fdisk). Now we have to decide the size of our own partitions. You can keep the swapspace as small as possible, because swapping on a memory stick is possible but shortens the life of the stick dramatically. So, you'll only have to choose the size of the conf and the data partition.
A few options are a conf partition which is only a couple of megabytes, big enough to hold the standard configuration files. You can put all your custom binaries on the data partition by symlinking /opt to a folder on the data partition instead of one on the conf partition. You can also decide you don't need a data partition at all and make the first partition as small as possible and the conf partition as big as possible. Or whatever, your call :).
So, make the three primary partitions (you can figure out how cfdisk works, don't you? If not, there's man cfdisk). Partition 1 and 2 are type 83, partition 3 is type 82 (Linux swap). Make partition 3 as small as possible.
If you don't have a Linux machine (or at least a machine bootable with Knoppix or the likes) you could do everything on your slug. First, you'll have to install a normal fdisk on the internal 8mb flash (I haven't tried it so I'm not completely sure if this fits. It should). This is best done with ipkg:
ipkg update ipkg install busybox
This busybox binary includes fdisk, but fdisk is not symlinked to it (for obvious reasons). To run it, use:
/opt/bin/busybox fdisk /dev/sda
Now, you can partition the stick on the slug itself. Google around if you don't know how to use fdisk.
This method doesn't work on V2.3R69 firmware, as you get an error
''Error: The ipkg command cannot currently be used because this system is running from its internal flash; it is not currently "unslung" to an external disk or flash device. Please complete the process of "unslinging" this system, or resolve the issues that did not permit it to boot from the external device before installing any ipkg packages or updates.''
However, given that fdisk and busybox appear to be built into the firmware image, maybe this isn't a problem.
Following is taken from the readme of uNSLUng 6.8beta: ***** If you do not choose to do the unslinging procedure described below, DO NOT install packages unless you are SURE you know what you are doing! If you do so and regret it all you need to do is reflash (putting it into reflash mode by a power cycle while pressing the little reset button).
Making the filesystems
Okay, some more preparation to be done: we'll have to put an ext3 filesystem on the first two partitions and a swap filesystem on the last one. Suppose your stick is called /dev/sda on your Linux machine, with /dev/sda1, /dev/sda2 and /dev/sda3 the three partitions, this needs to be done:
mke2fs -j /dev/sda1 mke2fs -j /dev/sda2 tune2fs -c 0 -i 0 /dev/sda1 tune2fs -c 0 -i 0 /dev/sda2 mkswap /dev/sda3
mke2fs is standard ext2 filesystem creation utility and the -j option makes a journal, ie. makes an ext3 filesystem (ext3 and ext2 are basically the same, except that ext3 has journalling). The tune2fs is used to make sure the slug doesn't automatically check the filesystems for errors every now and then, which only takes time and isn't necessary anymore since ext3 (journalling) imo. mkswap prepares the swapspace which we aren't going to use, but the slug still expects it to be there.
NOTE: This stage might not be needed at all. NSLU2 makes the filesystems when formatting (next stage). Moreover if tune2fs functionality is wanted it should be done after the NSLU2 has done it's formatting.
Faking the slug
NOTE: Unslung users should first be familiar with issues described in /WhichUSBPortforUnslung6 before choosing USB port 1, as described here.
Ok, plug the stick into USB port 1 and then boot up your slug. Now go to the web interface. You'll notice the slug detects the stick as 'Not formatted'. If you try to format the stick from within the webinterface, the slug is going to repartition it and fails. So, we'll have to stop it from repartitioning, but still let it copy the necessary configuration files.
Telnet or SSH into your slug as root. Now:
cd /sbin mv fdisk fdisk.old echo "#!/bin/sh" > fdisk chmod +x fdisk
You've renamed the standard slug fdisk binary (which is not the same as the standard Linux fdisk) and made a fake binary (a shell script in this case) which does nothing. Now go to the web interface again and format the "drive".
If all goes well, the stick will now appear as "Formatted" in the web interface and it should be mounted under /share/hdd/conf and /share/hdd/data. All there's left to do is fixing the original fdisk and unslinging (oh yeah, and stopping the swap from being used). So:
cd /sbin rm fdisk mv fdisk.old fdisk unsling disk1
To wrap things up you'll have to make sure the slug doesn't use the tiny swapspace on the stick. As the swap gets enabled in rc.bootbin, which is a Linksys binary, we cannot stop the slug from using the swap all together. What we can do however is turn the swap space off as soon as possible with a script in /unslung/rc.unslung. Type this (if you don't already have such a script, if you do, you probably know how to modify it anyway):
cat > /unslung/rc.unslung << EOF #!/bin/sh /sbin/swapoff /dev/sda3 return 1 EOF chmod +x /unslung/rc.unslung NOTE: On my unslung 5.5 I have to use /unslung/rc.unslung-start as filename in order to get this work. You can check if it works if you use cat /proc/meminfo there you shall see following lines if swap has been turned off at boot time . . SwapTotal?: 0 kB SwapFree?: 0 kB
This swap procedure above might be obsolete with the use of the /.ext3flash file explained in Ext3flash.
dustinemptyspace: NOW you have to ACTIVATE the swap somewhere else!
I've got random problems writing files on the shared drive and executing php scripts. They were due to lack of memory! So I higly suggest you to activate the swapping. The simplest method is to create an empty file on your shared HDD and use it as swap location for your NSLU2.
dd if=/dev/zero of=/path_to_swap/swapfile bs=1M count=256 mkswap /path_to_swap/swapfile swapon /path_to_swap/swapfile
Remember to write the last line in the
There seems to be an unsolved race condition if you optionaly want to run a USB harddrive as well.
If I reboot with the stick and the harddrive turned off - everything works as expected. But if I turn on the nslu2 with the harddrive turned on as well, it seems, that, in whatever port I have plugged the HD in it is faster (??!?!) on the bus and will be assigned /dev/sda and the stick only gets /dev/sdb - so my slug won't boot the correct device ... the memstick is /dev/sda if run alone ...
I have observed this running on openslug 2.7
Any suggestions ? see debian page, info is on the bottom.. the kernel needs to know which device to mount for / (root), which can be done by uuid or label ..
(I swapped the flash from Drive 1 to Drive 2, and the USB HDD to 1. This also enabled me to control user access to the hard drive which I was not able to do before. I hope this of help, though cannot say it will work for you)
view · edit · print · history · Last edited by dbh.
Based on work by ta, Prism, canth, Ken Pemberton, anonymous, me, Markus, emm_is, custk9, htjems, Michael K, tutenchamun, dustinemptyspace, Josef Fuchs, Bas Kok, Peter Baldwin, Anonymous, ka6sox, Peter Andersson, Koops, giel, and rwhitby.
Originally by giel.
Page last modified on February 06, 2009, at 10:00 PM