Archive for category LinkStation

Unified LSMONITOR for Debian System in LinkStation LS421DE

You have done replacing Buffalo stock firmware with Debian, the last part is to adjust the hardware behavior to match the new operating system.

This work initially done by Sergej Wildemann for LinkStation Live V2 with my modification for LinkStation LS421DE for both Buffalo kernel and vanilla one.

What’s LSMONITOR jobs:

  • Controlling LED according to the current state (booting, power off, etc).
  • Monitor the temperature of HDDs and adjust the fan speed according.
  • Monitor power off switch and initiate shutdown when power switch position is off.

Installation

Do the following commands on your LinkStation LS421DE. If you have installed previous lsmonitor init script just remove it first:

$ update-rc.d lsmonitor stop
$ update-rc.d lsmonitor remove

Get init script and extract:

$ wget https://github.com/tohenk/linkstation-mod/raw/master/lsmonitor/lsmonitor-unified.tar.gz
$ tar -xvf lsmonitor-unified.tar.gz -C /

Install required packages:

$ apt-get install smartmontools hdparm evtest

Enable init script:

$ update-rc.d lsboot defaults
$ update-rc.d lsmonitor defaults

Restart LinkStation LS421DE to take effect.

, , ,

Leave a comment

Compiling Debian Wheezy Kernel for LinkStation LS421DE

After successfully replacing Buffalo stock firmware with Debian Wheezy, now it’s time to compile our own kernel. You need Ubuntu box to do cross compiling.

Preparation

Install required softwares:

$ sudo apt-get install build-essential git

Clone linkstation mod tools using Git:

$ mkdir ~/lsmod
$ cd ~/lsmod
$ git clone https://github.com/tohenk/linkstation-mod.git .

If you just want to update the tools, issue:

$ cd ~/lsmod && git pull

Prepare toolchain (as of 13c5db1):

Toolchains are availables from Linaro. New toolchain can be downloaded and prepared as follow:

$ mkdir -p ~/lsmod/lskernel/toolchain
$ cd ~/lsmod/lskernel/toolchain
$ wget http://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
$ xzcat gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz | tar -xvf -

To configure which toolchain to use, issue:

$ cd ~/lsmod
$ ./lskernel/build-ls-kernel.sh --toolchain

Cloning Linux Git Repository

Issue the following command to clone Linux Git repository:

$ cd ~/lsmod
$ ./lskernel/build-ls-kernel.sh --download

The Linux Git Repository sized about 900 MB, so it may take more minutes depend on your connection speed. Next time, to update the repository issue command:

$ ./lskernel/build-ls-kernel.sh --update

Cross Compiling

As of commit de80705, now you can choose which kernel version to use:

$ ./lskernel/build-ls-kernel.sh --kver

Customize kernel configuration:

$ ./lskernel/build-ls-kernel.sh --config

Compile kernel image, modules, and DTB (as of commit 30d24d7):

$ ./lskernel/build-ls-kernel.sh --all

Package the kernel:

$ sudo ./lskernel/build-ls-kernel.sh --package

The resulting kernel is ls-kernel-3.18.tar.gz in the current directory.

Installing Kernel

Transfer packaged kernel to LinkStation (replace lsbox with your LinkStation ip address or hostname):

$ scp ls-kernel-3.18.tar.gz root@lsbox:/root/

Now on your LinkStation, issue commands:

$ cd ~
$ cp /boot/uImage.buffalo /boot/uImage.buffalo-$(uname -r)
$ tar --overwrite -xvf ls-kernel-3.18.tar.gz -C /

Restart LinkStation to use the new kernel:

$ reboot

Here is kernel log:

Booting Linux on physical CPU 0x0
Linux version 4.4.6-ls421de (toha@Dev-PC) (gcc version 5.3.1 20160113 (Linaro GCC 5.3-2016.02) ) #1 SMP Sat Mar 26 23:12:34 WIB 2016
CPU: ARMv7 Processor [561f5811] revision 1 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
Machine model: Buffalo LinkStation LS421DE
Memory policy: Data cache writeback
On node 0 totalpages: 131072
free_area_init_node: node 0, pgdat c0dc8d80, node_mem_map dfbf8000
  Normal zone: 1024 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 131072 pages, LIFO batch:31
