In this post I will explain how you can boot the MediaHub 300/400 series with Debian Wheezy and a custom kernel.
What’s different regarding your older post?
I’ve managed to cross-compile a 3.8.13 kernel and got it booting on the NAS, therefore, there are no limitations regarding the Debian flavor you want to install and as a result we will be installing Debian Wheezy on the device.
Also the kernel has boot parameters set that will override the uBoot ones, therefore we only have to place the kernel image on the small partition and afterwards boot the system using the filesystem on the bigger partition (3rd).
The kernel is stuck at 3.8.13 at the moment and will not likely to get any support in newer kernel releases due to the fact that the kernel now uses Device Tree to configure all devices (means uBoot hands over it’s configuration to the kernel), which the uBoot on the MediaHub does not support, but this kernel should be sufficient for the next upcoming releases of Debian.
I’ve prepared a basic filesystem containing Debian Wheezy and have installed some basic administration tools:
– archive/package utilities
– SSH server
– NTP sync
I’ve included support for the system hardware as builtin modules in the kernel and the rest as modules, because uBoot is not able to load a kernel bigger than 2Mb. Some of the separate modules I’ve included are:
– USB disk/stick support
– Ext4, JFS and XFS support
– NTFS support
– NFS and CIFS support
– Appletalk support
– Preemption model set to “Server”
– I/O scheduler set to “noop”
(I’ve included the kernel sources with the kernel config on my downloads page, this is exclusively for use with the Mediahub so it can be rebuilt with the options you want)
You can use any 3,5″ SATA harddrive for this installation up to 2TB (anything bigger cannot be used due to the limitations of the 32-bit CPU). You also need to download the 2 mediahub files from my Downloads section (bottom of page).
Preparing the harddisk:
We now have to partition the harddisk for usage in the NAS, therefore the following partitions have to be created (I assume you have some knowledge on partitioning, formatting and mounting disks):
partition 1 - swap - 256MB
partition 2 - ext3 - 100MB (kernel)
partition 3 - ext4 - 20GB (rootfs)
partition 4 - ext4 - rest of remaing space for data
Partition 2 must be ext2 or ext3, else uBoot will not be able to load the kernel image from the disk as it does not support ext4 or any other filesystem and it may not exceed 300MB of space, else uBoot will not recognize the partition and it’s contents.
Partition 3 is set to 20GB for the root filesystem, you may change this to a higher or lower value or even all the space remaining on disk ignoring partition 4. I always like to separate the data partition from the OS partition so a reinstall can be done much more efficiently!
Mount the partitions 2 and 3 on your local machine and move on to the next step.
Installing the kernel:
Extract the contents of the “mediahub_boot.tgz” package to the root of partition 2, the 100MB partition.
Installing the filesystem:
Extract the contents of the “mediahub_fs.tgz” package to the root of partition 3, the 20GB partition.
Now modify the network interfaces file, because the installation was performed on my device which was eth0, but yours has a different MAC address, therefore will be eth1. Please move in the mounted directory for partition 3 and edit the following file:
Rename all “eth0” instances to “eth1”.
I’ve updated the archives with a newer kernel and fixed some filesystem issues, the renaming step is unnecessary anymore!
After the contents have been extracted, unmount the partitions. Preparation is now finished!
Booting the NAS
Place the prepared harddisk in your NAS, connect the network cable and plug in the power. The NAS should now be able to boot and boot time will take around 2 minutes (there is a loading delay in uBoot for the kernel).
Connecting to the NAS
I’ve set up the network interface to use DHCP, you should be able to obtain the IP-address taken by the NAS by looking at the DHCP table of your router or run a nmap for open SSH ports on your subnet.
Once you know the IP-address you should be able to log in via SSH with the root account, it’s password is “root”.
I advise you to change this immediately via the “passwd root” command.
You should now be connected to your NAS via SSH and be able to install all necessary software you want to run on the device, some things worth changing:
– The generated SSH hostkey
– The used APT mirror (is now set to Holland)
– The used timezone (is now set to Amsterdam)
– The used locales (is currently en_US and nl_NL using UTF-8)
– The root password
– Set the IP address to a static one
Using a 2nd disk:
If you plan to use 2 disks in the NAS you have to place the disk you’ve prepared in slot 2. uBoot tries to boot from the first SATA disk, but the slot numbers on the case itself and the mainboard are switched, so slot 1 on the case is slot 2 on the mainboard and vice versa. One booted you are able to partition the second disk as usual.
Functions not working:
The Mediahub has a reset and backup button which are GPIO controlled, the support of these buttons is currently not available and will not work, you might be able to create triggers yourself to perform certain tasks when pressing these buttons. Also the small LCD screen on the 400 series is not supported for now.
I recently became in posession of a NMH400 (thanks to Joost which is on this blog as well!), my software boots on the NMH400 just fine and the cardreader is working out of the box (it’s connected to an internal USB connector). The LCD screen is not controlled via a kernel module by the looks of it and it seems that some software is controlling this screen but I have yet to find out what this is.
I’ve updated the archives with the following fixes:
– Kernel on the NMH300 should now set the powerled to a fixed state (it stops blinking after booting has completely finished).
– Kernel on the NMH300 should now handle the harddisk leds the proper way, during I/O operations the appropriate led will blink blue. The earlier lit red led is now deactivated.
– The kernel still boots on the NMH400, but no actions are taken to fix leds etcetera, a separate kernel needs to be built for this device.
– The network fix from Simon Quigley (thanks!) regarding the removal of the interfaces caching file has been implemented, therefore the renaming of the interface name during the setup process is now unnecessary!
44 responses to “Install Debian Wheezy and custom kernel on the Linksys MediaHub”
i am new to debian and nas. i miss time machine support, faster transfer rates, auto mount and plex app for nas support maybe.
what are the advantages of your install? i have it connected to a mac for watching films.
what are other best uses?
I think you are misunderstanding the options of the device, this is a simple NAS, using it for Timemachine is possible, but some hacks are needed and I don’t support it on this device, to be honest, I don’t recommend using this NAS for Timemachine, it’s just not fast enough if you have lots of data.
Faster transfer rates, this is a 400MHz CPU which is not that powerful anymore, the maximum transfer rates you will achieve on this device is around 16MB/sec for reading and 10MB/sec for writing. Whilst disks are faster than this, the CPU is the limiting factor here.
Using the NAs for streaming purposes should work just fine if you use NFS or CIFS, I’ve used this NAS for this purpose in the past and works fine.
The advantage of my install is that you have a fairly recent kernel with the newest Debian version available with SSH access, so you have total control over the device and it’s purpose.
Hi! Congrats for your kernel! It would be great if you make this piece of hardware works better.
What are the advantages/disadventages installing Debian? I miss better connection with mac os x, faster transference rates, time machine support…
Now I only like itunes compatibility.
Hi! Currently, only Debian works well out of the box, but as is the case with regular Debian, this is completely bare. I’ve added some essential tools for managing the NAS, but all other software like Samba, NFS, DAAP and CUPS needs to be installed and configured manually by you.
There are other Linux flavors as well, like Arch, but I didn’t spend any time in testing this distro for now, maybe later on I’ll try to support other distro’s as well. Please keep in mind that the CPU is ARMv5 which is pretty old, so there are only a couple of Linux flavors that support this CPU at this time. For instance, to use Ubuntu you’ll need at least a ARMv7 CPU.
Hi, this is awesome. I’ve just got it booted up on my NMH4xx.
If you remove the /etc/udev/rules.d/70-persistent-net.rules from the image, then when the unit boots up it will detect the interface, and it will become eth0, then there’s no need to change the interfaces file. (That files is where it caches the MAC address so devices with multiple interfaces will always be named the same after reboots).
I’m working to get the LCD working, by grabbing the files from the stock firmware (under /usr/spbin/lcdagent), which requires some of the web interface files (/var/www/htdocs/fw), and some stuff under /etc/conf and /etc/inc, but it looks like the actual LCD requires devices to be created, and I think these rely on the kernel module “mod_nmh3xx”, and I doubt we’ll find the source for that anywhere to compile against your kernel version.
I’ll let you know how I go, but so far I’m pretty happy being able to SSH into the unit, that’s what I’ve wanted for a long time. Now I’m trying to work out how to create a RAID 0 or 1 on it, since you’re missing the LVM tools. Any tips for cross compiling stuff for this architecture?
Hi, thanks for the udev fix! I’ve updated the image so the renaming part is not needed anymore! LVM and softraid is supported within the kernel, just install the appropriate tools using the APT package manager!
I poked around a bit more, and found that the screen is controlled by the lcdagent, which seems to want an xml engine running that parses system information into an xml file in the tmp directory. I’m not sure what starts/controls the xml engine yet.
I also found the “fuji” binary, which running strings across reveals some interesting information, that it uses the /dev/nmh_mem to manipulate settings, and I also saw references to uboot in there, so I’m not sure if it might be possible to update uboot in the flash on the device.
Checking in the tar ball of GPL code from Linksys, I find that they have included the source of mod_nmh3xx, including code for the leds, buttons, fan, a watchdog timer etc, so it would be nice to have this working again. I’m not sure what’s required to modify it so it compiles under the newer kernel.
I see on your other page about this unit you did some speed tests using mdadm, but I’m having issues compiling the md module. I put the kernel source you provided on the unit, and installed build-essentials, but attempting to compile anything to do with the mdadm driver results in a compiler internal error.
Can you give me your compiled mdadm driver, or tell me how you compiled it?
I did some more work on this. I managed to compile the mdadm driver, however using GCC4.6 would crash (segfaults and internal errors), I couldn’t even compile HelloWorld with it, but upgrading to 4.7 fixed this.
I also had to do it natively, which took hours (to compile the whole kernel), because I couldn’t get cross compiling to compile for the correct arch, it kept outputting files for ARMv7 instead of ARMv5, and I couldn’t work out how to fix that. Can you give me some information on how to cross compile to ARMv5?
Now I’ve got the md module loaded, and created the mdadm devices. Next I’m going to try to compile the NMH module, to get the buttons and LCD working, and so I can stop the power LED from flashing.
I’ve also discovered the NMH has a flash chip it uses to store the config. The fstab from the stock firmware mounts /dev/mtdblock3 under /etc/conf. I’m trying to work out how to mount this (to recover the config from the stock firmware), but even though MTD support is compiled in the kernel, and for the Orion SoC, it doesn’t seem to detect it, and creating the dev nodes manually doesn’t work. I suppose this isn’t the end of the world, but it would be nice to have that functionality, so I could backup the config of the device into the flash.
Thanks for your findings regarding the LCD screen! For now it will be hard to make it work I guess. The mod_nmh3xx don’t seem to be kernel patch files and are regular C files, but compiling them isn’t working, so we have to figure out what to do with it first.
For LVM / mdadm, why don’t you use the precompiled binaries available within the Debian repositories? I’ve tested softraid using mdadm and doesn’t seem to give any problems when I tested it although the performance is horrible. So maybe you want to use LVM for linking disks together for more space, but don’t use software RAID on the NAS, it’s just not powerful enough :(. The SoC has a hardware accelerated XOR engine, but is only usable for RAID5 calculations which is useless on this NAS.
About the flash ROM, I’ve looked into the original kernel sources and I’ve adopted some settings but I’ve never looked into this process to see if it actually worked as the flash chip is useless for me. The size is pretty small to do anything useful with it.
Guess I have to sit down again for the device and see what I can discover / patch again on the kernel to make other thinfs work as well. I guess you want to help and participate in this?