中華ファンレスNASをOpenWRT(LEDE)で使う

# はじめに
中華ファンレスNASをLinux化して「常時起動省電力Linuxサーバー」として運用するにあたり、
色々とハマったので、メモを晒しておきます。
やった事は srchack.org さんの[この記事](https://www.srchack.org/article.php?story=20170514090746354)がベースですが、
自己流に頑張ろうとして色々と大事故になったのですが、
海外サイトにも解決策が殆ど無い状態でしたので、足跡を残しておきます。

# 材料
* KIMAX BS-U35WF
* 3.5インチHDD

![IMG_20200103_104005.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/704155/cda71665-0dac-dbda-7511-09ee8437db5d.jpeg)


元々、IOデータの[RockDisk Next](https://www.ioplaza.jp/shop/contents/rdnext.aspx)を使っていて、未だに現役で困ってはいませんが、
さすがにlinux kernel 2.6.31 ってのは古すぎ(10年前・・・)で、
gcc環境を構築してもkernelが古すぎてビルドできないOSSが殆どになってきたので、
srchack.org さんの記事も発見していた事もあり、選択しています。
aliexplessの昨年の11.1セールで、3,600円くらいで買いました。
今でも、aliexplessのBlueendless Official Store辺りで買えるみたいです。

別に何でも良かったのですが、重要視した点は以下です。

* ファンレスNAS
* それなりのディストリビューションのLinuxがインストール出来る
* 省電力

国内市場では、ファンレスの小型NASキットは絶滅していて、
RaspberryPiやOrangePi辺りでNAS構築する例も有りますが、
別途HDDケースと本体をケーブルで繋ぐより、
一つの電源・箱でNASを構築したい、と言う欲求です。

尚、Wifiも付いてますが、技適の問題もありますし、
そもそも、NASは「ネットワークが安定していてなんぼ」ですので、無効化して使います。

# KIMAX BS-U35WFについて
srchack.org さんの記事で十分事足りるのですが、
MediaTekのチップと言いながら、[Ralink](https://qiita.com/yamori813/items/09f976d2970cad24fd5a)の流れを汲むSoCの様で、
ARM系ではなく、MIPSです。
RaspberryPiは飽きて来て、弄り甲斐が有りそうな環境を求めている方には良いかもしれません。

# 失敗1 : OpenWRT化時はフルリセットが必要
srchack.org さんの記事にも書かれていますが、
BS-U35WFの標準インターフェースで、OpenWRT/LEDEのファームを食べてくれますが、
どこかのチェックボックスを有効にし忘れたのか、
「/etc 以下を保持したままファームアップデート」と言うとんでもない状態となってしまいました。
折角の素のLinuxですが、/etc/passwd が工場出荷時のままで、rootパスワードが分からない、
というどうしようもない状態です。

OpenWRTのコミュニティーでは、[Factory Reset](https://openwrt.org/docs/guide-user/troubleshooting/failsafe_and_factory_reset)について等、
他にも色々な情報が有り、試してみましたが、全てNGで受け付けてくれません。
会社での業務時間とは比較にならないくらい、真剣に解析しましたが、打つ手無しです。

最終手段はUART引き出しになるのですが、
srchack.org さんの記事でピンが出てるので簡単かな、と思えど、
コスト削減の為か、基板変更が発生している様で、
最新の基板では残念な事にフレキ接続になってしまっていて、
はんだ付けが必要になってしまいます。
私は、結構危険ですが、セロテープで銅線を固定して、何とかUARTアクセスする事が出来ました。

![IMG_20200209_151522.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/704155/e05272bb-2e42-2e4b-23bf-9e283a4fc98c.jpeg)

これでrootログインして、/etc 含めて再度ファームアップデートする事が出来ました。

#失敗2 : 最新環境導入はNG?
折角、OpenWRTは現役のディストリビューションですので、最新版の環境を構築したくなりますが、
これが失敗の基でした。
OpenWRTのコミュニティーにも、[U35WFのページ](https://openwrt.org/toh/blueendless/blueendless_u35wf)はしっかりと記載があります。
ここを読むと、19.07の更に最新版で動作しそうな雰囲気を感じますが、乗っかると失敗します。

まず、RC版を使うと、GUI(httpアクセス)の機能が入っていない場合が有ります。
私は19.07.1.4のファームにアップデートしてGUIアクセスNG、前述の失敗1の理由でsshも繋がらず、で
UARTのお世話になっています。

では、安定盤であれば問題ないのか? と言う推測の基に、
19.07を入れて、一見上手く行った様に見えましたが、
Linuxの初期設定を終えて、いざHDDのフォーマットを実行しようとすると、
何故かHDDが認識されていません。

```openwrt-19.07.1.dmesg
[    0.000000] Linux version 4.14.167 (builder@buildhost) (gcc version 7.5.0 (OpenWrt GCC 7.5.0 r10911-c155900f66)) #0 Wed Jan 29 16:05:35 2020
[    0.000000] Board has DDR2
[    0.000000] Analog PMU set to hw control
[    0.000000] Digital PMU set to hw control
[    0.000000] SoC Type: MediaTek MT7620A ver:2 eco:6
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019650 (MIPS 24KEc)
[    0.000000] MIPS: machine is Kimax U35WF
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 08000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000] free_area_init_node: node 0, pgdat 8047c5d0, node_mem_map 81000040
[    0.000000]   Normal zone: 256 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] random: get_random_bytes called from 0x8047f740 with crng_init=0
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line: console=ttyS0,57600 rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Writing ErrCtl register=000281c0
[    0.000000] Readback ErrCtl register=000281c0
[    0.000000] Memory: 123796K/131072K available (3914K kernel code, 181K rwdata, 500K rodata, 1220K init, 215K bss, 7276K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 256
[    0.000000] CPU Clock: 580MHz
[    0.000000] clocksource: systick: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 583261500 ns
[    0.000000] systick: enable autosleep mode
[    0.000000] systick: running - mult: 214748, shift: 32
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6590553264 ns
[    0.000011] sched_clock: 32 bits at 290MHz, resolution 3ns, wraps every 7405115902ns
[    0.015481] Calibrating delay loop... 385.84 BogoMIPS (lpj=1929216)
[    0.087755] pid_max: default: 32768 minimum: 301
[    0.097170] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.110206] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.129305] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.148789] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.160975] pinctrl core: initialized pinctrl subsystem
[    0.172592] NET: Registered protocol family 16
[    0.204435] rt2880_gpio 10000600.gpio: registering 24 gpios
[    0.215474] rt2880_gpio 10000600.gpio: registering 24 irq handlers
[    0.228075] rt2880_gpio 10000660.gpio: registering 32 gpios
[    0.239077] rt2880_gpio 10000660.gpio: registering 32 irq handlers
[    0.251668] rt2880_gpio 10000688.gpio: registering 1 gpios
[    0.262498] rt2880_gpio 10000688.gpio: registering 1 irq handlers
[    0.279619] clocksource: Switched to clocksource systick
[    0.291286] NET: Registered protocol family 2
[    0.300868] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.314652] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.327244] TCP: Hash tables configured (established 1024 bind 1024)
[    0.340022] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.351550] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.364242] NET: Registered protocol family 1
[    0.372829] PCI: CLS 0 bytes, default 32
[    0.375669] rt-timer 10000100.timer: maximum frequency is 1220Hz
[    0.388409] Crashlog allocated RAM at address 0x3f00000
[    0.400569] workingset: timestamp_bits=30 max_order=15 bucket_order=0
[    0.419418] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.430919] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.461293] io scheduler noop registered
[    0.468936] io scheduler deadline registered (default)
[    0.480177] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.495645] console [ttyS0] disabled
[    0.502707] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20, base_baud = 2500000) is a Palmchip BK-3103
[    0.522380] console [ttyS0] enabled
[    0.536194] bootconsole [early0] disabled
[    0.560350] spi spi0.0: force spi mode3
[    0.568784] m25p80 spi0.0: mx25l12805d (16384 Kbytes)
[    0.578959] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.591638] Creating 4 MTD partitions on "spi0.0":
[    0.601210] 0x000000000000-0x000000030000 : "u-boot"
[    0.612069] 0x000000030000-0x000000040000 : "u-boot-env"
[    0.623618] 0x000000040000-0x000000050000 : "factory"
[    0.634640] 0x000000050000-0x000001000000 : "firmware"
[    0.648813] 2 uimage-fw partitions found on MTD device firmware
[    0.660684] Creating 2 MTD partitions on "firmware":
[    0.670605] 0x000000000000-0x00000017dc97 : "kernel"
[    0.681413] 0x00000017dc97-0x000000fb0000 : "rootfs"
[    0.692205] mtd: device 5 (rootfs) set to be root filesystem
[    0.705162] 1 squashfs-split partitions found on MTD device rootfs
[    0.717555] 0x0000003e0000-0x000000fb0000 : "rootfs_data"
[    0.730176] libphy: Fixed MDIO Bus: probed
[    0.747235] gsw: setting port4 to ephy mode
[    0.755872] mtk_soc_eth 10100000.ethernet: loaded mt7620 driver
[    0.768388] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5
[    0.785418] rt2880_wdt 10000120.watchdog: Initialized
[    0.796891] NET: Registered protocol family 10
[    0.810102] Segment Routing with IPv6
[    0.817510] NET: Registered protocol family 17
[    0.826477] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    0.852322] 8021q: 802.1Q VLAN Support v1.8
[    0.876393] VFS: Mounted root (squashfs filesystem) readonly on device 31:5.
[    0.897213] Freeing unused kernel memory: 1220K
[    0.906279] This architecture does not have kernel memory protection.
[    2.598725] init: Console is alive
[    2.605845] init: - watchdog -
[    2.649566] random: fast init done
[    4.436189] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    4.536518] usbcore: registered new interface driver usbfs
[    4.547629] usbcore: registered new interface driver hub
[    4.558364] usbcore: registered new device driver usb
[    4.574531] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    4.589333] ehci-platform: EHCI generic platform driver
[    4.610166] phy phy-usbphy.0: remote usb device wakeup disabled
[    4.621986] phy phy-usbphy.0: UTMI 16bit 30MHz
[    4.630871] ehci-platform 101c0000.ehci: EHCI Host Controller
[    4.642376] ehci-platform 101c0000.ehci: new USB bus registered, assigned bus number 1
[    4.658288] ehci-platform 101c0000.ehci: irq 26, io mem 0x101c0000
[    4.680688] ehci-platform 101c0000.ehci: USB 2.0 started, EHCI 1.00
[    4.694232] hub 1-0:1.0: USB hub found
[    4.702188] hub 1-0:1.0: 1 port detected
[    4.713379] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    4.727415] ohci-platform: OHCI generic platform driver
[    4.738189] ohci-platform 101c1000.ohci: Generic Platform OHCI controller
[    4.751809] ohci-platform 101c1000.ohci: new USB bus registered, assigned bus number 2
[    4.767726] ohci-platform 101c1000.ohci: irq 26, io mem 0x101c1000
[    4.805850] hub 2-0:1.0: USB hub found
[    4.813800] hub 2-0:1.0: 1 port detected
[    4.825783] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    4.844366] init: - preinit -
[    5.755253] usb 1-1: new high-speed USB device number 2 using ehci-platform
[    5.996450] random: procd: uninitialized urandom read (4 bytes read)
[    6.009702] hub 1-1:1.0: USB hub found
[    6.023035] hub 1-1:1.0: 4 ports detected
[    6.498298] 8021q: adding VLAN 0 to HW filter on device eth0
[    6.587457] usb 1-1.1: new high-speed USB device number 3 using ehci-platform
[    7.751995] jffs2: notice: (416) jffs2_build_xattr_subsystem: complete building xattr subsystem, 11 of xdatum (3 unchecked, 8 orphan) and 30 of xref (7 dead, 2 orphan) found.
[    7.786392] mount_root: switching to jffs2 overlay
[    7.825049] overlayfs: upper fs does not support tmpfile.
[    7.849242] urandom-seed: Seeding with /etc/urandom.seed
[    7.997194] procd: - early -
[    8.003234] procd: - watchdog -
[    8.512786] procd: - watchdog -
[    8.519413] procd: - ubus -
[    8.769701] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.785644] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.800088] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.813853] procd: - init -
[    9.724385] kmodloader: loading kernel modules from /etc/modules.d/*
[    9.916360] ip6_tables: (C) 2000-2006 Netfilter Core Team
[    9.950047] Loading modules backported from Linux version v4.19.98-0-gd183c8e2647a
[    9.965210] Backport generated by backports.git v4.19.98-1-0-g8204eb99
[   10.014573] ip_tables: (C) 2000-2006 Netfilter Core Team
[   10.049792] nf_conntrack version 0.5.0 (2048 buckets, 8192 max)
[   10.198184] xt_time: kernel timezone is -0000
[   10.250400] urngd: jent-rng init failed, err: 2
[   10.303138] PPP generic driver version 2.4.2
[   10.316194] NET: Registered protocol family 24
[   10.366897] rt2800_wmac 10180000.wmac: loaded eeprom from mtd device "factory"
[   10.381347] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 6352, rev 0500 detected
[   10.396820] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 7620 detected
[   10.411294] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[   10.524116] kmodloader: done loading kernel modules from /etc/modules.d/*
[   22.408357] 8021q: adding VLAN 0 to HW filter on device eth0
[   22.445399] br-lan: port 1(eth0) entered blocking state
[   22.455909] br-lan: port 1(eth0) entered disabled state
[   22.466694] device eth0 entered promiscuous mode
[   22.584853] br-lan: port 1(eth0) entered blocking state
[   22.595327] br-lan: port 1(eth0) entered forwarding state
[   22.606356] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   23.461098] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[   25.625819] ieee80211 phy0: rt2800_rf_self_txdc_cal: Info - RF Tx self calibration start
[   25.642431] ieee80211 phy0: rt2800_rf_self_txdc_cal: Info - RF Tx self calibration end
[   27.528807] ieee80211 phy0: rt2800_loft_iq_calibration: Info - LOFT Calibration Done!
[   27.548309] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Start!
[   27.575809] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Done! CH = 0, (gain= 1, phase=3b)
[   27.594938] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Start!
[   27.622435] ieee80211 phy0: rt2800_iq_search: Info - IQCalibration Done! CH = 1, (gain= f, phase=3a)
[   27.640679] ieee80211 phy0: rt2800_loft_iq_calibration: Info - TX IQ Calibration Done!
[   27.669955] ieee80211 phy0: rt2800_rxiq_calibration: Info - RXIQ G_imb=0, Ph_rx=-1
[   27.697751] ieee80211 phy0: rt2800_rxiq_calibration: Info - RXIQ G_imb=0, Ph_rx=-2
[   27.723017] IPv6: ADDRCONF(NETDEV_UP): wlan0-1: link is not ready
[   27.742455] br-lan: port 2(wlan0-1) entered blocking state
[   27.753488] br-lan: port 2(wlan0-1) entered disabled state
[   27.764831] device wlan0-1 entered promiscuous mode
[   27.903225] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   29.115132] wlan0: authenticate with 34:76:c5:b2:32:90
[   29.134189] wlan0: send auth to 34:76:c5:b2:32:90 (try 1/3)
[   29.149101] wlan0: authenticated
[   29.157215] wlan0: associate with 34:76:c5:b2:32:90 (try 1/3)
[   29.176759] wlan0: RX AssocResp from 34:76:c5:b2:32:90 (capab=0x411 status=0 aid=11)
[   29.192559] wlan0: associated
[   29.280984] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   29.310806] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0-1: link becomes ready
[   29.324120] br-lan: port 2(wlan0-1) entered blocking state
[   29.335106] br-lan: port 2(wlan0-1) entered forwarding state
[   51.696865] random: crng init done
[   51.703653] random: 6 urandom warning(s) missed due to ratelimiting
```
srchack.org さんの記事でも、対応が本家に取り入れられていない、との事でしたので、
素直に、LEDE 17.01.4 を https://github.com/arvati/lede-U35WF から持ってきて書き込む事で、
kernelバージョンが少し下がってしまいましたが、
(RockDisk Next の kernel 2.6.31 よりは随分とマシです。)
ようやく、無事にNASとしての最低限の機能を確認する事が出来ました。

```
cd /tmp
wget https://github.com/vanaware/openwrt/releases/download/v17.01.4-u35wf-v1/lede-17.01.4-ramips-mt7620-u35wf-sysupgrade.bin
sysupgrade -n ./lede-17.01.4-ramips-mt7620-u35wf-sysupgrade.bin
```

```LEDE-17.1.4.dmesg
[    0.000000] Linux version 4.4.92 (root@openwrt) (gcc version 5.4.0 (LEDE GCC 5.4.0 r3560-79f57e422d) ) #0 Tue Oct 17 17:46:20 2017
[    0.000000] Board has DDR2
[    0.000000] Analog PMU set to hw control
[    0.000000] Digital PMU set to hw control
[    0.000000] SoC Type: MediaTek MT7620A ver:2 eco:6
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019650 (MIPS 24KEc)
[    0.000000] MIPS: machine is Kimax U35WF
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 08000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000] free_area_init_node: node 0, pgdat 8035c4b0, node_mem_map 81000000
[    0.000000]   Normal zone: 256 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
[    0.000000] Kernel command line: console=ttyS0,57600 rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Writing ErrCtl register=000281c0
[    0.000000] Readback ErrCtl register=000281c0
[    0.000000] Memory: 125940K/131072K available (3017K kernel code, 147K rwdata, 384K rodata, 156K init, 208K bss, 5132K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:256
[    0.000000] CPU Clock: 580MHz
[    0.000000] clocksource: systick: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 583261500 ns
[    0.000000] systick: enable autosleep mode
[    0.000000] systick: running - mult: 214748, shift: 32
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6590553264 ns
[    0.000012] sched_clock: 32 bits at 290MHz, resolution 3ns, wraps every 7405115902ns
[    0.015459] Calibrating delay loop... 385.84 BogoMIPS (lpj=1929216)
[    0.080603] pid_max: default: 32768 minimum: 301
[    0.089924] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.102939] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.122088] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.141572] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.153715] pinctrl core: initialized pinctrl subsystem
[    0.165351] NET: Registered protocol family 16
[    0.179183] Can't analyze schedule() prologue at 8000acdc
[    0.203165] rt2880_gpio 10000600.gpio: registering 24 gpios
[    0.214191] rt2880_gpio 10000600.gpio: registering 24 irq handlers
[    0.226607] rt2880_gpio 10000638.gpio: registering 16 gpios
[    0.237583] rt2880_gpio 10000638.gpio: registering 16 irq handlers
[    0.250023] rt2880_gpio 10000660.gpio: registering 32 gpios
[    0.261001] rt2880_gpio 10000660.gpio: registering 32 irq handlers
[    0.273444] rt2880_gpio 10000688.gpio: registering 1 gpios
[    0.284252] rt2880_gpio 10000688.gpio: registering 1 irq handlers
[    0.297725] clocksource: Switched to clocksource systick
[    0.309448] NET: Registered protocol family 2
[    0.319075] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.332853] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.345442] TCP: Hash tables configured (established 1024 bind 1024)
[    0.358164] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.369705] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.382378] NET: Registered protocol family 1
[    0.390960] PCI: CLS 0 bytes, default 32
[    0.395325] rt-timer 10000100.timer: maximum frequency is 1220Hz
[    0.408093] Crashlog allocated RAM at address 0x3f00000
[    0.434876] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.446389] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.468534] io scheduler noop registered
[    0.476178] io scheduler deadline registered (default)
[    0.486683] ralink-usb-phy usbphy: invalid resource
[    0.496865] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.513010] console [ttyS0] disabled
[    0.520058] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20, base_baud = 2500000) is a Palmchip BK-3103
[    0.539735] console [ttyS0] enabled
[    0.553549] bootconsole [early0] disabled
[    0.576124] spi spi0.0: force spi mode3
[    0.584337] m25p80 spi0.0: mx25l12805d (16384 Kbytes)
[    0.594477] 4 ofpart partitions found on MTD device spi0.0
[    0.605411] Creating 4 MTD partitions on "spi0.0":
[    0.614967] 0x000000000000-0x000000030000 : "u-boot"
[    0.626679] 0x000000030000-0x000000040000 : "u-boot-env"
[    0.639228] 0x000000040000-0x000000050000 : "factory"
[    0.651199] 0x000000050000-0x000001000000 : "firmware"
[    0.746692] 2 uimage-fw partitions found on MTD device firmware
[    0.758537] 0x000000050000-0x00000017856f : "kernel"
[    0.770058] 0x00000017856f-0x000001000000 : "rootfs"
[    0.781815] mtd: device 5 (rootfs) set to be root filesystem
[    0.793304] 1 squashfs-split partitions found on MTD device rootfs
[    0.805643] 0x000000c00000-0x000001000000 : "rootfs_data"
[    0.821425] mtk_soc_eth 10100000.ethernet: loaded mt7620 driver
[    0.834093] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5
[    0.851134] rt2880_wdt 10000120.watchdog: Initialized
[    0.862683] NET: Registered protocol family 10
[    0.875753] NET: Registered protocol family 17
[    0.884766] bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfilter if you need this.
[    0.909922] 8021q: 802.1Q VLAN Support v1.8
[    0.933575] VFS: Mounted root (squashfs filesystem) readonly on device 31:5.
[    0.948554] Freeing unused kernel memory: 156K
[    3.404173] init: Console is alive
[    3.411324] init: - watchdog -
[    6.802198] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    6.914466] usbcore: registered new interface driver usbfs
[    6.925593] usbcore: registered new interface driver hub
[    6.936335] usbcore: registered new device driver usb
[    7.119418] raid6: int32x1  gen()    25 MB/s
[    7.298175] raid6: int32x1  xor()    42 MB/s
[    7.467750] raid6: int32x2  gen()    48 MB/s
[    7.638181] raid6: int32x2  xor()    49 MB/s
[    7.807910] raid6: int32x4  gen()    63 MB/s
[    7.977862] raid6: int32x4  xor()    48 MB/s
[    8.148566] raid6: int32x8  gen()    71 MB/s
[    8.317997] raid6: int32x8  xor()    54 MB/s
[    8.326496] raid6: using algorithm int32x8 gen() 71 MB/s
[    8.337085] raid6: .... xor() 54 MB/s, rmw enabled
[    8.346632] raid6: using intx1 recovery algorithm
[    8.357175] xor: measuring software checksum speed
[    8.457721]    8regs     :   418.800 MB/sec
[    8.557723]    8regs_prefetch:   399.200 MB/sec
[    8.657719]    32regs    :   499.600 MB/sec
[    8.757722]    32regs_prefetch:   460.400 MB/sec
[    8.766912] xor: using function: 32regs (499.600 MB/sec)
[    9.369359] Btrfs loaded
[    9.421709] SCSI subsystem initialized
[    9.435422] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    9.450058] ehci-platform: EHCI generic platform driver
[    9.470861] phy phy-usbphy.0: remote usb device wakeup disabled
[    9.482672] phy phy-usbphy.0: UTMI 16bit 30MHz
[    9.491561] ehci-platform 101c0000.ehci: EHCI Host Controller
[    9.503057] ehci-platform 101c0000.ehci: new USB bus registered, assigned bus number 1
[    9.518962] ehci-platform 101c0000.ehci: irq 26, io mem 0x101c0000
[    9.537112] ehci-platform 101c0000.ehci: USB 2.0 started, EHCI 1.00
[    9.550710] hub 1-0:1.0: USB hub found
[    9.558643] hub 1-0:1.0: 1 port detected
[    9.569514] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    9.583323] ohci-platform: OHCI generic platform driver
[    9.594076] ohci-platform 101c1000.ohci: Generic Platform OHCI controller
[    9.607688] ohci-platform 101c1000.ohci: new USB bus registered, assigned bus number 2
[    9.623559] ohci-platform 101c1000.ohci: irq 26, io mem 0x101c1000
[    9.658508] hub 2-0:1.0: USB hub found
[    9.666458] hub 2-0:1.0: 1 port detected
[    9.676925] uhci_hcd: USB Universal Host Controller Interface driver
[    9.705223] usbcore: registered new interface driver usb-storage
[    9.717911] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    9.736658] init: - preinit -
[   10.007850] usb 1-1: new high-speed USB device number 2 using ehci-platform
[   10.662655] random: procd: uninitialized urandom read (4 bytes read, 17 bits of entropy available)
[   10.681138] hub 1-1:1.0: USB hub found
[   10.697533] hub 1-1:1.0: 4 ports detected
[   11.225904] 8021q: adding VLAN 0 to HW filter on device eth0
[   11.312346] usb 1-1.1: new high-speed USB device number 3 using ehci-platform
[   11.375584] usb-storage 1-1.1:1.0: USB Mass Storage device detected
[   11.389007] scsi host0: usb-storage 1-1.1:1.0
[   11.738837] scsi 0:0:0:0: Direct-Access     ASMT     2115             0    PQ: 0 ANSI: 6
[   11.766590] sd 0:0:0:0: [sda] Very big device. Trying to use READ CAPACITY(16).
[   11.781590] sd 0:0:0:0: [sda] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB)
[   11.797072] sd 0:0:0:0: [sda] 4096-byte physical blocks
[   11.808137] sd 0:0:0:0: [sda] Write Protect is off
[   11.817746] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[   11.818360] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   11.837863] sd 0:0:0:0: [sda] Very big device. Trying to use READ CAPACITY(16).
[   12.057938]  sda: sda1 sda2
[   12.066239] sd 0:0:0:0: [sda] Very big device. Trying to use READ CAPACITY(16).
[   12.082337] sd 0:0:0:0: [sda] Attached SCSI disk
[   12.323369] mount_root: loading kmods from internal overlay
[   12.357085] kmodloader: loading kernel modules from //etc/modules-boot.d/*
[   12.376389] kmodloader: done loading kernel modules from //etc/modules-boot.d/*
[   15.612785] jffs2_scan_eraseblock(): End of filesystem marker found at 0x10000
[   15.627238] jffs2_build_filesystem(): unlocking the mtd device... done.
[   15.640444] jffs2_build_filesystem(): erasing all blocks after the end marker... done.
[   40.386657] jffs2: notice: (428) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[   40.417944] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab
[   40.431976] block: unable to load configuration (fstab: Entry not found)
[   40.445486] block: attempting to load /tmp/jffs_cfg/etc/config/fstab
[   40.458422] block: unable to load configuration (fstab: Entry not found)
[   40.487140] block: attempting to load /etc/config/fstab
[   40.576670] block: extroot: not configured
[   40.732385] jffs2: notice: (425) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[   43.287939] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab
[   43.301895] block: unable to load configuration (fstab: Entry not found)
[   43.315539] block: attempting to load /tmp/jffs_cfg/etc/config/fstab
[   43.328454] block: unable to load configuration (fstab: Entry not found)
[   43.342042] block: attempting to load /etc/config/fstab
[   43.353835] block: extroot: not configured
[   43.363661] mount_root: overlay filesystem has not been fully initialized yet
[   43.379609] mount_root: switching to jffs2 overlay
[   44.170272] urandom-seed: Seed file not found (/etc/urandom.seed)
[   44.206864] random: nonblocking pool is initialized
[   44.318238] procd: - early -
[   44.325131] procd: - watchdog -
[   44.890933] procd: - watchdog -
[   44.897556] procd: - ubus -
[   45.108830] procd: - init -
[   45.731585] kmodloader: loading kernel modules from /etc/modules.d/*
[   45.757063] Loading modules backported from Linux version wt-2017-01-31-0-ge882dff19e7f
[   45.773121] Backport generated by backports.git backports-20160324-13-g24da7d3c
[   45.830559] batman_adv: B.A.T.M.A.N. advanced 2016.5 (compatibility version 15) loaded
[   45.934744] rt2800_wmac 10180000.wmac: loaded eeprom from mtd device "factory"
[   45.949259] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 6352, rev 0500 detected
[   45.964718] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 7620 detected
[   45.979147] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[   45.986909] kmodloader: done loading kernel modules from /etc/modules.d/*
[   57.393186] 8021q: adding VLAN 0 to HW filter on device eth0
[   57.420436] device eth0 entered promiscuous mode
[   57.449377] br-lan: port 1(eth0) entered forwarding state
[   57.460243] br-lan: port 1(eth0) entered forwarding state
[   59.677642] br-lan: port 1(eth0) entered forwarding state
[   61.558546] IPv6: ADDRCONF(NETDEV_UP): wlan0-1: link is not ready
[   61.585271] device wlan0-1 entered promiscuous mode
[   61.595166] br-lan: port 2(wlan0-1) entered forwarding state
[   61.606497] br-lan: port 2(wlan0-1) entered forwarding state
[   61.896794] br-lan: port 2(wlan0-1) entered disabled state
[   61.946967] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   65.676140] wlan0: authenticate with 34:76:c5:b2:32:90
[   65.695466] wlan0: send auth to 34:76:c5:b2:32:90 (try 1/3)
[   65.710850] wlan0: authenticated
[   65.718855] wlan0: associate with 34:76:c5:b2:32:90 (try 1/3)
[   65.734618] wlan0: RX AssocResp from 34:76:c5:b2:32:90 (capab=0x411 status=0 aid=9)
[   65.750193] wlan0: associated
[   65.756298] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   65.847543] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0-1: link becomes ready
[   65.860783] br-lan: port 2(wlan0-1) entered forwarding state
[   65.872161] br-lan: port 2(wlan0-1) entered forwarding state
[   67.021826] br-lan: port 2(wlan0-1) entered forwarding state
```

あまり真面目にデバッグしていませんが、
HDDは小基板経由で繋がっているので、
ログに差分の有る 10000638.gpio 辺りが怪しいのかもしれません。

# おまけ1 : opkg設定 バグ対応
先ずは LEDE17.01 としてupgradeしておこうとしましたが、
opkg updateで失敗します。

```
root@LEDE:~# opkg update
・・・
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mipsel_24kc/accesscontrol/Packages.gz
*** Failed to download the package list from http://downloads.lede-project.org/releases/17.01.4/packages/mipsel_24kc/accesscontrol/Packages.gz

Collected errors:
 * opkg_download: Failed to download http://downloads.lede-project.org/releases/17.01.4/packages/mipsel_24kc/accesscontrol/Packages.gz, wget returned 8.
```

そもそも、最新のパッケージを見ても、accesscontrol は無いので、
設定から消すのが正解と思いますので、
下記情報を削除します。

```/etc/opkg/distfeeds.conf
src/gz reboot_accesscontrol http://downloads.lede-project.org/releases/17.01.4/packages/mipsel_24kc/accesscontrol
```

# おまけ2 : HDDフォーマット
以下の投稿に沿いながらHDDを設定すれば、難なくHDDフォーマット・Mountまで成功しました。

- [OpenWrtのrootfsをUSBメモリで拡張する方法](https://qiita.com/somainit/items/014aea356946b13957ff)
- [OpenWrtのrootfsとswapをUSBメモリで拡張する方法](https://qiita.com/somainit/items/12797800741c73369fa8)


```
root@LEDE:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                10.5M     10.5M         0 100% /rom
tmpfs                    61.6M    532.0K     61.1M   1% /tmp
/dev/mtdblock6            4.0M    960.0K      3.1M  23% /overlay
overlayfs:/overlay        4.0M    960.0K      3.1M  23% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                 3.6T     88.0M      3.4T   0% /mnt/sda1
root@LEDE:~# free
             total       used       free     shared    buffers     cached
Mem:        126096      40956      85140        532      11980      10580
-/+ buffers/cache:      18396     107700
Swap:      1048568          0    1048568
```

# まとめ
自力でNASやルーターのOSをOpemWRT/LEDE等に入れ替えてみる際のTipsとしては、以下です。
特殊な場合がもしれませんが、もし行き詰った場合がある方は、試してみると良いかもしれません。

1. ファームアップデートの際に/etcの下をバックアップする設定となっていないか確認する
2. 常に最新版のディストリビューションが最適とは限らない (ブランチにしか反映されていないかもしれない)

では、省電力Linuxサーバーの有る良い生活を!