CPU: All CPU(s) started in SVC mode.
PERCPU: Embedded 13 pages/cpu @dfbdc000 s23616 r8192 d21440 u53248
pcpu-alloc: s23616 r8192 d21440 u53248 alloc=13*4096
pcpu-alloc: [0] 0 
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttyS0,115200 root=/dev/sda2 rw initrd=0x2600040 panic=5 BOOTVER=0.13 UBOOT_DATE=2013/08/28 mtdparts=armada-nand:0x2000000(boot),0x1e000000(rootfs)
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 503300K/524288K available (8715K kernel code, 950K rwdata, 3968K rodata, 488K init, 737K bss, 20988K reserved, 0K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
    lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc0c6b178   (12685 kB)
      .init : 0xc0c6c000 - 0xc0ce6000   ( 488 kB)
      .data : 0xc0ce6000 - 0xc0dd3a70   ( 951 kB)
       .bss : 0xc0dd3a70 - 0xc0e8c1f0   ( 738 kB)
Hierarchical RCU implementation.
	Build-time adjustment of leaf fanout to 32.
	RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=1
NR_IRQS:16 nr_irqs:16 16
L2C: DT/platform modifies aux control register: 0x12086300 -> 0x1a086302
Aurora cache controller enabled, 4 ways, 256 kB
Aurora: CACHE_ID 0x00000100, AUX_CTRL 0x1a086302
Switching to timer-based delay loop, resolution 53ns
sched_clock: 32 bits at 18MHz, resolution 53ns, wraps every 114532461029ns
clocksource: armada_370_xp_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 101933890472 ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 37.50 BogoMIPS (lpj=187500)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket -1, mpidr 0
Setting up static identity map for 0x82a0 - 0x82f8
mvebu-soc-id: MVEBU SoC ID=0x6710, Rev=0x1
mvebu-pmsu: Initializing Power Management Service Unit
Brought up 1 CPUs
SMP: Total of 1 processors activated (37.50 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 56 architecture 2 part 20 variant 9 rev 6
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
xor: measuring software checksum speed
   arm4regs  :  1106.000 MB/sec
   8regs     :  1018.400 MB/sec
   32regs    :  1024.800 MB/sec
xor: using function: arm4regs (1106.000 MB/sec)
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
sram soc:sa-sram: found no memory resource
sram: probe of soc:sa-sram failed with error -22
hw-breakpoint: debug architecture 0x4 unsupported.
raid6: int32x1  gen()   170 MB/s
raid6: int32x1  xor()   218 MB/s
raid6: int32x2  gen()   265 MB/s
raid6: int32x2  xor()   248 MB/s
raid6: int32x4  gen()   307 MB/s
raid6: int32x4  xor()   252 MB/s
raid6: int32x8  gen()   349 MB/s
raid6: int32x8  xor()   233 MB/s
raid6: using algorithm int32x8 gen() 349 MB/s
raid6: .... xor() 233 MB/s, rmw enabled
raid6: using intx1 recovery algorithm
vgaarb: loaded
SCSI subsystem initialized
libata version 3.00 loaded.
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
Bluetooth: Core ver 2.21
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Bluetooth: L2CAP socket layer initialized
Bluetooth: SCO socket layer initialized
clocksource: Switched to clocksource armada_370_xp_clocksource
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
Trying to unpack rootfs image as initramfs...
Freeing initrd memory: 1448K (c2600000 - c276a000)
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
futex hash table entries: 256 (order: 2, 16384 bytes)
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
ntfs: driver 2.1.32 [Flags: R/W].
jffs2: version 2.2. (NAND) \xffffffc2\xffffffa9\xffffffa9 2001-2006 Red Hat, Inc.
fuse init (API version 7.23)
SGI XFS with ACLs, security attributes, realtime, no debug enabled
async_tx: api initialized (async)
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
armada-370-pinctrl d0018000.pin-ctrl: registered pinctrl driver
irq: Cannot allocate irq_descs @ IRQ41, assuming pre-allocated
irq: Cannot allocate irq_descs @ IRQ73, assuming pre-allocated
irq: Cannot allocate irq_descs @ IRQ105, assuming pre-allocated
mvebu-pcie soc:pcie-controller: PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io  0x1000-0xfffff]
pci_bus 0000:00: root bus resource [mem 0xf8000000-0xffdfffff]
pci_bus 0000:00: root bus resource [bus 00-ff]
pci 0000:00:01.0: [11ab:6710] type 01 class 0x060400
pci 0000:00:02.0: [11ab:6710] type 01 class 0x060400
PCI: bus0: Fast back to back transfers disabled
pci 0000:00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci 0000:00:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci 0000:01:00.0: [1912:0015] type 00 class 0x0c0330
pci 0000:01:00.0: reg 0x10: [mem 0x40000000-0x40001fff 64bit]
pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
PCI: bus1: Fast back to back transfers disabled
pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
PCI: bus2: Fast back to back transfers enabled
pci_bus 0000:02: busn_res: [bus 02-ff] end is updated to 02
pci 0000:00:01.0: BAR 8: assigned [mem 0xf8000000-0xf80fffff]
pci 0000:01:00.0: BAR 0: assigned [mem 0xf8000000-0xf8001fff 64bit]
pci 0000:00:01.0: PCI bridge to [bus 01]
pci 0000:00:01.0:   bridge window [mem 0xf8000000-0xf80fffff]
pci 0000:00:02.0: PCI bridge to [bus 02]
pci 0000:00:01.0: enabling device (0140 -> 0142)
mv_xor d0060800.xor: Marvell shared XOR driver
mv_xor d0060800.xor: Marvell XOR (Registers Mode): ( xor cpy intr )
mv_xor d0060900.xor: Marvell shared XOR driver
mv_xor d0060900.xor: Marvell XOR (Registers Mode): ( xor cpy intr )
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
console [ttyS0] disabled
d0012000.serial: ttyS0 at MMIO 0xd0012000 (irq = 19, base_baud = 12500000) is a 16550A
console [ttyS0] enabled
brd: module loaded
loop: module loaded
sata_mv d00a0000.sata: version 1.28
sata_mv d00a0000.sata: slots 32 ports 2
scsi host0: sata_mv
scsi host1: sata_mv
ata1: SATA max UDMA/133 irq 28
ata2: SATA max UDMA/133 irq 28
pxa3xx-nand d00d0000.nand: This platform can't do DMA on this device
nand: device found, Manufacturer ID: 0xad, Chip ID: 0xdc
nand: Hynix H27U4G8F2DTR-BC
nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
pxa3xx-nand d00d0000.nand: ECC strength 1, ECC step size 512
Bad block table found at page 262080, version 0x01
Bad block table found at page 262016, version 0x01
nand_read_bbt: bad block at 0x0000059c0000
nand_read_bbt: bad block at 0x0000061e0000
nand_read_bbt: bad block at 0x00000d9c0000
nand_read_bbt: bad block at 0x00000d9e0000
nand_read_bbt: bad block at 0x00000e1c0000
nand_read_bbt: bad block at 0x00000e1e0000
nand_read_bbt: bad block at 0x00001d1e0000
nand_read_bbt: bad block at 0x00001d840000
nand_read_bbt: bad block at 0x00001d860000
nand_read_bbt: bad block at 0x00001e6c0000
nand_read_bbt: bad block at 0x00001e6e0000
nand_read_bbt: bad block at 0x00001e840000
nand_read_bbt: bad block at 0x00001e860000
nand_read_bbt: bad block at 0x00001edc0000
nand_read_bbt: bad block at 0x00001ede0000
nand_read_bbt: bad block at 0x00001f380000
nand_read_bbt: bad block at 0x00001f3a0000
nand_read_bbt: bad block at 0x00001f840000
nand_read_bbt: bad block at 0x00001f860000
3 ofpart partitions found on MTD device pxa3xx_nand-0
Creating 3 MTD partitions on "pxa3xx_nand-0":
0x000000000000-0x000000100000 : "spi-flash"
0x000000100000-0x000002100000 : "boot"
0x000002100000-0x000020000000 : "rootfs"
libphy: Fixed MDIO Bus: probed
libphy: orion_mdio_bus: probed
mvneta d0074000.ethernet eth0: Using device tree mac address 10:6f:3f:cd:58:8b
PPP generic driver version 2.4.2
NET: Registered protocol family 24
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
ehci-orion: EHCI orion driver
orion-ehci d0050000.usb: EHCI Host Controller
orion-ehci d0050000.usb: new USB bus registered, assigned bus number 1
orion-ehci d0050000.usb: irq 25, io mem 0xd0050000
orion-ehci d0050000.usb: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: EHCI Host Controller
usb usb1: Manufacturer: Linux 4.4.6-ls421de ehci_hcd
usb usb1: SerialNumber: d0050000.usb
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
orion-ehci d0051000.usb: EHCI Host Controller
orion-ehci d0051000.usb: new USB bus registered, assigned bus number 2
orion-ehci d0051000.usb: irq 26, io mem 0xd0051000
orion-ehci d0051000.usb: USB 2.0 started, EHCI 1.00
usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb2: Product: EHCI Host Controller
usb usb2: Manufacturer: Linux 4.4.6-ls421de ehci_hcd
usb usb2: SerialNumber: d0051000.usb
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
xhci_hcd 0000:01:00.0: xHCI Host Controller
xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 3
xhci_hcd 0000:01:00.0: hcc params 0x014051cf hci version 0x100 quirks 0x00000090
usb usb3: New USB device found, idVendor=1d6b, idProduct=0002
usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb3: Product: xHCI Host Controller
usb usb3: Manufacturer: Linux 4.4.6-ls421de xhci-hcd
usb usb3: SerialNumber: 0000:01:00.0
hub 3-0:1.0: USB hub found
hub 3-0:1.0: 2 ports detected
xhci_hcd 0000:01:00.0: xHCI Host Controller
xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 4
usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
usb usb4: New USB device found, idVendor=1d6b, idProduct=0003
usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb4: Product: xHCI Host Controller
usb usb4: Manufacturer: Linux 4.4.6-ls421de xhci-hcd
usb usb4: SerialNumber: 0000:01:00.0
hub 4-0:1.0: USB hub found
hub 4-0:1.0: 2 ports detected
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usblp
usbcore: registered new interface driver cdc_wdm
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver pl2303
usbserial: USB Serial support registered for pl2303
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
rtc-rs5c372 0-0032: rs5c372a found, 24hr, driver version 0.6
rtc rtc0: invalid alarm value: 2016-3-27 37:85:0
rtc-rs5c372 0-0032: rtc core: registered rtc-rs5c372 as rtc0
gpio-fan gpio-fan: GPIO fan initialized
md: linear personality registered for level -1
md: raid0 personality registered for level 0
md: raid1 personality registered for level 1
md: raid10 personality registered for level 10
ata1: SATA link up 3.0 Gbps (SStatus 123 SControl F300)
md: raid6 personality registered for level 6
md: raid5 personality registered for level 5
md: raid4 personality registered for level 4
device-mapper: ioctl: 4.34.0-ioctl (2015-10-28) initialised: dm-devel@redhat.com
ata1.00: ATA-9: WDC WD40EFRX-68WT0N0, 82.00A82, max UDMA/133
ata1.00: 7814037168 sectors, multi 0: LBA48 NCQ (depth 31/32)
ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access     ATA      WDC WD40EFRX-68W 0A82 PQ: 0 ANSI: 5
marvell-cesa: probe of d0090000.crypto failed with error -22
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
sd 0:0:0:0: [sda] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB)
sd 0:0:0:0: [sda] 4096-byte physical blocks
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
oprofile: using arm/armv7-ca9
NET: Registered protocol family 10
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
NET: Registered protocol family 17
bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfilter if you need this.
l2tp_core: L2TP core driver, V2.0
l2tp_ip: L2TP IP encapsulation support (L2TPv3)
l2tp_netlink: L2TP netlink interface
l2tp_eth: L2TP ethernet pseudowire support (L2TPv3)
l2tp_ip6: L2TP IP encapsulation support for IPv6 (L2TPv3)
8021q: 802.1Q VLAN Support v1.8
ThumbEE CPU extension supported.
Registering SWP/SWPB emulation handler
input: gpio-keys as /devices/platform/gpio-keys/input/input0
rtc-rs5c372 0-0032: setting system clock to 2016-03-27 01:53:05 UTC (1459043585)
ALSA device list:
  No soundcards found.
 sda: sda1 sda2 sda3 sda4 sda5 sda6
