NSLU2-Linux
view · edit · print · history

HowTo.UseAMemoryStickAsMainDrive History

Hide minor edits - Show changes to markup

February 06, 2009, at 10:00 PM by dbh -- add cautionary note regarding selection of port
Added lines 122-123:
NOTE: Unslung users should first be familiar with issues described in /WhichUSBPortforUnslung6 before choosing USB port 1, as described here.
September 21, 2008, at 09:09 AM by ta --
Changed lines 184-186 from:

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 ..

to:

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)

April 27, 2008, at 09:33 AM by Prism --
Changed lines 94-95 from:
to:

However, given that fdisk and busybox appear to be built into the firmware image, maybe this isn't a problem.

April 27, 2008, at 08:56 AM by Prism -- formatting correction
Deleted line 86:
Changed lines 88-96 from:

''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.''

to:
  ''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.''
April 27, 2008, at 08:54 AM by Prism -- correcting formatting error
Changed lines 92-94 from:

"unslung" to an external disk or flash device.

Please complete the process of "unslinging" this system, or

to:

"unslung" to an external disk or flash device.''

''Please complete the process of "unslinging" this system, or

April 27, 2008, at 08:51 AM by Prism -- ipkg on non-unslung system disabled.
Added lines 73-74:
Added lines 86-97:

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.''

January 20, 2008, at 08:10 PM by canth -- last line: +or label.
Changed line 172 from:

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..

to:

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 ..

November 28, 2007, at 10:48 PM by Ken Pemberton --
Changed lines 63-64 from:

(KenP? comments): 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.

to:
(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.
November 28, 2007, at 10:47 PM by Ken Pemberton -- Commentary on problems with a specific stick.
Added lines 63-64:

(KenP? comments): 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.

August 28, 2007, at 07:10 PM by anonymous -- what about giving this a more generic title?
Changed lines 4-6 from:

Silent Less power

to:
  • Silent
  • Less power
Changed lines 8-11 from:

Limited number of write/erase cycles - bad for swap, not so good for logging

Debian

to:
  • Limited number of write/erase cycles

Therefore: Minimise write/erase cycles!

How to do that:

  1. Don't update time info on files / dirs - mount with noatime
  2. Use swap as rarely as possible
    1. Don't use all the RAM
      1. throw out un-needed processes
      2. use programs with a smaller memory-footprint
    2. minimize swap-usage - "swappiness"
  3. Minimize logging
    1. disable unneeded logging
    2. prevent logs to be written for single new lines
    3. put the rest on ram-disk and write to disk lateron

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

Debian

Changed lines 37-41 from:

SlugOS

Unslung

to:

SlugOS

Unslung

How-to for Unslung

August 28, 2007, at 08:45 AM by anonymous --
Added lines 1-18:

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.

Pros: Silent Less power

Cons: Limited number of write/erase cycles - bad for swap, not so good for logging

Debian

Use at least 512MB.

SlugOS

Unslung

Changed lines 21-22 from:

Requirements

to:

Requirements

Changed lines 28-29 from:

Partitioning

to:

Partitioning

Changed lines 44-45 from:

Alternative

to:

Alternative

Changed lines 57-58 from:

WARNING

to:

WARNING

Changed lines 66-67 from:

Making the filesystems

to:

Making the filesystems

Changed lines 81-82 from:

Faking the slug

to:

Faking the slug

Changed lines 94-95 from:

Finishing up

to:

Finishing up

Changed lines 137-138 from:

Problems:

to:

Problems:

July 23, 2007, at 08:43 AM by me -- tip
Changed line 127 from:

Any suggestions ? test

to:

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..

July 23, 2007, at 08:41 AM by me -- editing doesnt work
Changed line 127 from:

Any suggestions ?

to:

Any suggestions ? test

October 08, 2006, at 04:59 PM by Markus --
August 20, 2006, at 06:54 PM by emm_is --
Changed lines 45-47 from:
             doing!  "Bricking" your NSLU2 by not unslinging and then running ipkg
             is not just a possibility, it is a certainty.
to:
             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).
August 19, 2006, at 06:57 PM by custk9 -- Added warning about ipkg update
Added lines 39-47:

WARNING

      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!  "Bricking" your NSLU2 by not unslinging and then running ipkg
             is not just a possibility, it is a certainty.
August 04, 2006, at 01:31 PM by htjems -- Added info for 256MB USB pen with 6.8beta
Changed lines 1-2 from:

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 or more it should just work). You'll have to do some things manually.

to:

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.

Changed line 6 from:
  • A memory stick
to:
  • A memory stick (minimum 256MB for practical purposes)
Changed lines 18-19 from:

On a standard slug drive, the swap partition is about 55MB, the conf partition about 100MB 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 128MB. If you have a stick that is at least 256MB, you can skip this guide.

to:

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.

Changed lines 96-97 from:
to:

This swap procedure above might be obsolete with the use of the /.ext3flash file explained in Ext3flash.

