Sunday, January 21, 2007

HOWTO customize your D-Link DSM-G600 NAS with Telnet (BusyBox), iTunes server, gentoo and more.

To solve the always on storage, network attached storage [NAS], problem I choose to purchase the D-Link DSM-G600 device; in part because my tendency to stick with a the same hardware vendor. I may be naive and my demonstration is I believe that companies do more testing with their own hardware components than other hardware. The other part of the choice is that is a Gigabit NAS with a drive enclosure and with potential to plug in our external USB drives. The other, other part is that it is running Linux underneath.

I have the DSM-G600 revB and to demonstrate this last statement of it running a copy of embedded Linux, the following is the output of uname.
# uname -a
Linux NAS 2.4.21-pre4 #480 ¤­ 4¤ë 28 11:21:43 CST 2006 ppc unknown

And it looks like the below image
First step is to understand 'fun_plug'. This is a script that is called after after the DSM-G600 boots, but the user has full control over it. It resides on the drive that you've put into the enclosure. For the full background: How to fun_plug . This concept is a big seller to me, it allows customization to your heart's content.

Starting to fun_plug
(reference: Wiki Page Howto fun_plug )

There are several way to get the fun plug script on the device. I would recommend connecting via Samba from a Linux host. Most importantly you'll save yourself the hassle of Unix vs. Windows linefeeds.

(1) You'll want your DSM-G600 booted (and a drive in the enclosure).
(2) From your linux host:
mount -t smbfs -o username=admin ///HDD_a /mnt/nas
(3) Enter your password (the same as the web interface admin password).
(4) Execute:
touch /mnt/somedir/fun_plug
chmod 777 /mnt/somedir/fun_plug
(5) Customize fun_plug (open fun_plug up and do some customization) - See below
(6) Execute: umount /mnt/nas


Customization of fun_plug

There many customizations and the the limit only in your imagination . Several that seem worthy to mention are starting a telnet daemon, starting an itunes server, chrooting to a Gentoo distribution.

Starting small
output dmesg to a text file

(1) Open fun_plug with your favorite editor
emacs /mnt/nas/fun_plug
(2) Add
#!/bin/sh
dmesg > /mnt/HD_a2/dmesg.out
(3) reboot the DSM-G600

Why /mnt/HD_a2? because that is where the NAS device mounts the internal IDE drive.


Getting bigger
Telnet daemon (and more) Telnet and your DSM-G600
(1) Open fun_plug in your favorite editor
(2) enter the following
#!/bin/sh
if [ ! -e /mnt/HD_a2/ash ]
then
ln -s /mnt/HD_a2/busybox /mnt/HD_a2/ash
fi
if [ ! `grep root /etc/shadow` ]
then
echo kontroll.`grep admin /etc/shadow` >> /etc/shadow
/mnt/HD_a2/sed -i -e 's/kontroll.admin/root/' /etc/shadow
fi
/mnt/HD_a2/sed -i -e 's/root:.*/root:x:0:0:Linux User,,,:\/:\/mnt\/HD_a2\/ash/' /etc/passwd
cd /dev && /mnt/HD_a2/busybox makedevs ptyp c 2 0 0 9
cd /dev && /mnt/HD_a2/busybox makedevs ttyp c 3 0 0 9
/mnt/HD_a2/busybox telnetd &
(3) Get and extract
busybox-telnetd-1.2.1.tar.bz2 in the root folder of the DSM-G600. Download it
(4) reboot the DSM-G600

Medium sized
Firefly/mt-daapd itunes server on your DSM-G600
Step by Step: Step by Step for itunes server on DSM-G600

Slightly larger than Medium
A NFS server server on your DSM-G600
(1) Download the nfs binaries (nfs-utils-1.0.10-portmap5-nfsd.tar.gz)
(2) Unzip in an appropriate folder
(3) Add this to fun_plug
# nfs server
# Vars. Change these according to your setup
NFSROOT=/mnt/HD_a2/nas_packages/nfs

# Set up needed directories and files
if [ ! -d $NFSROOT/var/lib/nfs ]
then
mkdir -p $NFSROOT/var/lib/nfs
fi

if [ ! -d $NFSROOT/etc ]
then
mkdir -p $NFSROOT/etc
fi

if [ ! -f $NFSROOT/etc/exports ]
then
cat > $NFSROOT/etc/exports <<"EOF"
/mnt/HD_a2 192.168.0.0/24(rw)
EOF
fi

if [ ! -f $NFSROOT/etc/hosts.allow ]
then
cat > $NFSROOT/etc/hosts.allow <<"EOF"
lockd: 192.168.0.*
rquotad: 192.168.0.*
mountd: 192.168.0.*
statd: 192.168.0.*
EOF
cat > $NFSROOT/etc/hosts.deny <<"EOF"
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
EOF
fi

if [ ! -d /usr/sbin ]
then
mkdir -p /usr/sbin
fi

