Fixing your Debian NAS from within initramfs-tools
The following article was contributed by John Cass. Note that John's instructions will also work on other NAS machines running Debian, such as QNAP devices.
I had a problem upgrading my Debian kernel to 2.6.32 on the D-Link DNS-323. The upgrade looked like it worked but on reboot I had a hung machine. I tried taking the disk out, putting it in my main machine and remaking the links in /boot to the previous kernel and initrd.img but it turns out that on the DNS-323 both kernel and initrd are actually stored in flash memory (the /boot disk files are where they are built and a useful archive but are not used during the boot process).
So I was stuck, and had to make a serial cable in order to find out what was going on. The instructions here and here were very useful and the CA-42 clone cost me 4 GBP on eBay and arrived within a couple of days. A delicate bit of soldering (and installing ckermit on my main machine) and I had a serial connection - I could finally see what was was happening.
The upshot was, during the boot process the DNS-323 failed to mount my root partition. This was because the partition was formatted ext3 and the initrd.img had not included the ext3 module. It probably did this because I had deliberately forced mounting it as ext2 in the /etc/fstab (in an attempt to limit the write access to the disk, I want it to stay in standby for a long time but that's another post). (Remark by Martin: this is a known issue with initramfs-tools.)
Anyway, having seen this, Martin was able to guide me to getting it fixed:
- First of all, I issued
modprobe ext2to get the ext2 module loaded (luckily this was included in initrd.img). - Then you can mount the root partition on /root:
mount -t ext2 /dev/sda2 /root- it will complain a bit but will work fine. - Then run
/scripts/init-bottom/udev- this moves /dev to within the new root directory. chroot /root /bin/sh- shift the root around so we are working from the proper root diskmount -t proc none /proc- mount the proc treemount -t sys none /sys- and the sys treenano /etc/fstab- edit this to change ext2 back to ext3 for the root partitionmount -t ext2 /dev/sda1 /boot- mount the boot partition if it's a different device (mine is)- Edit
/etc/initramfs-tools/modulesand add bothext2andext3- this will force their inclusion in the updated initrd.img - run
update-initramfs -uto regenerate the kernel and initrd.img - this will rebuild the files in /boot and it will useflash-kernelto put them into the flash memory umount /proc /sys /dev /boot- unmount filesystemsexit- leave the chrootumount /root- unmount the root partitionreboot
And it should all be working!
Fan control on the D-Link DNS-323
The kernel in Debian doesn't have support for the fan control chip on the D-Link DNS-323. Since some people said that their device runs quite hot after installing Debian, I've prepared a 2.6.29 based kernel that includes the fan driver.
If you want to install this kernel, edit the file /etc/apt/sources.list and add the following line:
deb http://people.debian.org/~tbm/orion lenny main
Load the key used to sign this repository so that apt can verify it:
gpg --keyserver pgp.earth.li --recv-keys 68FD549F gpg --export -a 68FD549F | apt-key add -
Now you can install the new kernel:
apt-get update apt-get install linux-image-orion5x
After a reboot, you can control the fan this way:
echo 0 > /sys/class/hwmon/hwmon?/device/pwm1 # turn it off echo 255 > /sys/class/hwmon/hwmon?/device/pwm1 # turn it to full speed
Any values between 0 and 255 will work.
According to Anselmo Luginbuhl, you should also be able to use the lm-sensors package to automatically control the fan:
"Execute pwmconfig, it will make some tests and generate the fancontrol config file. At the end of the procedure it will ask you to "Select fan output to configure, or other action:", just be sure to pass through choice "1" or it would not fill in the configuration file, save the configuration and start the daemon /etc/init.d/fancontrol.
Probably the only thing that needs some attention to get an optimal result is to choose the right parameters for max and min temperature at which the fan should start or stop to minimize the °C and the noise."
Finally, this kernel also includes some performance patches from Marvell, so you might see some performance increases too.
Debian lenny images and docs for Debian on D-Link DNS-323
After integrating Matt Palmer's installer patches for D-Link DNS-323, I have now created installer images based on Debian lenny. They will work both on the D-Link DNS-323 as well as the Conceptronic CH3SNAS. I've also written an installation guide and other information, including how to use the recovery mechanism through the serial console.
D-Link DNS-323 and Conceptronic CH3SNAS support integrated in installer
I finally had a chance today to test the patches Matt Palmer created to add D-Link DNS-323 support to the Debian installer. I tested the patches on a Conceptronic CH3SNAS which, from a hardware perspective, is a D-Link DNS-323 (rev B1). I noticed that the firmware image specifies a number for the vendor, so we have to generate different installer images for the D-Link DNS-323 and Conceptronic CH3SNAS. That was easy enough to do and I was able to install Debian without any problems.
The next steps are to write an installation guide and other documentation, and to improve the kernel (the power LED is blinking and cannot be changed, and fan control is missing).
Debian installer coming to the D-Link DNS-323
My posting about receiving a Conceptronic CH3SNAS a month ago prompted Matt Palmer to work on the installer. Matt did a fantastic job and had patches for everything within a few days: he added support for the revision B of the DNS-323 to the kernel, added code to the kernel so the MAC address is parsed from flash, and added DNS-323 support to various components of the installer. Finally, he wrote a really good porting guide that will hopefully inspire other people to port the installer to more NAS devices. Porting to another Orion based device usually doesn't take much now that we have the infrastructure in place.
While Matt's patches came too late for inclusion into the initial release of lenny, the release team seems agreeable to the idea of adding support for the D-Link DNS-323 and Conceptronic CH3SNAS to a stable update of lenny. To this end, the dns323-firmware-tools package which is needed to create proper firmware images for the DNS-323 was accepted for lenny a few days ago. Alan Fletcher also kindly agreed to make a serial cable for me, so hopefully I'll get a chance to test Matt's patches soon and integrate them into the installer. In the meantime, I created a few simple pages about Debian on the D-Link DNS-323 which I will extend once support has been integrated into the installer.
Conceptronic CH3SNAS and the D-Link DNS-323 revision B1
Conceptronic kindly sent me a CH3SNAS for my Debian porting efforts. The Conceptronic CH3SNAS is reported to be basically the same hardware as the D-Link DNS-323 but it costs slightly less. There were some reports that the CH3SNAS uses a 88F5182 chip whereas the D-Link DNS-323 uses a 88F5181 but nobody was able to confirm this for sure. As it turns out, there are two revisions of the DNS-323. Revision A1 uses a 88F5181 chip along with a separate SATA chip. Revision B1 on the other hand uses a 88F5182 which integrates SATA into the SoC itself. The CH3SNAS is equivalent to a D-Link DNS-323 revision B1. In fact, the mainboard of the CH3SNAS even says DNS-323 rev B1.
The Linux kernel from mainline only works on the DNS-323 revision A1 at the moment. Adding support for revision B1 should be trivial since you basically just need to initialize the SATA chip on the SoC and possibly adapt some other values. Unfortunately, the DNS-323 uses a very small serial connector so none of my serial cables work. If I can find someone who will make a serial cable for me, I'll fix up the kernel.
TODO list for Debian on D-Link DNS-323
Someone asked me the other day what it would take to add Debian support for the D-Link DNS-323. Since we support a number of Orion based devices in debian-installer already, adding support for another device is typically fairly easy. I don't have a D-Link DNS-323 myself, but I looked around the useful DNS-323 wiki and this is what I came up. I'm sharing this list in the hope that other people are interested in working on DNS-323 support.
- The Orion kernel in Debian has support for the D-Link DNS-323 but it needs testing. Also, some patches, such as support for the fan speed chip, are not included in the mainline kernel yet.
- flash-kernel (which writes the kernel and ramdisk to flash) needs support for the DNS-323. I actually implemented this in the meantime but it's completely untested.
- oldsys-preseed reads the network configuration from your existing firmware and uses it to configure the network for debian-installer. This also needs support for the DNS-323.
- Some tools to generate proper firmware images need to be packaged for Debian.
- The debian-installer needs to generate a boot image for the DNS-323 (easy once the tools are packaged).
- Apparently the MAC address is not set automatically in u-boot and you have to run a tool called mac_read to set it. This is problematic because at the moment there's no code to set the MAC address in d-i and to make sure the newly installed system will automatically set the MAC address. This needs some work.