sd 0:0:0:0: [sda] Attached SCSI disk
ata2: SATA link up 3.0 Gbps (SStatus 123 SControl F300)
ata2.00: ATA-9: WDC WD40EFRX-68WT0N0, 80.00A80, max UDMA/133
ata2.00: 7814037168 sectors, multi 0: LBA48 NCQ (depth 31/32)
ata2.00: configured for UDMA/133
scsi 1:0:0:0: Direct-Access     ATA      WDC WD40EFRX-68W 0A80 PQ: 0 ANSI: 5
sd 1:0:0:0: [sdb] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB)
sd 1:0:0:0: [sdb] 4096-byte physical blocks
sd 1:0:0:0: Attached scsi generic sg1 type 0
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sdb: sdb1 sdb2 sdb3 sdb4 sdb5 sdb6
sd 1:0:0:0: [sdb] Attached SCSI disk
md: Waiting for all devices to be available before autodetect
md: If you don't use raid, use raid=noautodetect
md: Autodetecting RAID arrays.
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 8:2.
devtmpfs: mounted
Freeing unused kernel memory: 488K (c0c6c000 - c0ce6000)
udevd[1570]: starting version 175
random: nonblocking pool is initialized
Adding 999992k swap on /dev/sda5.  Priority:-1 extents:1 across:999992k 
EXT4-fs (sda2): re-mounted. Opts: (null)
EXT4-fs (sda2): re-mounted. Opts: (null)
EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
EXT4-fs (sda6): mounted filesystem with ordered data mode. Opts: (null)
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
mvneta d0074000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory
NFSD: starting 90-second grace period (net c0db3740)
XFS (sdb6): Mounting V4 Filesystem
XFS (sdb6): Ending clean mount