# Make symlinks
ln -s $NFSROOT/etc/exports /etc/
ln -s $NFSROOT/var/lib /var/
ln -s $NFSROOT/etc/hosts.* /etc/
ln -s $NFSROOT/sbin/* /usr/sbin/

# start the server
/sbin/insmod $NFSROOT/modules/nfsd.o
/usr/sbin/portmap
sleep 1
/usr/sbin/rpc.mountd
sleep 1
/usr/sbin/rpc.nfsd
sleep 1
/usr/sbin/rpc.statd
# re-export...

$NFSROOT/sbin/exportfs -ra
(4) Reboot the DSM-G600.

Reference (Forum post)


Big and Bold
chroot into Gentoo on DSM-G600
Step by Step: Chroot to Gentoo

There you have it, the world is yours now that you are in Gentoo. Enjoy it.

References:
DSM-G600 revB Hack Forum
A well organized Wiki about the DSM-G600 revB

keywords:D-Link DSM-G600, dlink DSM-G600, linux, NAS, configuring, fun_plug, fun plug, Customizing DSM-G600, embedded linux on DSM-G600, tweaking DSM-G600, itunes DSM-G600, telnet DSM-G600, gentoo DSM-G600, D-Link NAS, gentoo, embedded linux.

6 comments:

Anonymous said...

This is really cool. Its a little disturbing that if someone left there dsm-g600 on the internet with full r/w ftp access on the next reboot they would lose control of there dsm. But still very cool.

Paul Cooley said...

One should always be careful on what they stick on the internet ;)

Anonymous said...

FYI: gpl-violations.org project prevails in court case on GPL violation by D-Link

Visit gpl-violations.org project news page to read the details.

Tezuya

ecommercewebmaster12 said...

In order to make money online in the best possible way, you need to figure out effective business strategies and we can help you with that. We, at Infinity Informations, are well known all over for providing efficient business solutions to our clients all over the world and as soon as you utilize our ecommerce solutions for the purpose of facilitating your online business, you would notice sudden and tremendous growth in your ecommerce venture. So, contact http://www.infyecommercesolution.com immediately and facilitate your online business.

ed said...

一夜情聊天室,一夜情,情色聊天室,情色,美女交友,交友,AIO交友愛情館,AIO,成人交友,愛情公寓,做愛影片,做愛,性愛,微風成人區,微風成人,嘟嘟成人網,成人影片,成人,成人貼圖,18成人,成人圖片區,成人圖片,成人影城,成人小說,成人文章,成人網站,成人論壇,情色貼圖,色情貼圖,色情A片,A片,色情小說,情色小說,情色文學,寄情築園小遊戲, 情色A片,色情影片,AV女優,AV,A漫,免費A片,A片下載

情色,A片,AIO,AV,日本AV,色情A片,AV女優,A漫,免費A片,A片下載,情色A片,哈啦聊天室,UT聊天室,聊天室,豆豆聊天室,色情聊天室,尋夢園聊天室,080視訊聊天室,080聊天室,080苗栗人聊天室,免費視訊聊天,上班族聊天室,080中部人聊天室,視訊聊天室,視訊聊天,成人聊天室,一夜情聊天室,辣妹視訊,情色視訊,成人,成人影片,成人光碟,成人影城,自拍

A片,AIO,AV,日本AV,色情A片,AV女優,A漫,AIO交友愛情館,線上A片,免費A片,A片下載,情色A片,微風成人,嘟嘟成人網,成人,成人影片,成人光碟,成人影城,成人交友,愛情公寓,色情聊天室,情色貼圖,色情,色情影片,做愛,情色,哈啦聊天室,聊天室,UT聊天室,豆豆聊天室,尋夢園聊天室,080視訊聊天室,080聊天室,080苗栗人聊天室,自拍,性愛

情趣用品,情趣用品,情趣,情趣,A片,A片,情色,A片,A片,情色,情趣用品,情趣用品,A片,A片,情色,情色

情色視訊,美女視訊,辣妹視訊,視訊聊天室,視訊交友網,免費視訊聊天,視訊交友90739,視訊,免費視訊,情人視訊網,視訊辣妹,影音視訊聊天室,視訊交友,視訊聊天,免費視訊聊天室,成人視訊,UT聊天室,聊天室,豆豆聊天室,色情聊天室,尋夢園聊天室,聊天室尋夢園,080聊天室,080苗栗人聊天室,上班族聊天室,小高聊天室

6K聊天室,080中部人聊天室,聊天室交友,成人聊天室,中部人聊天室,情色聊天室,AV女優,AV,A片,情人薇珍妮,愛情公寓,情色,情色貼圖,情色文學,色情小說,色情,寄情築園小遊戲,AIO交友愛情館,情色電影,一葉情貼圖片區,色情遊戲

言情小說,情色論壇,色情網站,微風成人,成人電影,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,微風成人區,成人網站,免費影片,色情影片,自拍,hilive,做愛,微風成人,微風論壇,AIO

fundoo said...

Thanks for the information, we will add this story to our blog, as we have a audience in this sector that loves reading like this” ecommerce solutions