0% found this document useful (0 votes)
132 views8 pages

Creating Ext3%Swap Partitions On Tomato

The document provides step-by-step instructions for partitioning and formatting a USB storage device that is connected to a router running the Tomato firmware. It describes plugging in the USB device, using fdisk to create partitions including a Linux swap partition and an ext3 data partition, formatting the partitions, mounting the data partition, and enabling swap. It recommends labeling partitions for easy mounting and notes that swap should not be used on flash storage for permanent use.

Uploaded by

Odnarf Leahcim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views8 pages

Creating Ext3%Swap Partitions On Tomato

The document provides step-by-step instructions for partitioning and formatting a USB storage device that is connected to a router running the Tomato firmware. It describes plugging in the USB device, using fdisk to create partitions including a Linux swap partition and an ext3 data partition, formatting the partitions, mounting the data partition, and enabling swap. It recommends labeling partitions for easy mounting and notes that swap should not be used on flash storage for permanent use.

Uploaded by

Odnarf Leahcim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

For phase 1 I'll use the GUI to make things more simple (believe it or not):

1) Plug in USB storage device to router

1a) For simplicity's sake, make sure you have only one USB device attached, to avoid making a mistake
and wiping out a different device.

2) Open your favorite web browser, log into the Tomato website

3) Select USB and NAS, then USB Support

4) Device should be listed under "Attached Devices" at bottom of page.

4a) USB devices tend to be slow to mount, so patience helps. I usually get up and grab a cup of coffee
rather than refresh-refresh-refresh.

4b) If router doesn't recognize the USB device, verify core USB support & USB storage support are
enabled. Remember to hit Save after changing settings. Give it some time, at least a couple minutes,
then refresh the page and see if it's listed.

4c) Some devices only work if USB printer support is disabled, others require USB 3G modem support to
be disabled. Remember to hit Save. Give it some time then refresh.

4d) Occasionally I've noticed toggling on USB 1.1 Support kickstarts the process. Remember to hit Save.
Give it some time then refresh.

4e) If all else fails, and all settings are configured, try to reboot router.

4f) Typically once the router has mounted the device it'll continue to recognize it, so you can probably
turn on USB printer sharing, 3G modem support, disable USB 1.1, etc. and it'll still stay mounted. YMMV
(your mileage may vary)

5) After device is listed as an Attached Device, click on Unmount

6) Mounted? should then change from Yes to No

7) Close your web browser.

CLI for phase 2:

Commands here follow the step's initial instructions/explanation, which are then followed by some
example output. Any subsequent commands follow the output, and so on, within a step.
8) Login to router over telnet or ssh (putty for Windows is free and supports both)

9) List existing devices and partitions:

fdisk -l

Disk /dev/sda: 3941 MB, 3941597184 bytes

255 heads, 63 sectors/track, 479 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 480 3849152 b Win95 FAT32

Partition 1 has different physical/logical endings:

phys=(478, 254, 63) logical=(479, 52, 21)

9a) In my example, the device is /dev/sda and contains partition /dev/sda1 that uses a FAT32 format.

9b) It will probably be this or /dev/sdb and /dev/sdb1 but you need to read and interpret what it says

9c) /dev/jffs and /jffs is the JFFS filesystem, you do not want to touch it; do not run fdisk on a jffs device

9d) If you are at all confused STOP RIGHT NOW and ask for help!

10) Now we're going to create a new partition map and partitions:

fdisk /dev/sda

11) Create a new blank paritition table:

o
Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that the previous content

won't be recoverable.

12) Add a new primary partition, partition number 1:

e extended

p primary partition (1-4)

Partition number (1-4)

First cylinder (1-479, default 1)

Hit enter for default

Last cylinder or +size or +sizeM or +sizeK (1-479, default 479)

For a single partition you can hit enter to use the entire disk. I want to create a swap partition so I will
type +500M for a 500MB swap partition:

+500M

12a) Since I'm creating a swap partition I need to set the partition type:

Selected partition 1
Hex code (type L to list codes)

You can type L to list all types of filesystems, but 82 is Linux swap, so that's what I'll type:

82

13) Now I want to create a 2nd primary partition for ext3 data storage:

e extended

p primary partition (1-4)

Partition number (1-4)

Because partition 1 was just created as swap, we want to create partition 2:

First cylinder (63-479, default 63)

Hit enter for default (in this case, 63).

Last cylinder or +size or +sizeM or +sizeK (63-479, default 479)

Hit enter to use the entire disk for partition 2, or if you want to use a specific value (e.g. to create a 3rd,
4th, etc. partition) then type +###M with the appropriate numeric value like I did for swap.

If you want to create 3rd, 4th, etc. partitions then go back and create them. Otherwise continue on to
the next step.
14) Now that my two partitions are created I'm going to verify the partition map is how I want it by
printing it to screen.

Disk /dev/sda: 3941 MB, 3941597184 bytes

255 heads, 63 sectors/track, 479 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 62 497983+ 82 Linux swap

/dev/sda2 63 479 3349552+ 83 Linux

15) Now ask yourself: Is this how you want the disk to be? Are you sure? Are you really, really sure? If no
then hold down control & press c to break out of fdisk and abort all changes. If yes, then you need to
write it to disk.

Calling ioctl() to re-read partition table

You will then be dropped back to the shell prompt. If you failed to unmount the filesystem an error will
be displayed after ioctl. This error means fdisk couldn't write the partition map to disk, and your old
partitions are still intact. Go back to step one and unmount the partition(s).

16) Okay now you have your partitions there, and it's time to format them. Since I created a swap
partition, I'll format that one first, giving it the label "swap":

mkswap -L swap /dev/sda1


16a) Now to format my 2nd partition as ext3, giving it the label "Data":

mkfs.ext3 -L Data /dev/sda2

mke2fs 1.38 (30-Jun-2005)

Filesystem label=Data

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

419328 inodes, 837388 blocks

41869 blocks (5.00%) reserved for the super user

First data block=0

26 block groups

32768 blocks per group, 32768 fragments per group

16128 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200

Writing inode tables: done

Creating journal (16384 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

17) And you're back to a shell prompt. You can either reboot the router by typing:

reboot
At which point the router will reboot, and the default mounts will take effect.

Or you can manually mount the partitions. Because I gave the partition the label "Data" it will mount to
/tmp/mnt/Data. Therefore I would type:

mkdir /tmp/mnt/Data

mount /dev/sda2 /tmp/mnt/Data

Which would mount my Data partition. If you labelled your partition "Stuff" it would mount to
/tmp/mnt/Stuff instead. If you leave the label blank it will mount with the device name, which will
change depending on which USB port its plugged into (which is why labels are a Very Good Idea). Make
sure your labels are unique across devices, you don't need two partitions called Data (just call the other
one Lore).

18) To enable swap:

swapon /dev/sda1

Note that swapon only affects the current state of the router. If you reboot swap gets disabled. To
"permanently" enable swap call swapon in either the Init or Firewall tab under Administration -> Scripts.
As far as I can tell the label is ignored by swapon, so if you shuffle the drive between ports then you'll
need to adjust swapon to the new device name.

18a) Do not enable swap on flash-based devices unless you like destroying flash-based devices. For short
term purposes it will be perfectly fine, but if you need swap enabled 24/7 to run something from
optware/entware/etc. 24/7 then you need to put your swap on a hard disk. I create them for what-if-I-
need-swap-at-the-remote-site-in-6-months emergency purposes, purely a temporary solution to allow
the full range of possibilities at a future date. If I needed to enable it permanently I would go through
the trouble of partitioning a HD this way and using that instead (or, likely, in addition to flash).
One last note, if you wanted to format in ext2 instead of ext3, you would use the mkfs.ext2 command
instead of mkfs.ext3. Aside from changing 3 to a 2 the command line is otherwise identical (the output
will be slightly different).a

You might also like