Things currently not working

  1. reboot command behave as poweroff.
  2. poweroff doesn’t halt the LinkStation, you need to turn off the power manually (fixed in kernel 4.4).

Important

The LinkStation kernel build script may changed regularly. You need to update the script by issuing:

$ cd ~/lsmod
$ git pull

Save pending works and change branch to master:

$ cd lskernel/linux
$ git stash save -a
$ git checkout master

Then recompile the kernel by following cross-compiling steps above.

, , , , ,

24 Comments

Debian Wheezy on LinkStation LS421DE

Disclaimer:
THE FOLLOWING PROCEDURE WILL CAUSE ALL OF YOUR DATA TO BE LOST. YOU HAVE BEEN WARNED!

Installing Debian on LinkStation LS421DE to replace the Buffalo stock firmware aimed to create a full customized operating system without unnecessary software as in stock firmware.

The configuration for the following scenario described as below:

  • Using LinkStation LS421DE with armhf (arm hard float) architecture.
  • Not using raid, but adding raid partition for data partition is fully supported.
  • Currently, no vanilla kernel available. So, we are using Buffalo kernel at the moment. Vanilla kernel can be cross compiled.

The main process of Debian installation summarized as follow:

  • Creating rootfs by debootstrapping Debian on running LS421DE system.
  • Using a Linux box (Ubuntu) to prepare suitable image for LinkStation.
  • Modifying partition and installing Debian.
  • Enable lsmonitor script and customize Debian system.

