Debian on a Seagate DockStar

I bought a Seagate DockStar a couple of months ago.  What attracted me to this device was its size, its low price (compared to other Plug Computers), and support for a standard Linux Debian distribution.  I would have wanted something that I could install Ubuntu on, but Ubuntu does not provide support for the ARM v5 architecture.  I’m okay with Debian though, and Debian provides packages to this “armel” device even in their “squeeze” testing release.

SeagateFreeAgentDockStar-2

The DockStar has 128MB of RAM and 256MB of flash memory.  It has 4 USB ports, and unlike other Plug Computers, the ports are powered so you can attach regular USB thumb drives as well as higher-capacity portable drives.  The factory setting has the NAND flash memory set into four partitions.  The first partition mtd0 (1 MB) contains a very old U-Boot bootloader.  The second partition mtd1 (4 MB) contains a Linux kernel image, and the third partition mtd2 (32 MB) contains a Linux jffs2 file system.  The remaining partition mtd3 (219 MB) is unused.

Hacking the DockStar to boot a different Linux system from a USB drive all stemmed from the instructions initially posted at http://ahsoftware.de/dockstar/.  In essence, the bootloader environment variables are changed to cause the mtd0 bootloader to chain to another bootloader that gets installed at mtd3.  The installed mtd3 bootloader can then check for USB drives and boot the Linux kernel from there.

To accommodate a fallback to the original Pogoplug environment in case the USB drive fails to boot, a “switching” approach was made to the bootloader environment variables – that is, at each boot, the variables would be changed between booting the mtd1 kernel and booting a USB drive kernel.  However, the bootloader environment variables are themselves stored somewhere in mtd0, so this switching approach may potentially be a cause of your device getting bricked (if something fails in the update to mtd0).  Because of technical limitations, the installed mtd3 chained bootloader cannot be made to boot back into the mtd1 kernel if it fails to boot the USB drive.  Some users have opted to configure the boot sequence such that it always tries the USB drive, but does not change the bootloader variables in mtd0.  If the USB boot fails, the USB drive can just be mounted on another machine and get fixed.

Although it’s been desired by all that mtd0 should not be updated on every boot, there were discussions on whether the old U-Boot bootloader at mtd0 should just be updated.  It’s true that writing to the mtd0 U-Boot has its risks, but mtd0 is being re-written anyway (on every boot) if the switching mechanism is used.  So a one-time update to mtd0 sounds more reasonable.  This also frees up mtd3 for installing other things, like maybe a very small 219 MB Linux installation.

Step 1.  Prevent the DockStar from “phoning home”.

Out of the box, if you connect the DockStar to your network, it will retrieve firmware updates and disable ssh on the device.  To prevent this, I disconnected my home router from the Internet, but had it still responding to DHCP requests.  There is often a page from the mini web server in your router that lists out the IP addresses it has handed out, so that you can determine what IP address the DockStar received via DHCP.  Knowing that, you could ssh into the DockStar with the default password, comment out the script command that runs the Pogoplug software (which retrieves the firmware update from the Internet) and save that back into flash memory.  This is documented in http://ahsoftware.de/dockstar/.  It’s been mentioned that it’s better to just add a command to kill the offending process, so that other kernel modules can get loaded.  But I do not trust any executable from the cloudengines directory to not “phone home”, so I’m fine with disabling the whole script.

Step 2.  Update the mtd0 U-Boot and environment variables.

Jeff Doozan has been active on getting this done easily, and great instructions are posted at http://jeff.doozan.com/debian/uboot/ and subsequently adopted at http://www.plugapps.com/index.php5?title=PlugApps:Pogoplug_Setboot

Step 3.  Install the Debian “squeeze” release into a USB drive.

I opted to cross-install Debian’s armel distribution using debootstrap.  Since I was working from an Ubuntu desktop machine, my USB drive was at /dev/sdb.  I made three partitions (one 1GB ext3 partition, one 1GB swap partition, and another ext3 partition) and used the following to create the file systems:

    sudo mkfs -t ext3 /dev/sdb1
    sudo mkswap /dev/sdb2
    sudo mkfs -t ext3 /dev/sdb3

