Archive

Archive for the ‘Slug’ Category

Ubuntu 9.04 – NSLU2

July 15, 2009 Pari Leave a comment

The first release of Ubuntu for ARM architecture, Ubuntu 9.04 is working great on NSLU2. So far I’ve had running NFS, dhcp3, bluetooth (setup as a PAN AP), WiFi, CUPS, lirc (using the “linux input layer” drivers), wpa_supplicant, mjpg-streamer, mpd. Also successfully cross-compiled and loaded modules: autofs, gpsca, and rt73usb (for my WiFi dongle).

The installation took almost 6-8 hours on a 256kbps DSL connection, external USB flash. Most of it seems to be processing. In many instances during the installation it looked like it was frozen — progress bar stays at the same % mark for sometimes even an hour. Also towards the end when it says installation is completed, it gives an impression that it’s hung: there’s just a blue screen with a blinking prompt at the last line. It stays like that about 20min, and then returns back, prompting you for setting hardware clock. After that, it’s done, reboots.

First thing I did to avoid going through that agonizingly long process again, is backup the filesystem and the NSLU2 internal flash image.

Categories: Linux, Slug

Sheeva Plug

May 24, 2009 Pari Leave a comment

An ARM-based Linux server in a wall-wart – check this out! the Sheeva Plug, introduced by SheevaPlugMarvell. It’s like a headless Intel P3 or AMD Athlon server in a wall-wart, but just drawing only 10 W of power and under $90. You get a system with a 1.2 GHz ARM926EJ-S compatible processor (Marvell’s MV88F6281 Sheeva technology based processor, ARMv5), 512 MB SDRAM, 512 MB Flash, 1 USB 2.0, an SDIO slot, a 1Gig Ethernet, plus it has the JTAG and console available (via dedicated mini-USB port on the side; on the Slug you had to hardware hack and pull the wires out for these). In addition Marvell has made it totally open source (software, hardware, everything,…). Compare that with the Slug’s: 266 MHz, 32 MB SDRAM, 8 MB Flash.

Marvell website already provides a flash image of Ubuntu 9.04 with detailed instructions here.

Here’s some articles/links: Cnet, Slash Gear, NY Times, Scientific American, Plug Computers.

Categories: Linux, Slug

Slug Upgrade – on Batteries

March 28, 2008 Pari Leave a comment

I’m in a place where we have random power cuts during this time of the year, so didn’t want to risk bricking my slug (NSLU2) during an upgrade and so decided to power it by batteries. My fear was that I might end up bricking the slug if there was a power cut right when flashing it. Later I found out it was unfounded, as according to the upslug2 documentation there is really no way for you frag the RedBoot bootloader unless you intentionally do so, as by default, even if your flash image contains RedBoot and SysConfig sections, it does not overwrite the RedBoot and SysConfig areas (they remain untouched).

Anyway… here are some notes on upgrading a slug while on battery power.

Decided to upgrade my Slug to Debian 5.0 (debian-5.0beta1.zip). Followed the steps here (used the upslug2 method for flashing). It’s handy to have a serial console to see if it’s picking up the DHCP stuff properly. I hooked up the Slug directly to my laptop (running Ubuntu) via crossover cable.

Here are some stats. The Slug upgrade took 2 hrs 50min (on a 266MHz Slug, with a 200Kbps DSL connection, 57MB download). At around 2 hrs you’re prompted to create root and user accounts. About 15 minutes later you’re prompted for additional package selection (I unchecked all). In the next 30 minutes it prepares and flashes the kernel image to the Slugs flash memory. On a Slug (with a 2GB USB flash drive plugged into it), 4 freshly charged AA NiMH 2700mAH batteries (5.6v no load) lasted 3 hrs 10min before it dropped to a 4.3v (no load).

Categories: Slug

Slug Flash

February 12, 2008 Pari Leave a comment

Where is the bootloader, kernel and initial ramdisk? The boot sequence is documented here.

Some notes on the slug’s flash memory organization, taken from system logs:

From dmesg:

Searching for RedBoot partition table in IXP4XX-Flash.0 at offset 0×7e0000
6 RedBoot partitions found on MTD device IXP4XX-Flash.0
Creating 6 MTD partitions on “IXP4XX-Flash.0″:
0×00000000-0×00040000 : “RedBoot”           # 256 KB
0×00040000-0×00060000 : “SysConf”            # 128 KB
0×00060000-0×00080000 : “Loader”              # 128 KB
0×00080000-0×001e0000 : “Kernel”               # 1.375 MB
0×001e0000-0×007e0000 : “Ramdisk”            # 6 MB
0×007e0000-0×00800000 : “FIS directory”     # 128 KB

From /proc/mtd:

dev:    size   erasesize  name
mtd0: 00040000 00020000 “RedBoot”
mtd1: 00020000 00020000 “SysConf”
mtd2: 00020000 00020000 “Loader”
mtd3: 00160000 00020000 “Kernel”
mtd4: 00600000 00020000 “Ramdisk”
mtd5: 00020000 00020000 “FIS directory”

From /proc/partitions:

31     0        256 mtdblock0
31     1        128 mtdblock1
31     2        128 mtdblock2
31     3       1408 mtdblock3
31     4       6144 mtdblock4
31     5        128 mtdblock5

Categories: Slug

Internet Radio on the Slug

August 26, 2007 Pari Leave a comment

There are a good number of streaming radio channels on the net that would like to listen to — without leaving my power-guzzling (and really noisy) 400W computer on just for that.

The slug as an internet radio turns out to be an ideal solution for this. Its low power (under 5W) and compact size makes it ideal as a radio replacement. No longer forced to choose from local stations.First you’ll need to have a sound device for your slug. I got a USB Sound Device off of eBay for about $6 (including shipping). Sound clarity is very good for something so cheap.

The application you need to get is mpd (Music Player Daemon). If you’re running Debian/ARM just do:

apt-get install mpd
/etc/init.d/mpd restart

mpd itself doesn’t do anything, it just sits there, listening on default port of 6600 for commands. You’ll need a client. I use mpc (a command line client). There is also a nice plugin for Firefox called FoxyTunes.

First set up these environment variables pointing to your mpd:

export MPD_HOST=your_slugs_ip
export MPD_PORT=6600

Add a station (you can find stations on Shoutcast directory; note that mpd remembers the list of stations and which station it left off at and automatically streams it after rebooting):

mpc add http://www.live365.com/play/wamu3

Or you can create a play list and put it in /var/lib/mpd/playlists. Sample file (say radio_stations.m3u):

http://www.live365.com/play/wamu3
http://195.56.146.98:8002
http://64.202.98.133:2220

And load it:

mpc load radio_stations

Play:

mpc playlist
mpc play 2
mpc volume +5

Categories: Linux, Slug

Slug – Install

August 12, 2007 Pari Leave a comment

All these slug notes are for my own future reference in I decide to get some more slugs down the line :-). Just putting it out here to share.

I’ve installed Debian 5.0.1 (i.e. Lenny), on a 2GB flash drive (connected to USB port 1).Created a root partition of 1.5GB, and swap of 512MB on the 2GB flash drive:

Disk /dev/sda: 2041 MB, 2041577472 bytes
61 heads, 60 sectors/track, 1089 cylinders
Units = cylinders of 3660 * 512 = 1873920 bytes
Disk identifier: 0×000667ca

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         816     1493250   83  Linux
/dev/sda2             817        1089      499590   82  Linux swap / Solaris

Did the installation via flashing the debian installer image using upslug2 method as described here. At the end of the installation of the minimal Debian system, it flashes the new kernel and initrd to the Slug’s Flash.

Added the following extra packages after installation using apt-get:

apt-get install alsa-utils apache2 autofs bind9 bmon bzip2 chkconfig cups curl dhcp3-server dropbear irb ldap-utils lsof lynx nfs-common nfs-kernel-server pciutils portmap psmisc rtorrent ruby sasl2-bin samba screen sg3-utils slapd sudo sysstat tcpdump vim-runtime xauth

You don’t want to have all those services running given the limited memory the slug has, so you can remove the services you need from auto starting by this command (the equivalent of chkconfig command in Fedora/Redhat):

update-rc.d -f service_name remove

To restore the default runlevels, run:

update-rc.d service_name defaults

See Also:

Categories: Linux, Slug

Slug – Cups

August 12, 2007 Pari Leave a comment

Printer settings in /etc/cups/cupsd.conf (just the most relevant sections to get you started):

