Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chinkiko/f850f2ae3a8c6e274dc73d7ceea0aebf to your computer and use it in GitHub Desktop.
Save chinkiko/f850f2ae3a8c6e274dc73d7ceea0aebf to your computer and use it in GitHub Desktop.
Install OpenWRT or LEDE on WD MBL Western Digital MyBookLive
!! openwrt-mybooklive support Flash new firmware image using zip file "MBL.img.gz"
https://openwrt.org/toh/wd/mybooklive#upgrading
OpenWrt on the MBL can be upgraded using LuCI and sysupgrade. It directly takes a gzipped image file ending in .img.gz which does not have to (and due to memory constraints probably shouldn't) be unzipped.
# Instructions to Install OpenWRT or LEDE on WD MBL Western Digital MyBookLive (Tested on Single, but it should work on Duo too)
# Recommended to use a Linux / Debian box with wget, dd, gunzip, lsblk
# First, wget the file:
# Links of Lede 17.01.1 and 17.01.2 for Single
wget http://downloads.lede-project.org/releases/17.01.1/targets/apm821xx/sata/lede-17.01.1-apm821xx-sata-MyBookLiveSingle-ext4-rootfs.img.gz
wget http://downloads.lede-project.org/releases/17.01.2/targets/apm821xx/sata/lede-17.01.2-apm821xx-sata-MyBookLiveSingle-ext4-rootfs.img.gz
# Links of Lede 17.01.1 and 17.01.2 for Duo
wget http://downloads.lede-project.org/releases/17.01.1/targets/apm821xx/sata/lede-17.01.1-apm821xx-sata-MyBookLiveDuo-ext4-rootfs.img.gz
wget http://downloads.lede-project.org/releases/17.01.2/targets/apm821xx/sata/lede-17.01.2-apm821xx-sata-MyBookLiveDuo-ext4-rootfs.img.gz
# See in http://downloads.lede-project.org/releases/ if there is a new release and follow the common path:
/targets/apm821xx/sata/lede-17.01.2-apm821xx-sata-MyBookLiveSingle-ext4-rootfs.img.gz
/targets/apm821xx/sata/lede-17.01.2-apm821xx-sata-MyBookLiveDuo-ext4-rootfs.img.gz
# Now g unzip the file:
gunzip lede-*-apm821xx-sata-MyBookLive*-ext4-rootfs.img.gz
# Now use lsblk or any tool you like to check the connected HardDrive (there is no problem if it has info or not, but partition table and first about 256mb of disk data will be lost)
# The drive could be connected using USB, it should work (I tested)
# For example for /dev/sdb
dd if=lede-*-apm821xx-sata-MyBookLive*-ext4-rootfs.img of=/dev/sdb
# Run `sync` and disconnect the drive, and put in on the MyBookLive box
sync
# Now MyBookLive will have DHCP running so you could connect it first directly to your computer, or change your computer ip range to 192.168.1.5 and gateway 192.168.1.1 if you connect to existing network (if you have your current gateway on other IP, if you have on same IP you need to connect to your computer first)
# Connect using ssh:
ssh root@192.168.1.1
# We disable DHCP and configure as DHCP client: **(or create /etc/config/network)**
uci set network.lan.proto='dhcp'
uci del network.lan.ipaddr
uci del network.lan.netmask
uci commit network
/etc/init.d/network restart
# Now you could connect the MyBookLive to your existing network and check the new IP of the MBL
# Connect again using SSH.
opkg update
opkg find *partitions*
#cgdisk - 1.0.1-1 - ncurses-based partition table manipulation utility with GPT support.
# Similar to sfdisk, but works with GPT partitions. Shares the same limitations
# of the gdisk partition utility. While it can read and convert MBR partitions
# in GPT, it cannot modify MBR partitions on its own.
#gdisk - 1.0.1-1 - GPT partition table manipulation utility with an interface
# similar to fdisk. It can read and convert MBR partitions in GPT
# but is otherwise unable to generate or modify MBR partitions.
#kmod-mtd-rw - 4.4.61+git-20160214-1 - A kernel module that temporarily makes all MTD partitions writeable.
#libblkid - 2.29.2-1 - The libblkid library is used to identify block devices (disks) as to their
# content (e.g. filesystem type, partitions) as well as extracting additional
# information such as filesystem labels/volume names, partitions, unique
# identifiers/serial numbers...
#sfdisk - 2.29.2-1 - list the size of a partition, list the partitions on a device, check the
# partitions on a device and repartition a device
#sgdisk - 1.0.1-1 - Script-friendly GPT partition table manipulation utility.
# It can read and convert MBR partitions in GPT but is otherwise
# unable to generate or modify MBR partitions.
# To the contrary of gdisk, its interface is geared towards scripts,
# so it takes command line arguments instead of being interactive.
# It will NOT ask confirmation before carrying out the operations.
# It has a slightly smaller footprint than gdisk tool.
#opkg install cgdisk
cgdisk /dev/sda # no reconoce nada
# If you need, we look for partition to see current layout (to check later against gdisk)
root@LEDE:~# fdisk -l /dev/sda
# Disk /dev/sda: 5.5 TiB, 6001175126016 bytes, 11721045168 sectors
# Units: sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 4096 bytes
# I/O size (minimum/optimal): 4096 bytes / 4096 bytes
# Disklabel type: dos
# Disk identifier: 0x5452574f
#
# Device Boot Start End Sectors Size Id Type
# /dev/sda1 * 8192 24575 16384 8M 83 Linux
# /dev/sda2 32768 557055 524288 256M 83 Linux
opkg install gdisk
gdisk /dev/sda
# GPT fdisk (gdisk) version 1.0.1
#
# Type device filename, or press <Enter> to exit: /dev/sda
# Caution: invalid main GPT header, but valid backup; regenerating main header
# from backup!
#
# Caution! After loading partitions, the CRC doesn't check out!
# Warning! Main partition table CRC mismatch! Loaded backup partition table
# instead of main partition table!
#
# Warning! One or more CRCs don't match. You should repair the disk!
#
# Partition table scan:
# MBR: MBR only
# BSD: not present
# APM: not present
# GPT: damaged
#
# Found valid MBR and corrupt GPT. Which do you want to use? (Using the
# GPT MAY permit recovery of GPT data.)
# 1 - MBR
# 2 - GPT
# 3 - Create blank GPT
#
# Your answer:
If we updated using another `dd` image then we could choose option 2
since the partition table on GPT is correct and we could see current data on 3rd partition.
If this is the first time we use the disk with LEDE using `dd` we should choose 1
and write layour copied from MBR
Command (? for help): 1 #-> Here it uses MBR and copies its layout
# Your answer: 1
#
Command (? for help): p
# Disk /dev/sda: 11721045168 sectors, 5.5 TiB
# Logical sector size: 512 bytes
# Disk identifier (GUID): AA739863-D3C2-41AE-8988-1357F45A83E3
# Partition table holds up to 128 entries
# First usable sector is 34, last usable sector is 11721045134
# Partitions will be aligned on 2048-sector boundaries
# Total free space is 11720504429 sectors (5.5 TiB)
#
# Number Start (sector) End (sector) Size Code Name
# 1 8192 24575 8.0 MiB 8300 Linux filesystem
# 2 32768 557055 256.0 MiB 8300 Linux filesystem
#
Command (? for help): w #-> save changes
#
# Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
# PARTITIONS!!
#
Do you want to proceed? (Y/N): y
# OK; writing new GUID partition table (GPT) to /dev/sda.
# Warning: The kernel is still using the old partition table.
# The new table will be used at the next reboot or after you
# run partprobe(8) or kpartx(8)
# The operation has completed successfully.
reboot
# Now we are gonna create additional 3rd partition for data:
root@LEDE:~# gdisk /dev/sda
# GPT fdisk (gdisk) version 1.0.1
#
# Partition table scan:
# MBR: protective
# BSD: not present
# APM: not present
# GPT: present
#
# Found valid GPT with protective MBR; using GPT.
#
Command (? for help): _
# b back up GPT data to a file
# c change a partition's name
# d delete a partition
# i show detailed information on a partition
# l list known partition types
# n add a new partition
# o create a new empty GUID partition table (GPT)
# p print the partition table
# q quit without saving changes
# r recovery and transformation options (experts only)
# s sort partitions
# t change a partition's type code
# v verify disk
# w write table to disk and exit
# x extra functionality (experts only)
# ? print this menu
#
Command (? for help): n
Partition number (3-128, default 3): #-> Enter
First sector (34-11721045134, default = 557056) or {+-}size{KMGTP}: #-> Enter
Last sector (557056-11721045134, default = 11721045134) or {+-}size{KMGTP}: #-> Enter
# Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): #-> Enter
# Changed type of partition to 'Linux filesystem'
#
Command (? for help): p
# Disk /dev/sda: 11721045168 sectors, 5.5 TiB
# Logical sector size: 512 bytes
# Disk identifier (GUID): AA739863-D3C2-41AE-8988-1357F45A83E3
# Partition table holds up to 128 entries
# First usable sector is 34, last usable sector is 11721045134
# Partitions will be aligned on 2048-sector boundaries
# Total free space is 16350 sectors (8.0 MiB)
#
# Number Start (sector) End (sector) Size Code Name
# 1 8192 24575 8.0 MiB 8300 Linux filesystem
# 2 32768 557055 256.0 MiB 8300 Linux filesystem
# 3 557056 11721045134 5.5 TiB 8300 Linux filesystem
#
Command (? for help): w
#
# Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
# PARTITIONS!!
#
# Do you want to proceed? (Y/N): y
# OK; writing new GUID partition table (GPT) to /dev/sda.
# Warning: The kernel is still using the old partition table.
# The new table will be used at the next reboot or after you
# run partprobe(8) or kpartx(8)
# The operation has completed successfully.
reboot
opkg update
opkg install kmod-fs-ext4 e2fsprogs block-mount
# We format ext4 the 3rd partition and we assign a label
time mkfs.ext4 -L Data /dev/sda3 # 32m 42.47s in MyBookLive Single disk 6TB Purple
# We create mount point for ext4 3rd partition.
mkdir -p /mnt/Data
# We mount ext4 (if it was powered of in improper way it will be slower about 22seg, if not 0.5seg)
time mount -v -o sync /dev/sda3 /mnt/Data
# Unmount ext4 data partition
time umount -v /mnt/Data/
# ------------------------------------------------------------------------------------
# Status Led's.
# ------------------------------------------------------------------------------------
uci del system.@led[-1]
uci add system led
uci set system.@led[-1].name='Alive'
uci set system.@led[-1].sysfs='mbl:blue:power'
uci set system.@led[-1].default='0'
uci set system.@led[-1].trigger='timer'
uci set system.@led[-1].delayon='1000'
uci set system.@led[-1].delayoff='500'
uci add system led
uci set system.@led[-1].name='DiskUsage'
uci set system.@led[-1].sysfs='mbl:green:power'
uci set system.@led[-1].default='0'
uci set system.@led[-1].trigger='disk-activity'
# Additional if we want to manually turn on red Led on some Error.
uci add system led
uci set system.@led[-1].name='Error'
uci set system.@led[-1].sysfs='mbl:red:power'
uci set system.@led[-1].default='0'
uci set system.@led[-1].trigger='default-on'
To be continued...
Debian_Lenny:MBL_OS
http://mybookworld.wikidot.com/optware
ENTware (NOT ARCH on official http://bin.entware.net/)
http://ipkg.nslu2-linux.org/feeds/optware/ds101g/cross/stable/
OpenWRT
https://openwrt.org/toh/wd/mybooklive
http://downloads.openwrt.org/releases/18.06.1/targets/apm821xx/sata/
http://downloads.openwrt.org/releases/18.06.1/packages/powerpc_464fp/packages/
Golang
@chinkiko
Copy link
Author

chinkiko commented May 15, 2018

root@LEDE:/etc/config# cat network

config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option ula_prefix 'fd97:fece:576c::/48'

config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'

root@LEDE:/etc/config# uci set network.lan.proto='dhcp'
root@LEDE:/etc/config# uci del network.lan.ipaddr
root@LEDE:/etc/config# uci del network.lan.netmask
root@LEDE:/etc/config# uci commit network
root@LEDE:/etc/config# cat network

config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option ula_prefix 'fd97:fece:576c::/48'

config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option ip6assign '60'
option proto 'dhcp'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment