The SheevaPlug Experience

In one of my first posts I referred to the fact that I am running this wordpress blog on a SheevaPlug (more details about this server here). Below is a rather lengthy post with my notes about setting up this server

The Sheeva Plug Experience

0. Connected USB from Sheeva to PC. PC found new hardware after a while. Needed CD to install drivers. After, open Device Manager in Control panel to check which COM port the sheeva is reachable over. Then used putty to make the serial connection over that port… worked

1. My very first step was to program the sheeva to boot from an external USB flash disk. To this end I essentially followed the guide here:

As a summary:
Plugged in the USB hub
Plugged in the USB flash drive
ran dmesg to see which device the USB was now loaded on (/dev/sda)
formatted the usb drive using fdisk to have 3 partitions:

Disk /dev/sda: 8021 MB, 8021606400 bytes
5 heads, 32 sectors/track, 97920 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0x00000000
Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          27        2144   83  Linux (ext2)
/dev/sda2              28       97635     7808640   83  Linux (ext3)
/dev/sda3           97636       97920       22800   83  Linux (swap)

once partitioned, formatted the partitions mkfs.ext3 and mkfs.ext2 and mkswap
Created mount points:

mkdir /mnt/mtdroot
mkdir /mnt/sda1
mkdir /mnt/sda2

Mounted the partitions and internal NAND flash:

mount /dev/mtdblock1 /mnt/mtdroot
mount /dev/sda1 /mnt/sda1
mount /dev/sda2 /mnt/sda2

Copied internal filesystem from NAND to external USB drive:

cp -av /mnt/mtdroot/. /mnt/sda2
cp -a /dev /mnt/sda2

Copied kernal from the provided CD to the boot parition:

cp uImage /mnt/sda1

Edited fstab so that kernel loaded from sda1

rootfs / rootfs rw 0 0

replaced with:

/dev/sda2 / ext3 rw 0 0
 /dev/sda1 /boot ext2 rw 0 0

edited Uboot to use USB:

Backup of the boot arguments so that it is easy to go back if it doesn’t work. Type the following at the Marvell prompt:

 setenv bootargs_nand $(bootargs)
 setenv bootcmd_nand $(bootcmd)

Then, write the new arguments to boot from the external storage:

setenv bootargs 'console=ttyS0,115200 root=/dev/sda2 rootdelay=10 mtdparts=nand_mtd:[email protected](uImage),[email protected](rootfs) rw'
setenv bootcmd 'usb start; ext2load usb 0:1 0x8000000 uImage; bootm 0x8000000; reset'
saveenv (or boot to try once)

2. Fixed the apt-get problem (basically due to space problems the designers wipe apt-get packages to save space):

edit the file /etc/fstab and comment out the follow line with a #:

tmpfs /var/cache/apt tmpfs defaults,noatime

Reboot the system for the changes to take effect. The system would not mount /var/cache/apt as tmpfs anymore and now you can create the archives directory with:

mkdir -p /var/cache/apt/archives/partial

3. Fixed networking:

auto lo
iface lo inet loopback
# dhcp example
#auto eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static

4. Installed mysql server:

apt-get install mysql-server

Had some problems with root password (do not use !! in password), so had to uninstall (apt-get remove mysql-server) and reinstall along with dpkg-configure mysql-server

5. Installed apache and PHP:

sudo apt-get install apache2
 sudo apt-get install php5 libapache2-mod-php5 php5-mysql

restart apache (/etc/init.d/apache2 restart)

make php work with mysql, open file /etc/php5/apache2/php.ini
Uncomment the following line by taking out the semicolon (;).
Change this line:


More info, especially the SSL part:

6. Installed proftpd
7. Wrote quick script to change hostname (because proftpd wasnt starting) and edited resolv.conf to contain correct hostnames. Also starts proftpd automatically

To write the startup script example:

Write a script. put it in the /etc/init.d/ directory.
Lets say you called it FOO. You then run
update-rc.d FOO defaults
You also have to make the file you created, FOO, executable, using
chmod +x FOO

8. Install BIND
to allow forwarding in the named.conf.options add:

 allow-query     { any; };

9. Installed SAMBA
published a fileshare:

nano -w /etc/samba/smb.conf

enabled the WINS server part (uncommented the line).
enabled security=user
 changed workgroup variable
 uncommented interfaces variable

added the following in the section:

 #======================= Share Definitions =======================
 #Dave's FTP root share
 comment = Dave FTP Root Folder
 read only = no
 browseable = no
 create mask = 777
 directory mask = 777
 guest ok = no
 path = /var/ftproot

added an SMB password for my user:

smbpasswd -a username

restarted the service /etc/init.d/samba restart

10. Implemented disk space monitoring because not enough space to be comfortable

– Installed sendEmail (apt-get sendemail)
– made new directory in /var/
– defined diskmonitor.script

df / > diskusage
myvar=$(awk -F” ” ‘/[-9]+[0-9]/ {print $3}’ diskusage)

if [ $myvar -ge 5208476 ];
sendEmail -f [email protected] -t [email protected] -u “DISK SPACE ALERT” -m “WARNING WARNING My disk space usage is over 80%” -s
echo “Disk Usage under control”>>/var/log/messages

The above monitors disk space usage and emails me if goes over a threshold

– made diskmonitor.script executable:
chmod +x diskmonitor.script
– made a cronjob to schedule the above file diskmonitor.script:

crontab -e

added line:

# m h  dom mon dow   command
 * */5 * * * /var/scripts/diskmonitor.script

this will run my script every 5 hours

11. Configure mysql to use another location database:

12. Probably going to publish ssh access, so I want an “autoban” feature:

apt-get install denyhosts

then edit the config file: /etc/denyhosts.conf

also changed the ssh port and timeout from /etc/ssh/sshd_config
the timeout value is changed by adding the line: ClientAliveInterval 540