I obtained and used the cross-platform bootstrapper.  I opted to include the ntp package (because the DockStar does not have a battery-backed RTC), the USB automounter, the ssh server, the U-Boot image utilities, and the Linux kernel at this time.  Other packages can be installed later once we get the DockStar to boot from the USB drive.

    sudo apt-get install debootstrap
    sudo mount /dev/sdb1 /mnt
    sudo /usr/sbin/debootstrap --foreign --arch=armel \
        --include=ntp,usbmount,openssh-server,uboot-mkimage,linux-image-2.6.32-5-kirkwood \
        squeeze /mnt http://ftp.us.debian.org/debian
    sudo umount /mnt

Unmount the USB drive from the desktop and attach it to the DockStar.  The DockStar will still boot to the Pogoplug environment since there isn’t a valid U-Boot kernel image at the USB drive at this time.  After ssh’ing into the DockStar:

    mount /dev/sda1 /mnt
    /usr/sbin/chroot /mnt /bin/bash
    PATH=/usr/sbin:/sbin:$PATH
    mount -t proc none /proc
    /debootstrap/debootstrap --second-stage

Although some prebuilt kernels are available at http://sheeva.with-linux.com/sheeva/, I opted to use the standard kernel from Debian:

    mkimage -A arm -O linux -T kernel -C none -a 0x8000 -e 0x8000 \
        -n "vmlinuz-2.6.32-5-kirkwood" -d /vmlinuz /boot/uImage
    mkimage -A arm -O linux -T ramdisk -C gzip -a 0 -e 0 \
        -n "initrd.img-2.6.32-5-kirkwood" -d /initrd.img /boot/uInitrd

I then performed some housekeeping stuff before the reboot of the DockStar:

    echo "dockstar" > /etc/hostname
    echo "LANG=C" > /etc/default/locale
    echo "/dev/sda1 / ext3 defaults 0 1" >> /etc/fstab
    echo "/dev/sda2 none swap sw 0 0" >> /etc/fstab
    echo "none /proc proc defaults 0 0" >> /etc/fstab
    echo "auto lo" >> /etc/network/interfaces
    echo "iface lo inet loopback" >> /etc/network/interfaces
    echo "auto eth0" >> /etc/network/interfaces
    echo "iface eth0 inet dhcp" >> /etc/network/interfaces
    echo "deb http://ftp.us.debian.org/debian squeeze main" >> /etc/apt/sources.list
    echo "deb-src http://ftp.us.debian.org/debian squeeze main" >> /etc/apt/sources.list
    echo "America/Los_Angeles" > /etc/timezone
    cp /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
    passwd root
I exit back to the Pogoplug-based environment and unmount the USB drive.
    exit
    umount /mnt
Step 4.  Boot into the Debian system.

Once the Debian system is setup in the USB drive, you can issue a standard /sbin/reboot.  The updated bootloader would see a kernel image in the USB drive and boot the Debian system we have just installed.  From another machine, you can ssh into the DockStar and install additional packages, for example:

    apt-get install apache2
    apt-get install dpkg-dev
    apt-get install netatalk    

And there you have it.  A full Debian “squeeze” installation in an “armel” device.  With Apache, it becomes a full-pledged headless web server.  With the USB ports, it’s very convenient to transfer files into the system using USB thumb drives and make them available throughout your network.

 

Update 10/30/2010: Corrected pre-formatted text and added additional housekeeping commands.

This entry was posted in Computers and tagged , . Bookmark the permalink.