Creating rootfs on running LS421DE system

You must have already a root access to the LinkStation box, if not, follow the the procedure on https://tohenk.wordpress.com/2014/11/11/opening-stock-firmware-of-linkstation-ls421de/.

Install debootstrap:

$ cd ~
$ wget http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.64~bpo70+1_all.deb
$ dpkg -i --force-all debootstrap_1.0.64~bpo70+1_all.deb

Prepare the tools by issuing commands:

$ mkdir ~/lsmod
$ cd ~/lsmod
$ wget https://github.com/tohenk/linkstation-mod/archive/master.zip
$ unzip master.zip
$ cd linkstation-mod-master

Edit scripts/debootstrap-rootfs.cfg and adjust as you need, choose closest mirror from your location. Extra packages can be specified using PACKAGES variable.

$ cat scripts/debootstrap-rootfs.cfg
ARCH=armhf
VERSION=wheezy
MIRROR=http://kartolo.sby.datautama.net.id/debian
PACKAGES=
$ vi scripts/debootstrap-rootfs.cfg

Run debootstrap:

$ ./scripts/debootstrap-rootfs.sh --clean

You can ommit –clean option if you don’t want to debootstrap-ing again. After debootstrap process, the rootfs archive can be found on rootfs folder:
rootfs_wheezy_armhf_yymmdd.tar.gz => hddrootfs
initrd_wheezy_armhf_yymmdd.tar.gz => initrd

Preparing Debian image for LinkStation

On Linux (Ubuntu) box, prepare the tools:

$ mkdir ~/lsmod
$ cd ~/lsmod
$ wget https://github.com/tohenk/linkstation-mod/archive/master.zip
$ unzip master.zip
$ cd linkstation-mod-master

Transfer rootfs from LinkStation (replace lsbox with your real LinkStation hostname or IP address):

