Running NetBSD on the LG-N2R1D NAS-family

December 15, 2011 posted by Reinoud Zandijk


When my late server suddenly broke down i decided it needed replacement. I decided to go for a NAS for its low energy usage, small form factor and it needed to run additional services like http/apache, mysql, named, ntpd, postfix + postgrey + fetchmail, dhcp, serve my /home, /var/mail on NFS to the other machines etc.

My eye fell on the LG NAS-N2R1D for it features easy 2 disc hot swapable SATA (when it gets supported in NetBSD of course), possibilities for RAID0/1, Gigabit ethernet port, eSATA support, plenty of USB connectors, USB based cardreader and its DVD burner(!). There was also a variant with a BluRay burner but since i already got an external one i went for the DVD burner variant.

Modding and hacking

Unpacked, i powered up the machine and inspected its fairly extensive webinterface. Regretfully it lacked almost all the needed services other than apache and dhcp since it apparently was more tailored for Windows networking with samba.

Since all my systems run NetBSD anyway, the lack of these features meant it had to run NetBSD one way or another!

So i opened the box... and blew away my warranty. As expected i found a 4 pads on the PCB that really looked like a developer's serial port hookup. Some searching on the web confirmed my guess. Someone had figured out that it was indeed one of the SoC serial ports but on TTL level. I had an USB to TTL serial card around and soldered it to the board... After fixing a Rx/Tx wire mixup and trying out some common speeds, i got a prompt! See for dissemble instructions and information on how to solder the serial port here.

Hooking it up to a machine, it turned out to run a custom version of Linux and the PCB turned out to be an 800 Mhz ARM9 Marvell 88F6192 SoC. Lucky for me, NetBSD already supported a generic Marvell NAS reference board so i guessed this board shouldn't be that different.

After battling with the uboot firmware for a while, i finally noticed a NetBSD entry in the config due to its firmware also running on other boards. Use setenv on the uboot prompt and set `netbsd_en' to yes.

Uboot can only boot special images, normally postfixed with .ub. These are just the kernel with a uboot header. Those files are created by the evbarm port as part of the kernel build.

In my porting effort i set up a MARVELL_NAS kernel and fiddled with it until it got a serial console and netbooting. It failed to boot out of the box of course and i had to disable a few devices to get it to work. When it finally worked as expected i started adding stuff until i got a new LG_NAS kernel config.

Installing NetBSD on the NAS

Since uboot can also netboot, the easiest way to bootstrap NetBSD is with a network boot and reformat the disc and install NetBSD on it:

tftp 0x800000 netbsd.ub; setenv bootargs nfsroot=$(serverip):$(rootpath) -a; bootm 0x800000
(NetBSD boots)
(NetBSD asks for root info)
(Install NetBSD)

Format the disc with disklabel in at least two partitions: One small 32 Mb ext2fs partition and the rest as you like. I used this on a 1Tb disc :

8 partitions:
# size offset fstype [fsize bsize cpg/sgs]
a: 65536 63 Linux Ext2 0 0 # (Cyl. 0*- 65*)
b: 524288 65599 swap # (Cyl. 65*- 585*)
c: 1953525168 0 unused 0 0 # (Cyl. 0 - 1938020)
e: 1952935281 589887 4.2BSD 0 0 0 # (Cyl. 585*- 1938020)

After the install, its time to set some vars (use the normal shell escapes, especially for ';') :

netbsd_boot=bootm $(netbsd_add) $(bootargs)
netbsd_bootcmd=run netbsd_get ; run netbsd_set_args ; run netbsd_boot
netbsd_set_args=setenv bootargs rootdev=$(netbsd_rootdev) $(netbsd_netconfig)
bootcmd=run netbsd_bootcmd
netbsd_get=ide reset; ext2load ide 1 $(netbsd_add) $(image_name)

and save them with `saveenv'!

The file `netbsd.ub' (prefix / is mandatory!) is then loaded from the ext2 partition i normally mount on /boot for easy updating. Note that the /netbsd file needs to exist for kmem grovelers to work.



Post a Comment:
Comments are closed for this entry.