{"id":115,"date":"2010-09-17T05:32:24","date_gmt":"2010-09-17T12:32:24","guid":{"rendered":"http:\/\/peterwong.net\/blog\/?p=115"},"modified":"2010-09-17T05:32:24","modified_gmt":"2010-09-17T12:32:24","slug":"debian-on-a-seagate-dockstar","status":"publish","type":"post","link":"https:\/\/peterwong.net\/blog\/debian-on-a-seagate-dockstar\/","title":{"rendered":"Debian on a Seagate DockStar"},"content":{"rendered":"<p>I bought a Seagate DockStar a couple of months ago.&#160; 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.&#160; I would have wanted something that I could install Ubuntu on, but Ubuntu does not provide support for the ARM v5 architecture.&#160; I\u2019m okay with Debian though, and Debian provides packages to this \u201carmel\u201d device even in their \u201csqueeze\u201d testing release.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"SeagateFreeAgentDockStar-2\" border=\"0\" alt=\"SeagateFreeAgentDockStar-2\" src=\"\/\/peterwong.net\/blog\/wp-content\/uploads\/2010\/09\/SeagateFreeAgentDockStar2.jpg\" width=\"324\" height=\"216\" \/> <\/p>\n<p>The DockStar has 128MB of RAM and 256MB of flash memory.&#160; 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.&#160; The factory setting has the NAND flash memory set into four partitions.&#160; The first partition mtd0 (1 MB) contains a very old U-Boot bootloader.&#160; The second partition mtd1 (4 MB) contains a Linux kernel image, and the third partition mtd2 (32 MB) contains a Linux jffs2 file system.&#160; The remaining partition mtd3 (219 MB) is unused.<\/p>\n<p>Hacking the DockStar to boot a different Linux system from a USB drive all stemmed from the instructions initially posted at <a title=\"http:\/\/ahsoftware.de\/dockstar\/\" href=\"http:\/\/ahsoftware.de\/dockstar\/\">http:\/\/ahsoftware.de\/dockstar\/<\/a>.&#160; In essence, the bootloader environment variables are changed to cause the mtd0 bootloader to chain to another bootloader that gets installed at mtd3.&#160; The installed mtd3 bootloader can then check for USB drives and boot the Linux kernel from there.<\/p>\n<p>To accommodate a fallback to the original Pogoplug environment in case the USB drive fails to boot, a \u201cswitching\u201d approach was made to the bootloader environment variables \u2013 that is, at each boot, the variables would be changed between booting the mtd1 kernel and booting a USB drive kernel.&#160; 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).&#160; 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.&#160; 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.&#160; If the USB boot fails, the USB drive can just be mounted on another machine and get fixed.<\/p>\n<p>Although it\u2019s 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.&#160; It\u2019s 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.&#160; So a one-time update to mtd0 sounds more reasonable.&#160; This also frees up mtd3 for installing other things, like maybe a very small 219 MB Linux installation.<\/p>\n<h5>Step 1.&#160; Prevent the DockStar from \u201cphoning home\u201d.<\/h5>\n<p>Out of the box, if you connect the DockStar to your network, it will retrieve firmware updates and disable ssh on the device.&#160; To prevent this, I disconnected my home router from the Internet, but had it still responding to DHCP requests.&#160; 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.&#160; 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.&#160; This is documented in <a title=\"http:\/\/ahsoftware.de\/dockstar\/\" href=\"http:\/\/ahsoftware.de\/dockstar\/\">http:\/\/ahsoftware.de\/dockstar\/<\/a>.&#160; It\u2019s been mentioned that it\u2019s better to just add a command to kill the offending process, so that other kernel modules can get loaded.&#160; But I do not trust any executable from the cloudengines directory to not \u201cphone home\u201d, so I\u2019m fine with disabling the whole script.<\/p>\n<h5>Step 2.&#160; Update the mtd0 U-Boot and environment variables.<\/h5>\n<p>Jeff Doozan has been active on getting this done easily, and great instructions are posted at <a title=\"http:\/\/jeff.doozan.com\/debian\/uboot\/\" href=\"http:\/\/jeff.doozan.com\/debian\/uboot\/\">http:\/\/jeff.doozan.com\/debian\/uboot\/<\/a> and subsequently adopted at <a title=\"http:\/\/www.plugapps.com\/index.php5?title=PlugApps:Pogoplug_Setboot\" href=\"http:\/\/www.plugapps.com\/index.php5?title=PlugApps:Pogoplug_Setboot\">http:\/\/www.plugapps.com\/index.php5?title=PlugApps:Pogoplug_Setboot<\/a><\/p>\n<h5>Step 3.&#160; Install the Debian \u201csqueeze\u201d release into a USB drive.<\/h5>\n<p>I opted to cross-install Debian\u2019s armel distribution using debootstrap.&#160; Since I was working from an Ubuntu desktop machine, my USB drive was at \/dev\/sdb.&#160; 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:<\/p>\n<pre class=\"brush: bash;\">    sudo mkfs -t ext3 \/dev\/sdb1\n    sudo mkswap \/dev\/sdb2\n    sudo mkfs -t ext3 \/dev\/sdb3<\/pre>\n<p>I obtained and used the cross-platform bootstrapper.&#160; 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.&#160; Other packages can be installed later once we get the DockStar to boot from the USB drive.<\/p>\n<pre class=\"brush: bash;\">    sudo apt-get install debootstrap\n    sudo mount \/dev\/sdb1 \/mnt\n    sudo \/usr\/sbin\/debootstrap --foreign --arch=armel \\\n        --include=ntp,usbmount,openssh-server,uboot-mkimage,linux-image-2.6.32-5-kirkwood \\\n        squeeze \/mnt http:\/\/ftp.us.debian.org\/debian\n    sudo umount \/mnt<\/pre>\n<p>Unmount the USB drive from the desktop and attach it to the DockStar.&#160; The DockStar will still boot to the Pogoplug environment since there isn\u2019t a valid U-Boot kernel image at the USB drive at this time.&#160; After ssh\u2019ing into the DockStar:<\/p>\n<pre class=\"brush: bash;\">    mount \/dev\/sda1 \/mnt\n    \/usr\/sbin\/chroot \/mnt \/bin\/bash\n    PATH=\/usr\/sbin:\/sbin:$PATH\n    mount -t proc none \/proc\n    \/debootstrap\/debootstrap --second-stage<\/pre>\n<p>Although some prebuilt kernels are available at <a title=\"http:\/\/sheeva.with-linux.com\/sheeva\/\" href=\"http:\/\/sheeva.with-linux.com\/sheeva\/\">http:\/\/sheeva.with-linux.com\/sheeva\/<\/a>, I opted to use the standard kernel from Debian:<\/p>\n<pre class=\"brush: bash;\">    mkimage -A arm -O linux -T kernel -C none -a 0x8000 -e 0x8000 \\\n        -n &quot;vmlinuz-2.6.32-5-kirkwood&quot; -d \/vmlinuz \/boot\/uImage\n    mkimage -A arm -O linux -T ramdisk -C gzip -a 0 -e 0 \\\n        -n &quot;initrd.img-2.6.32-5-kirkwood&quot; -d \/initrd.img \/boot\/uInitrd<\/pre>\n<p>I then performed some housekeeping stuff before the reboot of the DockStar:<\/p>\n<pre class=\"brush: bash;\">    echo &quot;dockstar&quot; &gt; \/etc\/hostname\n    echo &quot;LANG=C&quot; &gt; \/etc\/default\/locale\n    echo &quot;\/dev\/sda1 \/ ext3 defaults 0 1&quot; &gt;&gt; \/etc\/fstab\n    echo &quot;\/dev\/sda2 none swap sw 0 0&quot; &gt;&gt; \/etc\/fstab\n    echo &quot;none \/proc proc defaults 0 0&quot; &gt;&gt; \/etc\/fstab\n    echo &quot;auto lo&quot; &gt;&gt; \/etc\/network\/interfaces\n    echo &quot;iface lo inet loopback&quot; &gt;&gt; \/etc\/network\/interfaces\n    echo &quot;auto eth0&quot; &gt;&gt; \/etc\/network\/interfaces\n    echo &quot;iface eth0 inet dhcp&quot; &gt;&gt; \/etc\/network\/interfaces\n    echo &quot;deb http:\/\/ftp.us.debian.org\/debian squeeze main&quot; &gt;&gt; \/etc\/apt\/sources.list\n    echo &quot;deb-src http:\/\/ftp.us.debian.org\/debian squeeze main&quot; &gt;&gt; \/etc\/apt\/sources.list\n    echo &quot;America\/Los_Angeles&quot; &gt; \/etc\/timezone\n    cp \/usr\/share\/zoneinfo\/America\/Los_Angeles \/etc\/localtime\n    passwd root<\/pre>\n<h5><font style=\"font-weight: normal\" size=\"2\">I exit back to the Pogoplug-based environment and unmount the USB drive.<\/font><\/h5>\n<pre class=\"brush: bash;\">    exit\n    umount \/mnt<\/pre>\n<h5>Step 4.&#160; Boot into the Debian system.<\/h5>\n<p>Once the Debian system is setup in the USB drive, you can issue a standard <em>\/sbin\/reboot<\/em>.&#160; The updated bootloader would see a kernel image in the USB drive and boot the Debian system we have just installed.&#160; From another machine, you can ssh into the DockStar and install additional packages, for example:<\/p>\n<pre class=\"brush: bash;\">    apt-get install apache2\n    apt-get install dpkg-dev\n    apt-get install netatalk    <\/pre>\n<p>And there you have it.&#160; A full Debian \u201csqueeze\u201d installation in an \u201carmel\u201d device.&#160; With Apache, it becomes a full-pledged headless web server.&#160; With the USB ports, it\u2019s very convenient to transfer files into the system using USB thumb drives and make them available throughout your network.<\/p>\n<p>&#160;<\/p>\n<p><strong>Update 10\/30\/2010<\/strong>: Corrected pre-formatted text and added additional housekeeping commands.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I bought a Seagate DockStar a couple of months ago.&#160; 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.&#160; I would have wanted something &hellip; <a href=\"https:\/\/peterwong.net\/blog\/debian-on-a-seagate-dockstar\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[19,24],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-computers","tag-linux","tag-plug-computers"],"_links":{"self":[{"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":0,"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peterwong.net\/blog\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}