15 Responses to Debian on a Seagate DockStar

  1. Steven Hirsch says:

    Peter,

    I’ve been following along with your instructions for installing Debian Squeeze on my Dockstar. Some errata:

    On my x86_64 Ubuntu Lucid box, I needed to explicitly provide the full path to the appropriate script as an additional (final) argument to debootstrap. For whatever reason, it did not “know” to look in /usr/share/debootstrap/scripts.

    Your web page is munging ‘–‘ into a single ‘-‘.

    After transferring the USB stick to the Dockstar, mounting the bootstrap and chroot’ing, you give the command:

    ‘passwd root’

    This fails with “passwd: Cannot determine your user name.”

    Finally, there is enough partially incorrect and downright confusing information on the initial “cracking” of the unit and adjustment of U-Boot that you might want to consider including a step-by-step. Lots of sites covering this, all of them disagree at some level if not downright contradict each other.

    It’s busy with Stage 2 of bootstrapping as we speak. More when I get things going.

  2. Steven Hirsch says:

    It appears that the HTML authoring tool is using hi-bit characters and non-ASCII markup when presenting the various commands above! If cut and pasted into a console, results are completely bizarre and perhaps dangerous. I would strongly suggest re-doing all of them in pure ASCII before someone has a disaster.

  3. pitz says:

    @Steven
    Thanks for citing those. Adding pre-formatted text using my blog writer has always been a problem, and I’ve been looking around for the right plugins. The updated entry has been sitting in my Drafts folder for a while now, and I’ve just uploaded it. Pre-formatted text should be better, and I’ve moved the passwd command further down because it needs the second stage bootstrap completed. I’ll post another update regarding the U-Boot partition.

    • pitz says:

      Jeff Doozan’s script has made updating the U-Boot bootloader in mtd0 real easy (Step 2 above). He’s got it down to a single script that you can execute from the DockStar itself (it will download additional files, so ensure that the DockStar is connected to the net when you do this). At the time I started with the DockStar, the new U-Boot bootloader has just been completed, and other folks may still have been using the older switching method I mentioned. Jeff Doozan’s site has since then described the new method and the PlugApps site has followed the new method as well.

  4. Steven Hirsch says:

    Thanks, Peter! That will be a big help to those who follow. I still think it’s worth mentioning that the initial debootstrap on Ubuntu Lucid fails utterly unless this is appended after the repository URL:

    /usr/share/debootstrap/scripts/squeeze

    Without that, all you get is:

    E: No such script: squeeze

    when trying to execute it. There is probably some config file or environment variable to give it a default search location, but as with so much of the debian build system, you are just “supposed to know..” how to do it – certainly there’s no clue provided in the man page.

  5. alunix says:

    hello, what about the ” usb-vga cards” corp , unbuntu, virtualbox ?

    • pitz says:

      @alunix
      Running Ubuntu instead of Debian can be done on the DockStar. However, running VirtualBox probably cannot be done. Even if VirtualBox can be ported to ARM, it probably requires more compute and memory resources than the DockStar could provide.
      I have been able to successfully test a USB-monitor card. The one I tested is a Mimo 7″ USB-powered monitor (any USB monitor that uses the DisplayLink interface should work). With the right drivers and proper X11 configuration, I was able to have a small X11 monitor on my DockStar coupled with a USB keyboard and mouse.

  6. allunix says:

    ca doit etre des sequelles : virtual box n’est pas actuel sur arm . Ubuntu marche bien sur arm (smartq v7 et AC 100) , ca dépend des sd. Pour le reste les cartes usb-vga tritton lindy startech et manhattan répondent toutes par le meme identifiant apres lsusb, pas réussi à l’installer . Quelle corporation régit ce systeme comment et pourquoi ?

  7. Pingback: Hacking Seagate DockStar « Tomáš Břinčil

  8. Steffen says:

    Thanks. Worked great.

  9. Brian says:

    I am curious. After you have hacked it to run the Debian distro, can you still run the Pogoplug software? Or can you recommend a better way to enable DLNA streaming without the Pogoplug?
    Thanks.

  10. Brian says:

    Since this is documented for the Dockstar, with 4 USB ports, would it be as useful on a GoFlex Net, with only 1 USB port? What I am asking is, would I need to leave the USB drive in the unit for the Debian system to run, or is the distro installed on mtd3 allowing the removal of the drive?

    Sorry if it is a newbie question…
    Thanks.

  11. pitz says:

    Yes, you would need to leave the USB drive in the unit because that’s where Debian is installed. The Dockstar/GoFlex flash memory is only 256MB. There are some smaller distros that could fit into mtd3 and you could tweak uBoot to boot into mtd3, but it leaves very little space for additional programs. It would free up the USB port though.

  12. Matt says:

    I’ve just completed the setup of a dockstar using the above instructions and Jeff Doozan’s script and aside from a couple of user-generated snafus it all went seamlessly. Very happy indeed with my £10 NAS / SSH server!

    Thanks very much!

Leave a Reply

Your email address will not be published. Required fields are marked *