COMMANDS
TO PREPARE AND LOAD A USB FLASH MEMORY STICK
- and how to use a RAM disk for temporary files to preserve the life of the USB Flash memory
and mount a second drive - see below
(I have used Fedora Core 6 Linux on a Pentium PC - also OK in Fedora Core 7 in VMWare on a Mac)
Ubuntu also works OK
Insert memory stick into PC USB socket - do NOT double click it's icon to mount
it
open a terminal window as root
type (followed by return)
cd /
fdisk /dev/sda - - - fdisk /dev/sdb on my Fedora 7 - - see note §
d
d
n
p
1
when you see - (First cylinder (1-129, default 1):) type return
when you see -(Last cylinder or +size or +sizeM or +sizeK (1-129, default 129):)
type return
w
(wait till the stick LED stops flashing or till you get the terminal prompt again)
umount/dev/sda1
(this unmounts the stick - some versions of linux mount a stick when you plug it in)
then -
mke2fs /dev/sda1
or
mkfs.ext3 /dev/sda1
(thanks to "BZ" for pointing out that ext3 disks are checked and corrected for errors at boot time
- he reports that the router will rescue an ext3 disk that was badly unmounted
)
the stick light will flash for a while - wait till it stops
remove the stick
plug it in again
right click on the usb stick icon in the window "computer" - choose
"mount"
double click on the stick icon on the desk-top
a folder "disk" will open containing nothing but a folder "lost+found" - you now have a formatted stick.
download stick070110.tar.gz (or similar) - see the "distro" page - and save in a new folder/directory
right click on it's icon and choose "extract here"
open the folder stick070110.tar.gz_FILES (or similar) that is created
click on any file and type control-a - all files will be selected
right click on any file and choose "copy"
right click inside the window "disk" and choose paste
(or just drag and drop)
Say "yes" to overwrite folder "lost+found"
right click on the stick icon and choose "Unmount Volume"
wait for the light on the stick to stop flashing and remove the stick
OR if using Ubuntu which stops you being root
open a terminal window and -
mount /dev/sda1 /mnt then cd /mnt
then unpack the tar file from the saved location to the directory (
tar xvf /home/your/path/to/stick_070209.tar.gz
tie a BIG card lable onto the stick so you do not lose it (when you turn your back they wander on their
own like pencils)
write a note on the card
plug it into the Sweex/Edimax router in the USB socket furthest from the Ethernet
sockets
(update - either socket seems to work, unlike the original Elektor project)
-some sticks only turn the LED on while writing - others flash during mount - if in doubt WAIT A BIT before pulling the stick
The terminal should have
looked like this
==================================================================
[root@localhost ~]#
cd /
[root@localhost /]# fdisk /dev/sda
Command (m for help): d
Selected partition 1
Command (m for help): d
No partition is defined yet!
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-492, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-492, default 492):
Using default value 492
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost /]# umount /dev/sda1
umount: /dev/sda1: not mounted
[root@localhost /]# mke2fs /dev/sda1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
31488 inodes, 125936 blocks
6296 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
16 block groups
8192 blocks per group, 8192 fragments per group
1968 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost /]#
===================================================================
§ It is important not to format the wrong drive!!
- to check that the drive sda (say) is the flash drive type this in a terminal window -
udevinfo -q env -n /dev sda | grep ID_SERIAL (- or replace sda with sdb or another guess)
you will see - ID_SERIAL=<drive type shows here>
(please email me if you find a GUI tool for all this!!! - Linux is not a Mac yet....)
At boot time this ( etc/init.d/S94ramdisk ) script runs
---------------------------------------------------------------------------
#!/bin/sh
# create the folder ramdisk and set it as RAM
mkdir /var/www/ramdisk
mount -o size=2M -t tmpfs tmpfs /var/www/ramdisk
echo "save webcam pictures such as picture.jpg to"
echo "ramdisk at http://xxx.xxx.xxx.xxx/ramdisk/picture.jpg"
---------------------------------------------------------------------------
Even though you semi-permanently save files to USB Flash like /var/www/index.html
you can now also save files like picture.jpg to the RAM disk and have
them appear within the root website folder like /var/www/ramdisk/picture.jpg
They are not present after a power off/reboot .
- with thanks to Vlad
Mount a second USB memory stick or hard drive
This only works for me if the router is already running.
Plug the drive into the second USB socket and in a Telnet session type
mount /dev/scsi/host1/bus0/target0/lun0/part1 /mnt/usb
I find several errors reported on the ttyS0 port and attempts to
cd /mnt/usb
ls
only work after tens of seconds delay.
After some tens of minutes things seem to settle down and the disk is useable and faster.
However, a single large USB memory stick is very reliable so I have not fully tested a two disk system.
In order for the system to restart after a power failure the second disk could perhaps be plugged in but not powered.
It could then be powered up in the boot sequence by switching a CPU line (led line) to drive a transistor switch.
Then issue the mount comand after a delay.