June 18, 2006, at 03:58 PM by Michael K -- Added type of partition (primary)
Changed lines 24-25 from:

So, make the three 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.

to:

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.

March 28, 2006, at 07:28 PM by tutenchamun --
Added lines 108-118:

Problems:

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 ?

February 27, 2006, at 03:52 PM by dustinemptyspace -- activate the swap!!!!
Changed lines 94-107 from:

There!

to:

There!

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 /unslung/rc.local file, in order to reactivate the swap file after the reboot.

August 09, 2005, at 05:03 PM by Josef Fuchs -- How to check if swap is disabled
Changed lines 86-93 from:
to:
       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 
August 09, 2005, at 04:56 PM by Josef Fuchs -- Incorrect filename for unslung 5.5 (/unslung/rc.unslung-start)
Added lines 85-86:
 NOTE: On my unslung 5.5 I have to use  /unslung/rc.unslung-start  as filename in order to get this work.  
August 07, 2005, at 04:10 PM by Bas Kok -- the usb stick did not hotplug for me, needed a reboot
Changed lines 56-57 from:

Ok, time to boot up your slug if it wasn't already on. Plug the stick into USB port one and 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.

to:

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.

August 06, 2005, at 09:04 PM by Peter Baldwin --
Changed lines 74-75 from:
 unsling hdd
to:
 unsling disk1
July 23, 2005, at 02:00 PM by Anonymous -- echo -> cat
Changed lines 78-80 from:
 echo "#!/bin/sh
 /sbin/swapoff /dev/sda3 
 return 1" > /unslung/rc.unslung
to:
 cat > /unslung/rc.unslung << EOF
 #!/bin/sh
 /sbin/swapoff /dev/sda3
 return 1
 EOF
May 21, 2005, at 01:57 AM by ka6sox --
Changed lines 1-2 from:

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 or more it should just work). You'll have to do some things manually.

to:

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 or more it should just work). You'll have to do some things manually.

May 21, 2005, at 01:53 AM by ka6sox -- added empasis to minimum size for Flash Sticks as HD\
Changed lines 1-2 from:

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, with 256MB or more it should just work). You'll have to do some things manually.

to:

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 or more it should just work). You'll have to do some things manually.

March 04, 2005, at 11:19 PM by Peter Andersson --
Added lines 51-53:
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.
January 28, 2005, at 09:35 PM by Koops --
Changed line 66 from:

If all goes well, the stick will no 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:

to:

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:

January 14, 2005, at 09:43 AM by giel --
Changed lines 80-84 from:

There!

Todo

You'll have to make a diversion script to stop the slug from using the swap. But I don't feel like typing anymore today :)

to:

There!

January 14, 2005, at 09:43 AM by giel --
Added lines 26-38:

Alternative

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.

Added lines 72-78:

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):

 echo "#!/bin/sh
 /sbin/swapoff /dev/sda3 
 return 1" > /unslung/rc.unslung
 chmod +x /unslung/rc.unslung
January 13, 2005, at 10:34 PM by rwhitby --
Changed line 1 from:

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, with 256MB or more it might just work). You'll have to do some things manually.

to:

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, with 256MB or more it should just work). You'll have to do some things manually.

Changed line 18 from:

On a standard slug drive, the swap partition is about 55MB, the conf partition about 100MB and the data partition fills up the drive. When you'll try to format a memory stick with the web interface, it fails. This might be because the standard partitioning doesn't fit on 128MB. If this is the only reason (which I don't know because I haven't tested it) and you have a stick bigger than 256MB, you can skip this guide.

to:

On a standard slug drive, the swap partition is about 55MB, the conf partition about 100MB 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 128MB. If you have a stick that is at least 256MB, you can skip this guide.

January 13, 2005, at 06:20 PM by giel --
Changed lines 1-64 from:
to:

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, with 256MB or more it might just work). You'll have to do some things manually.

Requirements

  • An NSLU2 with Unslung firmware
  • A memory stick
  • A Linux machine (or at least some system that is able to handle ext3)
  • fdisk or cfdisk

Partitioning

First, you'll have to make a correct partitioning manually. On a drive prepared by the slug the following partitions can be found:

  1. The data partition
  2. The configuration partition
  3. The swap partition

On a standard slug drive, the swap partition is about 55MB, the conf partition about 100MB and the data partition fills up the drive. When you'll try to format a memory stick with the web interface, it fails. This might be because the standard partitioning doesn't fit on 128MB. If this is the only reason (which I don't know because I haven't tested it) and you have a stick bigger than 256MB, you can skip this guide.

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 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.

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.

Faking the slug

Ok, time to boot up your slug if it wasn't already on. Plug the stick into USB port one and 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".

Finishing up

If all goes well, the stick will no 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 hdd

There!

Todo

You'll have to make a diversion script to stop the slug from using the swap. But I don't feel like typing anymore today :)

Page last modified on February 06, 2009, at 10:00 PM