A couple years ago I bought the Thecus N7700, a low-end NAS with 7 hot swappable SATA disks. I wanted an affordable solution that would give me a lot of capacity at home for raw photos, videos, and ISOs/VMs, so I filled it with consumer-grade 2 TB disks in RAID 5 configuration. Unfortunately, I would soon discover that Thecus has a very short “compatibility list” of drives they test with, all of them enterprise-grade disks, and the drives I bought were not on it. On at least a dozen occasions, the system reported I/O errors with one or more disks. I would reboot and rebuild the RAID, then check the SMART data, just to discover the disks had experienced no errors at all – it was a firmware issue. Despite releasing many updates to the firmware since then (several of which claimed to fix this issue), the problem persists.
Fortunately, the machine is x86 and made entirely of commodity parts, so it’s possible to install any OS I like on it. The catch is, it has no VGA out. However, it does have integrated video on the motherboard – they just didn’t solder a connector onto it. Following the directions here, I disassembled one end of a VGA cable (first I used a flathead screwdriver to push off the plastic cover, then used some needlenose pliers to twist the metal tabs until they broke off, exposing the pins). I then poked the pins through a small piece of paper, for insulation, and inserted them directly into the motherboard. The VGA holes are at the back of the motherboard near the other connectors. I was successful in getting VGA out, although it took quite a bit of fiddling with the angle of the cable to make it touch things just right – in the future I may want to solder a connector onto the board for convenience. Once I’d done this, I could plug in a USB keyboard and hit DEL to enter BIOS at boot and turn on USB booting – note that you do not want to set USB-CDROM/USB-FDD etc. as the boot device, but rather you must plug in a USB flash drive first, which the BIOS will correctly see as a disk device, and then change the priority of boot disk devices. After that, I could set up the USB flash drive with any installer or OS I wanted – I used an 8 GB flash drive. There are alternative ways to getting another OS to run on the board – like replacing the internal 128 MB flash drive – but it’s much easier to diagnose boot issues if you can see the VGA out.
I started out by installing FreeNAS, just to discover it doesn’t support the N7700′s SATA controller. Next I tried Openfiler but couldn’t get it to boot from USB (although this might be possible). Finally I decided to go with the freshly-released Ubuntu Server 11.10 Linux. I used Unetbootin to put its installer ISO onto my USB key, and sure enough it could see all my disks. Catch is, I wanted to install it to the USB key, but I was using that for the installer. The internal flash drive was too small to install to (128 MB). The Thecus N7700 only has two USB ports – if I had a second USB flash drive and a USB hub handy, I would’ve just installed directly onto the second USB key (I recommend trying this), but I didn’t, so instead I installed onto a small root partition on one of my RAID hard drives, sized to match the USB flash drive. It failed to install Grub to the MBR during install, but I ignored this. Afterwards, I attached both the flash drive and the disk to my PC, repartitioned the flash drive in Parted Magic, and then used Clonezilla to copy the installed partition from my hard disk to the flash drive. There was a small catch to this: I had to create a tiny 1 MB partition before my Ubuntu partition and mark it as a BIOS boot partition for Grub. Then, I used the Ubuntu 11.10 Desktop Live CD in live mode to chroot into the Ubuntu filesystem (see this guide to chrooting involving mount -o bind) and run “install-grub /dev/sdb”, where /dev/sdb was my USB flash device, and “update-grub”. At this point the device was bootable.
Once I had booted up the device, I had to fix some annoyances. First of all, device names of disks can change between boots, particularly if you remove or add disks. To deal with this I created /etc/udev/rules.d/nas-disk.rules with the following contents:
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0000000000000000-lun-0", SYMLINK+="nasa"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0100000000000000-lun-0", SYMLINK+="nasb"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0200000000000000-lun-0", SYMLINK+="nasc"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:04:00.0-sas-0x0300000000000000-lun-0", SYMLINK+="nasd"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:05:00.0-sas-0x0000000000000000-lun-0", SYMLINK+="nase"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:05:00.0-sas-0x0100000000000000-lun-0", SYMLINK+="nasf"
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_PATH}=="pci-0000:05:00.0-sas-0x0200000000000000-lun-0", SYMLINK+="nasg"
Now, /dev/nasa thorugh /dev/nasg referred to my seven disks in order from the top down. Warning: if you mount any volumes in your /etc/fstab, make sure you include the “nobootwait” option. Otherwise, if a volume fails to mount for any reason during boot, it will just sit there waiting for you to press S, before even starting the SSH server.
Once I had done this I installed a number of useful packages:
- sshd: Already installed during installation, lets me administer the machine over the network with the box closed and no VGA cable attached.
- mdadm: Needed for software RAID support.
- xfsprogs reiserfsprogs btrfs-tools hfsprogs: Tool support for additional filesystems.
- nfs-kernel-server: Lets me share files with other UNIX machines over NFS. (see this guide – I found it useful to set no_root_squash so my client had free access)
- samba: Installed during installation, lets me share files with Windows clients.
- webmin: Gives me a remote web administration interface on port 10000 that I can use to, among other things, create, modify, and destroy RAID partitions.
- smartmontools: Allows me to regularly check the SMART data of my disks and run self-tests, and report any problems.
- transmission-daemon: Provides a web interface for BitTorrent downloads. Requires some configuration, see this guide.
- sysstat: Includes iostat, which lets me view current disk activity.
- open-iscsi open-iscsi-tools: iSCSI support (not currently using this but I used to use iSCSI exclusively and manage the volume as NTFS on Windows clients).
At first I considered running btrfs on my NAS, which is a very promising up-and-coming competitor to ZFS, but there’s no official stable release quite yet and I’m uncertain about performance. ZFS itself is only available in alpha form on Linux, primarily due to licensing issues. I ended up running XFS because it’s mature and handles volumes with many large files well.
Some notes on RAID: I used software RAID 5 over 5 disks with mdadm. It starts in degraded state, then rebuilds, and will send mail to root about this, so don’t be alarmed. You can use it right away if you want (although this slows down rebuild), and you can monitor the rebuild process via SSH with while true; do cat /proc/mdstat; sleep 5; done.
Note that if you do modify the OS of your Thecus N7700, the disk LEDs and LCD display will no longer work. The LCD display will show “Running self tests” forever, and the blue and red LEDs will also remain on and not flashing indefinitely. I believe a sufficiently clever person could reverse engineer their interface and provide a command-line utility or daemon to control them, which would be quite handy, but I don’t need it. The power and network LEDs should still work fine.
Note that if you insert or remove drives, or boot without the USB flash drive attached, you may accidentally alter the disk boot priority order in BIOS, causing the internal flash drive to gain priority, or causing the flash drive to fall off the list. If this happens, you still need the VGA cable to get back into BIOS to fix it. To mitigate this problem, I recommend completely erasing the internal flash drive by filling it with zeros: dd if=/dev/zero of=/dev/sda bs=128M (make sure it’s /dev/sda on your machine though!)
Warning: When you close back up the case, remember to plug back in the case fans. Seven disks generate a lot of heat and you will fry your machine if you don’t do this. Sadly I destroyed my Thecus this way only a single day after getting my RAID set up, so I can’t say much about long-term use.
Let me know if you have any problems with this, and please share your own experiences! To close this out, here is a bunch of data about the Thecus N7700 system that you may find useful if you’re trying to get another distro or OS running on it:
lspci:
00:00.0 Host bridge: Intel Corporation Mobile 945GME Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GME Express Integrated Graphics Controller (rev 03)
00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev 02)
00:1c.2 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 3 (rev 02)
00:1c.3 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 4 (rev 02)
00:1c.4 PCI bridge: Intel Corporation 82801GR/GH/GHM (ICH7 Family) PCI Express Port 5 (rev 02)
00:1c.5 PCI bridge: Intel Corporation 82801GR/GH/GHM (ICH7 Family) PCI Express Port 6 (rev 02)
00:1d.0 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3 (rev 02)
00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 (rev 02)
00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)
00:1f.0 ISA bridge: Intel Corporation 82801GHM (ICH7-M DH) LPC Interface Bridge (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA AHCI Controller (rev 02)
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 02)
02:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
04:00.0 RAID bus controller: Marvell Technology Group Ltd. 88SE6440 SAS/SATA PCIe controller (rev 02)
05:00.0 RAID bus controller: Marvell Technology Group Ltd. 88SE6440 SAS/SATA PCIe controller (rev 02)
/proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 14
model name : Intel(R) Celeron(R) M CPU 440 @ 1.86GHz
stepping : 12
cpu MHz : 1866.707
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx constant_tsc up arch_perfmon bts aperfmperf pni monitor tm2 xtpr pdcm dts
bogomips : 3733.41
clflush size : 64
cache_alignment : 64
address sizes : 32 bits physical, 32 bits virtual
power management:
/proc/meminfo
MemTotal: 1023884 kB
lsmod
Module Size Used by
serio_raw 12990 0
i915 505108 1
drm_kms_helper 32889 1 i915
drm 192226 2 i915,drm_kms_helper
i2c_algo_bit 13199 1 i915
video 18908 1 i915
lp 17455 0
parport 40930 1 lp
raid10 30270 0
usb_storage 44173 1
raid456 61518 1
async_raid6_recov 12906 1 raid456
async_pq 12959 2 raid456,async_raid6_recov
uas 17699 0
ahci 21634 0
libahci 25727 1 ahci
mvsas 51615 8
libsas 62786 1 mvsas
scsi_transport_sas 34482 2 mvsas,libsas
e1000e 139775 0
raid6_pq 88205 2 async_raid6_recov,async_pq
async_xor 12738 3 raid456,async_raid6_recov,async_pq
xor 21860 1 async_xor
async_memcpy 12481 2 raid456,async_raid6_recov
async_tx 13123 5 raid456,async_raid6_recov,async_pq,async_xor,async_memcpy
raid1 26291 0
raid0 17067 0
multipath 12977 0
linear 12792 0
smartctl -a /dev/hda (info about the internal flash drive)
Device Model: 128MB ATA Flash Disk
Serial Number: C191100004A12b39GGwP
Firmware Version: AD B512D
User Capacity: 128,057,344 bytes [128 MB]
Sector Size: 512 bytes logical/physical
ATA Version is: 6
ATA Standard is: ATA/ATAPI-6 T13 1410D revision 3a
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
/proc/ioports
0000-0cf7 : PCI Bus 0000:00
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
0070-0073 : rtc0
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : 0000:00:1f.1
0170-0177 : ata_piix
01f0-01f7 : 0000:00:1f.1
01f0-01f7 : ata_piix
02f8-02ff : serial
0376-0376 : 0000:00:1f.1
0376-0376 : ata_piix
03f6-03f6 : 0000:00:1f.1
03f6-03f6 : ata_piix
03f8-03ff : serial
0400-04bf : pnp 00:08
0400-0403 : ACPI PM1a_EVT_BLK
0404-0405 : ACPI PM1a_CNT_BLK
0408-040b : ACPI PM_TMR
0428-042f : ACPI GPE0_BLK
04d0-04d1 : pnp 00:01
0500-051f : 0000:00:1f.3
0680-06ff : pnp 00:01
0880-088f : pnp 00:01
0cf8-0cff : PCI conf1
0d00-ffff : PCI Bus 0000:00
8000-8fff : PCI Bus 0000:04
8f00-8f7f : 0000:04:00.0
8f00-8f7f : mvsas
9000-9fff : PCI Bus 0000:03
9f00-9f1f : 0000:03:00.0
a000-afff : PCI Bus 0000:02
af00-af1f : 0000:02:00.0
b000-bfff : PCI Bus 0000:01
c000-cfff : PCI Bus 0000:05
cf00-cf7f : 0000:05:00.0
cf00-cf7f : mvsas
d000-dfff : PCI Bus 0000:06
f300-f30f : 0000:00:1f.2
f300-f30f : ahci
f400-f403 : 0000:00:1f.2
f400-f403 : ahci
f500-f507 : 0000:00:1f.2
f500-f507 : ahci
f600-f603 : 0000:00:1f.2
f600-f603 : ahci
f700-f707 : 0000:00:1f.2
f700-f707 : ahci
f800-f80f : 0000:00:1f.1
f800-f80f : ata_piix
fb00-fb1f : 0000:00:1d.3
fb00-fb1f : uhci_hcd
fc00-fc1f : 0000:00:1d.2
fc00-fc1f : uhci_hcd
fd00-fd1f : 0000:00:1d.1
fd00-fd1f : uhci_hcd
fe00-fe1f : 0000:00:1d.0
fe00-fe1f : uhci_hcd
ff00-ff07 : 0000:00:02.0
/proc/iomem
00000000-0000ffff : reserved
00010000-0009a7ff : System RAM
0009a800-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
000a0000-000bffff : Video RAM area
000c0000-000dffff : PCI Bus 0000:00
000c0000-000c7fff : Video ROM
000e0000-000effff : pnp 00:0b
000f0000-000fffff : reserved
000f0000-000fffff : System ROM
00100000-3fddffff : System RAM
01000000-01534783 : Kernel code
01534784-017bbd7f : Kernel data
01870000-01946fff : Kernel bss
3fde0000-3fde2fff : ACPI Non-volatile Storage
3fde3000-3fdeffff : ACPI Tables
3fdf0000-3fdfffff : reserved
3fe00000-febfffff : PCI Bus 0000:00
d0000000-dfffffff : 0000:00:02.0
e0000000-efffffff : PCI MMCONFIG 0000 [bus 00-ff]
e0000000-efffffff : reserved
e0000000-efffffff : pnp 00:0a
fd300000-fd3fffff : PCI Bus 0000:02
fd400000-fd4fffff : PCI Bus 0000:02
fd4c0000-fd4dffff : 0000:02:00.0
fd4c0000-fd4dffff : e1000e
fd4fc000-fd4fffff : 0000:02:00.0
fd4fc000-fd4fffff : e1000e
fd500000-fd5fffff : PCI Bus 0000:01
fd600000-fd6fffff : PCI Bus 0000:06
fd700000-fd7fffff : PCI Bus 0000:06
fd800000-fd8fffff : PCI Bus 0000:01
fd900000-fd9fffff : PCI Bus 0000:05
fd900000-fd93ffff : 0000:05:00.0
fda00000-fdafffff : PCI Bus 0000:05
fdaff000-fdafffff : 0000:05:00.0
fdaff000-fdafffff : mvsas
fdb00000-fdbfffff : PCI Bus 0000:04
fdb00000-fdb3ffff : 0000:04:00.0
fdc00000-fdcfffff : PCI Bus 0000:04
fdcff000-fdcfffff : 0000:04:00.0
fdcff000-fdcfffff : mvsas
fdd00000-fddfffff : PCI Bus 0000:03
fde00000-fdefffff : PCI Bus 0000:03
fdec0000-fdedffff : 0000:03:00.0
fdec0000-fdedffff : e1000e
fdefc000-fdefffff : 0000:03:00.0
fdefc000-fdefffff : e1000e
fdf00000-fdf7ffff : 0000:00:02.0
fdf80000-fdfbffff : 0000:00:02.0
fdffc000-fdffc3ff : 0000:00:1f.2
fdffc000-fdffc3ff : ahci
fdfff000-fdfff3ff : 0000:00:1d.7
fdfff000-fdfff3ff : ehci_hcd
fec00000-ffffffff : reserved
fec00000-fec003ff : IOAPIC 0
fed13000-fed1dfff : pnp 00:0b
fed20000-fed8ffff : pnp 00:0b
fee00000-fee00fff : Local APIC
fee00000-fee00fff : pnp 00:0b
ffb00000-ffb7ffff : pnp 00:0b
fff00000-ffffffff : pnp 00:0b
/proc/interrupts
CPU0
0: 304 IO-APIC-edge timer
1: 4 IO-APIC-edge i8042
8: 1 IO-APIC-edge rtc0
9: 0 IO-APIC-fasteoi acpi
14: 23215 IO-APIC-edge ata_piix
15: 0 IO-APIC-edge ata_piix
16: 88518197 IO-APIC-fasteoi uhci_hcd:usb5, mvsas, i915
17: 92740547 IO-APIC-fasteoi mvsas
18: 0 IO-APIC-fasteoi uhci_hcd:usb4
19: 0 IO-APIC-fasteoi uhci_hcd:usb3
23: 1014224 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb2
48: 0 PCI-MSI-edge ahci
49: 745524 PCI-MSI-edge eth1-rx-0
50: 667535 PCI-MSI-edge eth1-tx-0
51: 3 PCI-MSI-edge eth1
NMI: 0 Non-maskable interrupts
LOC: 19023450 Local timer interrupts
SPU: 0 Spurious interrupts
PMI: 0 Performance monitoring interrupts
IWI: 0 IRQ work interrupts
RES: 0 Rescheduling interrupts
CAL: 0 Function call interrupts
TLB: 0 TLB shootdowns
TRM: 0 Thermal event interrupts
THR: 0 Threshold APIC interrupts
MCE: 0 Machine check exceptions
MCP: 262 Machine check polls
ERR: 0
MIS: 0