Optware, the Right Way
From DD-WRT Wiki
Revision as of 20:29, 5 November 2009 (edit) Masterman (Talk | contribs) (→Frater's no hassle, newbie friendly Optware) ← Previous diff |
Revision as of 20:31, 5 November 2009 (edit) (undo) Masterman (Talk | contribs) (→Frater's no hassle, newbie friendly Optware) Next diff → |
||
Line 106: | Line 106: | ||
'''NOTE''' For smaller storage devices such as SD/MMC and flash drives, the '''minimum''' partition size for /opt should be '''256MB''' | '''NOTE''' For smaller storage devices such as SD/MMC and flash drives, the '''minimum''' partition size for /opt should be '''256MB''' | ||
+ | |||
+ | Also the '''/jffs''' partition is '''not''' necessary if you are only installing this Optware. | ||
Revision as of 20:31, 5 November 2009
Frater's no hassle, newbie friendly Optware
This is the latest, greatest and easiest way to enable Optware on your Router. It is recommended that you have a router with USB capable storage, although SD/MMC Mods are working. Also, you wont be needing JFFS2, so DISABLE it.
Services that will be installed:
- Bash instead of shell in busybox (LFS support)
- Automounting and unmounting of storage device partitions
- Hotmount
- Pre-configured samba share
- Torrent transmission with watchdog
- Reverse proxy featuring pound
- Service tool
- Network printing
- Xinetd
- Pound
- Asterisk
- Lighttpd
- Vlighttpd
- Countryblock
- Services running as other users than root
- Vim with proper terminal support
If starting from scratch, you will need to first format and partition your harddisk, flashdrive or SD card to an EXT2 or EXT3 Linux filesystem. It is much easier than you think, and can be accomplished via a Linux Live boot-CD. There will be NO changes to your PC whatsoever, and it is very simple to implement.
My personal favorite is Ubuntu as it provides a very user friendly interface and can be understood in a matter of minutes no matter what OS you use (Windows, MAC etc) and not to mention Firefox is already installed. Just download the free for life version of your choice (32 or 64 bit) from the above link, and use a burning software like Nero to burn the Image to a CD. After that, simply pop the disc into your CD/DVD drive and reboot.
If your PC BIOS settings are set like they should be (first drive to boot should be the CD/DVD drive), then sit back and wait for it to load.
It will then prompt you for language selection, and then the query prompt will proceed. Default is "Try Ubuntu without any changes to your computer." Hit enter and let it load.
Once in Ubuntu, connect the drive you wish to format and partition. Once completed, navigate to the browsing menu at the top of the screen and look for applications, then click Terminal
Once in the Terminal window, read the following directions and enter the following commands:
NOTE: All BOLD text in this Wiki will be the commands that you enter.
Type sudo su - as this allows you to become root, or full administrator of the machine.
Using the fdisk command, you will be creating four partitions:
- sd?1 - the /opt partition, where Optware will reside.
- sd?2 - the swap partition, where Linux will swap jobs.
- sd?3 - the /jffs partition
- sd?4 - the data partition, which you will share via Samba or FTP.
NOTE The ?'s are the drive letters Linux assigns. You will need to determine which one is correct by issuing the command dmesg | more (Keep Hitting enter to continue readout). You will be looking for the disk you want to format. Here is an example of what it should look like:
scsi0 : SCSI emulation for USB Mass Storage devices Vendor: WD Model: 1600BEV External Rev: 1.05 Type: Direct-Access ANSI SCSI revision: 02 Attached scsi disk sdb at scsi0, channel 0, id 0, lun 0 SCSI device sdb: 312581808 512-byte hdwr sectors (160042 MB)
It's important to understand everyone's disk drive configuration will be different. If your drive is 40 GB or smaller, use the smaller set of partition sizes below. If your drive is over 40 GB, you can use the larger set of partition sizes.
Disk 40 GB or less
- /opt 256 megabytes
- swap 32 megabytes
- /jffs 128 megabytes
- data remainder of the disk
Disk greater than 40 GB
- /opt 512 megabytes
- swap 64 megabytes
- /jffs 256 megabytes
- data remainder of the disk
NOTE For smaller storage devices such as SD/MMC and flash drives, the minimum partition size for /opt should be 256MB
Also the /jffs partition is not necessary if you are only installing this Optware.
Code: (the ? are the drive letters (c,d,e etc.) so make sure you choose the correct one!) The bold texts are the commands
fdisk /dev/sd? Command (m for help): p Disk /dev/sd?: 64 heads, 63 sectors, 621 cylinders Units = cylinders of 4032 * 512 bytes Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-621, default 1):<HIT ENTER> Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): +512M <HIT ENTER> Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (197-621, default 197):<HIT ENTER> Using default value 197 Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +64M <HIT ENTER> Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (197-621, default 197):<HIT ENTER> Using default value 621 Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M <HIT ENTER> Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 4 First cylinder (197-621, default 197):<HIT ENTER> Using default value 1 Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): <HIT ENTER> Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap) Command (m for help): p Disk /dev/sd?: 64 heads, 63 sectors, 621 cylinders Units = cylinders of 4032 * 512 bytes Device Boot Start End Blocks Id System /dev/sd?1 * 1 196 395104+ 83 Linux /dev/sd?2 197 262 133056 82 Linux swap /dev/sd?3 263 458 395136 83 Linux Command (m for help): w
If you get a message saying that the current table is in use and will be executed on next reboot, then do it! Make SURE though after rebooting that when you open the terminal for the next sequence of commands, do a sudo su - followed by an fdisk /dev/sd? and type p as this will verify the partition table
Continuing:
Formatting the /opt, /jffs and data partitions, and preparing the swap partition
mke2fs -j -m 1 -L Optware /dev/sd?1
mke2fs 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09 Filesystem label=Optware OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 122112 inodes, 243964 blocks 12198 blocks (5.00%) reserved for the super user First data block=0 8 block groups 32768 blocks per group, 32768 fragments per group 15264 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Writing superblocks and filesystem accounting information: done
mke2fs -j -m 1 -L Shared /dev/sd?3
mke2fs 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09 Filesystem label=Shared OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 122112 inodes, 243964 blocks 12198 blocks (5.00%) reserved for the super user First data block=0 8 block groups 32768 blocks per group, 32768 fragments per group 15264 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Writing superblocks and filesystem accounting information: done
mke2fs -j -m 1 -L Data /dev/sd?4
mke2fs 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09 Filesystem label=Data OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 122112 inodes, 243964 blocks 12198 blocks (5.00%) reserved for the super user First data block=0 8 block groups 32768 blocks per group, 32768 fragments per group 15264 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Writing superblocks and filesystem accounting information: done
mkswap /dev/sd?2
Now your disk drive is partitioned and formatted for Linux! If you are a windows user, you can either proceed (recommended) using Linux (Ubuntu comes with FireFox already installed) or shut down the Linux distro you used, and make sure the boot disk pops out, as you wll need to get back to windows.
Connecting the Drive to your Router
1. In the DD-WRT web GUI screen, on the Services USB tab enable the options for:
- Core USB support
- USB 2.0 support
- USB storage support
- Printer Support (optional)
- ext2/ext3 File System support
2. From the DD-WRT web GUI screen, on the Administration/Management tab, scroll to the bottom and click on Reboot Router.
3. There are several methods of doing this. Once you have all your partitions set on the external device, add this to your Start-up script in Administration->Commands
Startup script (make sure you install to the/opt partition. Replace the ? after ..lun0/part with the appropriate partition number that /opt is designated. It SHOULD be 1)
sleep 10 && mount -t ext3 /dev/scsi/host0/bus0/target0/lun0/part? /opt & n=1 while [ ! -d /opt/etc/init.d ] ; do sleep 3 [ $n -gt 30 ] && break let n+=1 done /opt/etc/init.d/optS
Click Save Startup
Shutdown script:
/opt/etc/init.d/optK
Click Save Shutdown
Give the router a minute or two to process and reboot.
Alternative (easier):
Web Interface Method:
Go to Services->USB. Enable USB Core support, USB 2.0 Support, USB Printer Support, USB Storage Support, Ext2/3 support, FAT File System Support (optional) and Automatic Drive Mount.
Once the drive and partitions are recognized, Select /opt from the Drop-down menu. Click Apply settings (your router will reboot)
NOTE This may be easier, but the initial Command Line method is much more reliable!
Next, start a terminal session to your router or use a program like PuTTY if using Windows.
First issue these commands to ensure /opt is mounted:
root@DD-WRT:~#mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro) none on /dev type devfs (rw) proc on /proc type proc (rw) ramfs on /tmp type ramfs (rw) devpts on /proc/bus/usb type usbfs (rw) /dev/scsi/host0/bus0/target0/lun0/part1 on /opt type ext3 (rw) root@DD-WRT:~#
Here's just a little sample of my device output parameters. Yours will not look like this yet.
root@Asus:~# df -h Filesystem Size Used Avail Use% Mounted on rootfs 5.0M 5.0M 0 100% / /dev/root 5.0M 5.0M 0 100% / /dev/scsi/host0/bus0/target0/lun0/part3 259M 213M 44M 83% /opt /dev/scsi/host0/bus0/target0/lun0/part4 293G 6.7G 284G 3% /mnt /dev/scsi/host0/bus0/target0/lun0/part1 69M 5.6M 63M 9% /jffs root@Asus:~#
Enter the following commands into Busybox/Telnet:
wget -O /tmp/prep_optware http://wd.mirmana.com/prep_optware sh /tmp/prep_optware
This will load all the necessary optware and supporting scripts that Frater wrote from the ground up.
This will take about 10-20 mins depending on your connection and your router CPU clock. Close your Web Interface as this consumes precious memory and CPU resources
Once everything has completed, type reboot into either the BusyBox/Telnet Shell (why not, your right there) or through the Web Interface.
The BusyBox/Telnet Commands to enable/disable the services are are follows:
service - show all services (enabled/disabled) service <service name> - if "status" is supported it will run the service-script with "status" asparameter. service <service name> on - Enable the script (chmod +x /opt/etc/init.d/S<servicescript>) service <service name> off - Disable the script (chmod -x /opt/etc/init.d/S<servicescript>) service <service name> <parameter> - Run the script with the parameter.
Examples:
service service pound service pound off service pound on service pound stop
service automount start - mount all partitions service automount stop - umount all partitions instead of the one to /opt service automount status - show all partitions service automount unmount <partition|mountpoint> - unmount that partition and remove it fromautomount service automount nomount <partition> - Do not automount this partition service automount nonomount <partition> - remove this partition from the nomount list
Useful scripts
mount fdisk -l blkid df -h cat /tmp/fdisk cat /tmp/blkid cat /opt/etc/automount cat /opt/etc/nomount lsusb
Many more exciting packages are in the works, so be sure to follow This forum thread and further help is always available on the forums.
Enjoy!