$ mkdir rootfs
$ scp root@lsbox:/root/lsmod/linkstation-mod-master/rootfs/* rootfs/

Prepare LinkStation stock firmware and place it in firmware folder:

$ mkdir firmware
$ cp path-to-buffalo-firmware/ls400-133en.zip firmware/
$ unzip firmware/ls400-133en.zip

Customize scripts/debootstrap-combine.cfg (adjust HOSTNAME, NETWORK_PROTO, etc), then create hddrootfs and initrd:

$ cat scripts/debootstrap-combine.cfg
HOSTNAME=LS421DE88B
NETWORK_INTERFACE=eth1
NETWORK_PROTO=static
NETWORK_IP=172.16.1.4
NETWORK_NETMASK=255.255.255.0
NETWORK_GATEWAY=172.16.1.1
NETWORK_DNS=172.16.1.1
NETWORK_DOMAIN=ntlab.net
#INITRD_TEMP_ROOT="0x811"
#INITRD_ROOT="0x901"
INITRD_ROOT="0x802"
$ vi scripts/debootstrap-combine.cfg
$ sudo ./scripts/debootstrap-combine.sh rootfs/rootfs_wheezy_armhf_141112.tar.gz rootfs/initrd_wheezy_armhf_141112.tar.gz firmware/ls400-133en

Unpack Buffalo kernel image:

$ sudo ./scripts/unpack-image.sh firmware/ls400-133en/uImage.img out/

Debian image for LinkStation now ready in the folder out with files hddrootfs.buffalo.updated, initrd.buffalo, and uImage.buffalo.

Modifying partition and installing Debian

Now, detach the hard disk from LinkStation and attach it to Linux box. Ensure the disk is detected and acquire the correct device node:

$ ls /dev/sd*

I’m assumed the disk detected as /dev/sda. Next install mdadm if it’s not already installed:

$ sudo apt-get install --no-install-recommends mdadm

Assemble raid partition:

$ sudo mdadm --assemble --scan

Stop all raid partition:

$ sudo mdadm --stop /dev/md0
$ sudo mdadm --stop /dev/md1
$ sudo mdadm --stop /dev/md2
$ sudo mdadm --stop /dev/md101

Remove all raid partition:

$ sudo mdadm --remove /dev/md0
$ sudo mdadm --remove /dev/md1
$ sudo mdadm --remove /dev/md2
$ sudo mdadm --remove /dev/md101

Zero super block:

$ sudo mdadm --zero-superblock /dev/sda1
$ sudo mdadm --zero-superblock /dev/sda2
$ sudo mdadm --zero-superblock /dev/sda5
$ sudo mdadm --zero-superblock /dev/sda6

Create filesystems:

$ sudo mkfs.ext3 /dev/sda1
$ sudo mkfs.ext4 /dev/sda2
$ sudo mkswap /dev/sda5
$ sudo mkfs.ext4 /dev/sda6

Install Debian:

$ mkdir /tmp/sda1
$ sudo mount /dev/sda1 /tmp/sda1
$ sudo cp out/initrd.buffalo /tmp/sda1
$ sudo cp out/uImage.buffalo /tmp/sda1
$ mkdir /tmp/sda2
$ sudo mount /dev/sda2 /tmp/sda2
$ sudo ./scripts/unpack-rootfs.sh out/hddrootfs.updated.buffalo /tmp/sda2

Attach back the disk to LinkStation, try pinging to test if installation was successfull. You then can SSH-ing as usual.

Enable lsmonitor script and customize Debian system

Now, the final step to customize Debian system by enabling lsmonitor init script:

$ cd ~
$ wget https://github.com/tohenk/linkstation-mod/raw/master/lsmonitor/lsmonitor.tar.gz
$ cd / && tar -xvf ~/lsmonitor.tar.gz

Install dependencies:

$ apt-get install smartmontools hdparm

Enable init script:

$ update-rc.d lsmonitor defaults

Start lsmonitor service:

$ service lsmonitor start

Now, Debian system is complete. Next you can customize your Debian as you need.

, , ,

18 Comments

Opening Stock Firmware of LinkStation LS421DE

The purpose for opening a stock firmware is to gain root access to LinkStation. With root access, several additional softwares can be added to the firmware, e.g: using optware package. Furthermore, a custom operating system can be used to replace the Buffalo stock firmware such as Debian.

This process based on existing method on buffalo.nas-central.org, tested on LS421DE:

  1. Download the tools from https://github.com/tohenk/linkstation-mod/archive/master.zip.
    $ mkdir ~/lsmod
    $ cd ~/lsmod
    $ wget https://github.com/tohenk/linkstation-mod/archive/master.zip
    $ unzip master.zip
    $ cd linkstation-mod-master
    
  2. Get the Buffalo stock firmware from http://buffalo.jp/support_ap/support/products/ls400.html, the latest firmware as of this writing is 1.33.
    $ mkdir firmware
    $ cd firmware
    $ wget http://buffalo.jp/php/ldl_ap.php?to=secure%2Fnas%2Fwin%2Fls400-133en.zip%3Fkey%3DMzEyNzEwMDQzNzE0NTQ2OTEwMTAwMjJkcml2ZXIuYXNpYS5idWZmYWxvLmpwMDQwL2J1Zi1kcnYyL3NlY3VyZS9uYXMvd2luL2xzNDAwLTEzM2VuLnppcDEwMTAwMDJpZDExMTBya3BhdzAwMDAwMDA2MDAwMzcyNzY%3D%26ext%3D.zip
    $ unzip ls400-133en.zip
    

    After unzip process, the firmware can be found on the ~/lsmod/linkstation-mod-master/firmware/ls400-133en/ folder.

  3. Prepare SSH public key for login authentication.
    If you’re already using a linux box, simply copy id_dsa.pub or id_rsa.pub to data folder.

    $ cd ~/lsmod/linkstation-mod-master
    $ cp ~/.ssh/id_dsa.pub data/id_dsa.key
    

    On windows box, use puTTYgen to generate SSH private/public key pair. Refer to http://winscp.net/eng/docs/ui_puttygen for an example. After the key generation is complete, do not close the puTTYgen window, rather select all the text in the generated public key, press Ctrl+C to copy the content and paste it as text file in notepad and save the file with .key extension. You then can copy the file to linux box using WinSCP for example and put in the data folder.

  4. Execute the script to open the stock firmware.
    $ sudo ./scripts/open-ls-rootfs.sh firmware/ls400-133en/hddrootfs.img
    Opening stock firmware ROOTFS of firmware/ls400-133en/hddrootfs.img.
    > Preparing directories...
    > Unpacking ROOTFS image...
      Using password 1NIf_2yUOlRDpYZUVNqboRpMBoZwT4PzoUvOPUp6l.
    > Extracting ROOTFS...
    > Removing root password...
      Removing root password from initfile backup.
      Removing root password from shadow file.
    > Allowing root login via telnet and ssh...
      Enabling SSHD service.
    > Adding ssh key...
    > Creating emergency script service...
    > Package ROOTFS...
      Opened ROOTFS image saved in /home/toha/lsmod/linkstation-mod-master/out/hddrootfs.img.
    
    Done.
    
    

    Additionally, you can add features by editing data/nas_features and issue the following command:

    $ sudo ./scripts/open-ls-initrd-cpio.sh firmware/ls400-133en/initrd.img
    Opening stock firmware INITRD of firmware/ls400-133en/initrd.img.
    > Preparing directories...
    > Unpacking INITRD image...
      Using password 1NIf_2yUOlRDpYZUVNqboRpMBoZwT4PzoUvOPUp6l.
    > Extracting INITRD using cpio...
    > Enable SFTP in nas_features...
    > Patching nas_features...
      Applying patch from /home/toha/lsmod/linkstation-mod-master/data/nas_features.
    > Removing root password...
    > Create and package INITRD...
      Opened INITRD image saved in /home/toha/lsmod/linkstation-mod-master/out/initrd.img.
    
    Done.
    
    

    The opened firmware image can be found on ~/lsmod/linkstation-mod-master/out/ folder named as hddrootfs.img and initrd.img.

  5. Re-flash the modified firmware.
    You need a windows box (or Machintosh) to flash Buffalo firmware. Copy and replace original firmware with the opened firmware from previous step.
    Append the following lines to LSUpdater.ini

    [SpecialFlags]
    Debug = 1
    

    Execute LSUpdater.exe, activate debug mode by clicking in the upper left corner (see figure below).
    ls-updater-debug
    In the Debug Mode dialog, tick the following options:

    • Config: Do not check version
    • Config: Force update
    • Update: Update rootfs
    • Update: Update initrd (only if you add features to initrd image)

    ls-updater-debug-options
    Next, perform update process by clicking the Update button. After update process is done you can SSH-ing to the box using root.

, ,

11 Comments