memory stick
Home Firmware tools memory stick Busybox easy VI Packages Miscellaneous Update Upgrade Error: killed Slug 2010 Beyond NSLU2 Contents Site home

 

Partitions
Replacing dropbear

Running openslug on a USB memory stick/flash drive

We start by logging in to the slug using Putty. The default password should be "opeNSLUg"

login as: root
root@192.168.x.x's password: 

Note that I've already run "turnup init" and set the password and network parameters. If you haven't done this already then now is a good time.

Now I'll run "df" to see how much free space is available:

root@zebidee:~# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/mtdblock4            6528      5524      1004  85% /
/dev/mtdblock4            6528      5524      1004  85% /dev/.static/dev
tmpfs                    10240        28     10212   0% /dev
tmpfs                    15148        20     15128   0% /var
tmpfs                    15148         0     15148   0% /media/ram

Insert the fat formatted memory stick and wait for it:

root@zebidee:~# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/mtdblock4            6528      5524      1004  85% /
/dev/mtdblock4            6528      5524      1004  85% /dev/.static/dev
tmpfs                    10240        32     10208   0% /dev
tmpfs                    15148        20     15128   0% /var
tmpfs                    15148         0     15148   0% /media/ram
/dev/sda1 497712 0 497712 0% /media/sda1

The memory stick is in the wrong format though, we can verify that with the mount command:

root@zebidee:~# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/root on /dev/.static/dev type jffs2 (rw)
tmpfs on /dev type tmpfs (rw)
tmpfs on /var type tmpfs (rw)
tmpfs on /media/ram type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/sda1 on /media/sda1 type vfat (rw,sync,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8)

To fix this we first unmount it with "umount" then create an ext3 file system using mke2fs with the -j option:

Alternatively you could partition the drive to have separate system and data areas.

Note: You are advised to REBOOT after creating partitions, and before creating file systems on those partitions (unless you did the partitioning on a PC beforehand)

root@zebidee:~# root@zebidee:~# umount /dev/sda1
root@zebidee:~# root@zebidee:~# mke2fs -j /dev/sda1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
124928 inodes, 497980 blocks
24899 blocks (5.00%) reserved for the super user
First data block=1
61 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
       8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables:  done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

At this point I reboot just to be sure (actually this is unnecessary).

root@zebidee:~# reboot
root@zebidee:~# 
Broadcast message from root (pts/0) (Thu Dec 14 21:12:47 2006):

The system is going down for reboot NOW!

And log back in

login as: root
root@192.168.x.x's password: 

I can now run "turnup". "memstick" means select options suitable for flash memory.

Normally a disk install would include a swap partition to increase available memory ("virtual memory") however on a flash drive a swap partition would slow the system down and could wear out the flash memory. If you do intend to use a swap partition then activate it now with "swapon"

A memstick install will also put parts of the filesystem in ramdisk to minimise wear on the flash.

Option "-i" means initialise, which tells it to copy the system to the device and not just use an existing install.

Option "-f" tells turnup to go ahead even if there are files already present. It probably stands for "force" or "format".

This is a slow operation and will take several minutes.

Note: The full command should be: "turnup memstick -i /dev/sda1 -t ext3" with the final -t part telling it what filesystem to expect.

root@zebidee:~# turnup memstick -i /dev/sda1
/sbin/turnup: umounting any existing mount of /dev/mtdblock4
turnup: copying root file system
17641 blocks
done
touch: /var/log/wtmp: No such file or directory
chown: /var/log/wtmp: No such file or directory
eval: 1: cannot create /dev/tty0: No such device or address
chmod: /var/log/wtmp: No such file or directory
eval: 1: cannot create /dev/tty0: No such device or address
turnup: tmpfs will no longer be mounted on /var

I often get some errors at this stage, shown in cyan. More importantly if I run "df" again I can see that the root file system is still "/dev/mtdblock4" and not "/dev/sda1" so I reboot and try again:

root@zebidee:~# reboot

Broadcast message from root (pts/0) (Thu Dec 14 21:22:16 2006):

The system is going down for reboot NOW!
root@zebidee:~# login as: root
root@192.168.x.x's password: 
root@zebidee:~# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda1 6528 5524 1004 85% /initrd
/dev/sda1 482214 17707 439608 4% /
/dev/sda1 482214 17707 439608 4% /dev/.static/dev
tmpfs 10240 32 10208 0% /dev
tmpfs 15148 20 15128 0% /media/ram

At this point the system is running off the stick and we can install packages using ipkg.

Things that could go wrong:

The system may forget the "turnup" and revert to running from internal flash. If this happens you'll need to run "turnup /dev/sda1" again, this time without the "-i" option. If you can't reboot or can't run anything it means the flash is full. Just take out the memory stick, reflash the NSLU2 with openslug, then try again.

Afterwards run "turnup preserve" to store the configuration properly.

Note that so far I've only had to do this once, even though I've replaced the flash image a few times.

The following is a new one on me and I have no idea what's wrong. I'll probably try a reflash. The stick has been used before without problems and it's been repartitioned so there is no good reason why it shouldn't turnup.

Further note, this is caused by me not paying attention to the wiki, the -i switch goes before the device name.

root@zebidee:~# turnup memstick /dev/sda1 -i -f
/sbin/turnup: umounting any existing mount of /dev/mtdblock4
umount: /tmp/rootfs.1391: not mounted
turnup disk: /dev/sda1(/tmp/rootfs.1391): umount does not seem to work
turnup disk: /dev/sda1(-i -f -o noatime): unable to mount device on /tmp/rootfs.1391
root@zebidee:~#