# Only listen for connections from the local machine.
Listen localhost:631
Listen 192.168.1.77:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing Off
BrowseProtocols cups
BrowseOrder Deny,Allow
BrowseAllow from @LOCAL
BrowseAllow from @IF(eth1)

# Default authentication type, when authentication is required…
DefaultAuthType Basic

# Restrict access to the server…
<Location />
Require valid-user
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.0/24
</Location>

# Restrict access to the admin pages…
<Location /admin>
#Require valid-user
Require group printadmins
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.0/24
</Location>

Then reload the configuration:

service cups reload

Plug the printer into the USB (if it isn’t already).

Next, from your browser bring up the Cups Printer Administration tool, running on the Slug’s port 631:

lynx http://slug:631

and follow the steps there to detect and the printer that is connected to the slug. After that is done you’ll find a printers.conf in /etc/cups directory, containing details of your printer.

Accessing your printer

You can access your printer via IPP. In Ubuntu 8.10, under add New Printer, select “Internet Printing Protocol” and specify the URI. For example, ipp://slug:631/printers/Samsung_ML-2010

Sharing Printers via Samba

Printer settings in global section in /etc/smb.conf::

[global]

load printers = yes
printing = cups
printcap name = cups
cups options = raw

My printers section in /etc/smb.conf:

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
read only = yes
create mask = 0700
use client driver = yes;
admin users = @printadmins

# If you want anyone to be able to use your printer then keep this:
guest ok = yes

# If you want to restrict users, then comment out above and uncomment this (make sure user1 is in the samba db).
;valid users = user1

Categories: Linux, Slug

Slug – Samba

August 12, 2007 Pari Leave a comment

Sharing Folders

To share a folder, say /misc/flash/share, create a section in the /etc/smb.conf:

[myshare]
path=/opt/share
browseable = yes
writable = yes
valid users = user1
#guest ok = yes

Create a samba account in the samba’s database for user1:

smbpasswd -a user1

Reload the samba service:

service samba reload

Now go to another machine on the same network and mount it as follows:

mount.cifs //slug/myshare /opt/slug

Automount and Samba

You can have samba automount your samba shares to /smb (or /cifs). For example

ls /smb/server_name/share_name

Just add these two files (this is a dirty way of doing it; i.e. putting user specific stuff in /etc, just for personal use):
/etc/auto.smb.slug.opts

mountopts=”$mountopts,rw,iocharset=utf8,uid=uid,gid=gid

/etc/auto.smb.slug.cred:

username=username
password=password

Note: I edited the /etc/autofs.smb script to use auto.smb.server_name.cred file for credentials instead of auto.smb.server_name file.

Don’t forget to restart/reload autofs:

service autofs reload

Samba Client

# List SMB shares
smbclient -L //server -U user

# Connect
smbclient //server/myshare -U user

# Mount
smbmount //server/myshare ~/share

# Or:
mount -t cifs //server/myshare ~/share -o username=username,noexec

Sharing Directory by Group

To make the /opt/share directory shareable by multiple users in a closed user group, create a group (I call it cug):

groupadd cug

Edit the /etc/group and add all the users you want to have share the folder to the cug group. You may have to logout and log back in for the new group to have effect (even though it may show up in the “id user” command).

Then change the ownership and set the SGID bit for the /opt/share directory.

chown nobody.cug /opt/share
chmod 2775 /opt/share  # chmod g+sw

Categories: Linux, Slug

Slug – NFS/Automount

August 11, 2007 Pari Leave a comment

I’ve kept my home directories (for that matter anything that I write to) on a separate filesystem on a flash drive attached to port 2 of the Slug (port 1 has the flash drive with the OS).

I like to mount my /home directories on demand, when I plugin the the second flash drive. This entails the following steps:

1. Automount flash drive to /misc/flash:

Configure the automounter to mount the flash drive (to /misc/flash).

Add this to /etc/auto.master:

/misc   /etc/auto.misc –timeout=60

Add this to /etc/auto.misc:

flash           -fstype=ext3            :/dev/sdb1

2. Export user home directories found in /misc/flash/homes:

Configure NFS to export the user home directories found in /misc/flash/homes.

Add this to /etc/exports:

/misc/flash/user1 192.168.1.0/24(rw,sync,no_subtree_check)

/misc/flash/user2 192.168.1.0/24(rw,sync,no_subtree_check)

3. Automount the above home directories when accessed:

Configure another automounter configuration which automounts the user’s home directory via NFS fstype (as they are NFS file systems) when the users accesses /home/user.

Add this to /etc/auto.master:

/home   /etc/auto.home –timeout=60

Add this to /etc/auto.home:

*        -fstype=nfs,soft,intr,nosuid    slug:/misc/flash/homes/&

Categories: Linux, Slug

Slug – Tips

August 10, 2007 Pari 2 comments

Reducing Memory

Given that it has only 32MB of RAM, NSLU2 runs Asterisk as is very well, but if you want to add more daemons you might need to miser down on the memory.

Dropbear
Dropbear consumes only 2.4MB vs 8.2MB of SSH (who would’ve ever thought I’d be concerned about savings of 6MB of memory!)

Install dropbear:

apt-get install dropbear

Edit the /etc/default/dropbear configuration file:

NO_START=0
DROPBEAR_PORT=22

Remove sshd and start dropbear:

update-rc.d -f ssh remove
/etc/init.d/dropbear start

Here is a comparison of memory usage:

NSLU2:~# ps -eo comm,pid,%mem,vsize | grep dropbear
dropbear 1743 root 1.7 1916
dropbear 1884 root 3.4 2440

NSLU2:~# ps -eo comm,pid,%mem,vsize | grep sshd
sshd 1808 root 3.5 5148
sshd 1904 root 7.6 8216

Asterisk: If you’re running Asterisk, you might want to replace your modules.conf with minimal one found here Slimming Asterisk, it’ll prevent hoards of asterisk modules from loading.

Reducing Disk Writes

If your using a flash drive, you’ll definitely want to reduce the number of disk writes to the drive.

1. Mount with ‘noatime’ parameter, this will stop the kernel from writing the access time every time the file accessed.

/dev/sda1 / ext3 defaults,noatime,errors=remount-ro 0 1

2. Disable syslogd MARK entries
Disable syslogd MARK entries by adding this line to /etc/default/syslogd. You don’t need this if you’re using Debian 5.0.1 (Lenny) – it uses rsyslogd (instead of syslogd) and MARK entries are disabled by default (the “ModLoad immark” is commented out in /etc/rsyslog.conf).

SYSLOGD=”-m 0″

3. Log files are sync’d immediately to the filesystem the moment they are written to. To prevent immediate sync’ing, dash out all entries in /etc/default/syslogd. It will still write to the log files, just that they won’t get sync’d immediately.

4. Move samba caching to a ramfs
On doing a “find /var -mmin -10 -ls” I found some files that were being written to regularly by samba. Moved this to a small ramfs, by adding this line in /etc/fstab:

none    /var/cache/samba    ramfs    maxsize=512    0    2

5. Set swappiness value to zero (default is 60):

echo 0 > /proc/sys/vm/swappiness

or set this in /etc/sysctl.conf:

vm.swappiness = 0

6. Tune disk writes. Set the following in /etc/sysctl.conf:

vm.dirty_background_ratio = 5              # default = 5
vm.dirty_ratio = 50                                # default = 10
vm.dirty_writeback_centisecs = 500        # default = 500
vm.dirty_expire_centisecs = 3000           # default =3000

Spinning Down the Drive

After trying a couple of different ways to do this (hdparm, scsi-stop, etc), I found I had the best luck with the sg_start utility (from sg3_utils package):

Get the packages:

sudo apt-get install sg3-utils libsgutils1

Example command to spin down:

sg_start –stop –pc=2 /dev/sdb

Very useful. Besides using it for the slug, I also use it to force spin down my external drive after unmounting it and just before I pull the USB cable – so that I don’t get that horrible “clunk” noise in the drive.

Other

Some other things you might want to put into your Linux on Slug:

1. Enforce file system check
Given that the NSLU2 is headless, you definitely don’t want to be left helpless, should it ever go into maintenance mode asking you to do fsck. So enforce fsck, add the following in /etc/default/rcS:

FSCKFIX=yes

2. Power Button
The default setup causes the power button to reboot. I changed it to shutdown:

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now

Categories: Linux, Slug