Wouldn’t it be great if you could make a “system backup” so you could restore
your GoFlex Home system from USB? Well
you can and I’ll show you how to do it. You will need a Linux PC but it’s easy
to install Linux on an old laptop.
Background
Inside the firmware file that you used to be able to download from the Seagate site, there are 3 files, initrd, uImage and hipserv2_seagateplug-20120508.ubi. Initrd is the initial ram disk or temporary boot system, uImage is the Linux kernel which is kind of like ms-dos in a Windows system and finally hipserv2_seagateplug-20120508.ubi is the Linux OS which is the GoFlex Home firmware. I always thought it should be possible to either modify the ubi file or replace it with another one, but didn’t spend time on it while the seagateshare.com server was available to initialize the system because it’s only a small inconvenience to set up accounts and configure settings again.Now that the seagateshare.com server has shut down we need an alternative to the stock firmware, because without a way to create the first user account the GoFlex Home would be useless after a firmware reflash. Searching the web there are guides for installing custom firmware but they involve replacing u-boot and could end up either turning the GoFlex Home into a paper weight or having to open up the box and connect a serial cable to fix it.
I was surprised that no-one seems to have fully solved how to do what I wanted to do and the closest I found was a page from Beyond Logic (kudos to Craig Peacock) which provided some very useful information.But the pre-built mtd-utils binaries failed with GLIBC_2.27' not found errors. I spent a bit of time working on that problem before realising that I could just emulate flash NAND on a separate Linux box. So I dug an old Asus EeePC out of a cupboard, installed Ubuntu Mate and got to work.To make it more interesting though, some of the values on the Beyond Logic page turned out to be incorrect at least for my particular GoFlex Home but in the end I finally got a loadable ubi image.
Procedure
commands you enter are in blue, output in white and as always, check my disclaimer first and while this works great for me I can’t guarantee your results.----- On the GoFlex Home ------
First create an
image of your GoFlex Home system files, so login with SSH and become root user and then run the command below, changing the “of=” path to suit. I have assumed the
output file path is a USB stick named “USB” in the GoFlex Home External Storage
(USB) port.
And be patient
- it will look like nothing is happening for a minute or so.
dd if=/dev/mtd2 of=External\ Storage/USB/mtd2.img
dd if=/dev/mtd2 of=External\ Storage/USB/mtd2.img
509952+0 records in
509952+0 records out
261095424 bytes (261 MB, 249 MiB) copied, 83.3194 s, 3.1 MB/s
509952+0 records out
261095424 bytes (261 MB, 249 MiB) copied, 83.3194 s, 3.1 MB/s
----- On the Linux PC -----
Transfer the
mtd2.image file you created above to the Linux PC, the instructions below assume
that it has been copied to the Downloads folder.
sudo -s to become root user
You will probably need to install mtd-utils first
You will probably need to install mtd-utils first
apt-get install mtd-utils on Ubuntu Mate
(simulate a NAND flash
device with 3 partitions like the GoFlex Home)
modprobe nandsim
first_id_byte=0x98 second_id_byte=0xda third_id_byte=0x00 fourth_id_byte=0x15
parts=8,48
(load the mtd2 image to
the simulated NAND mtd2 partition, assuming the mtd2.img is in the Downloads folders)
dd
if=Downloads/mtd2.img of=/dev/mtd2
509952+0 records in
509952+0 records out
261095424 bytes (261 MB, 249 MiB) copied,
15.8653 s, 16.5 MB/s
(load the ubi kernel module)
modprobe ubi
(attach the device mtd2 to the ubi device)
ubiattach /dev/ubi_ctrl -m 2 -O 2048
UBI device number 0, total 1992 LEBs (252936192 bytes, 241.2 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
(make a mountpoint)
mkdir /mnt/ubifs
(mount ubifs)
mount -t ubifs
/dev/ubi0_0 /mnt/ubifs
(make a zlib compressed
ubifs image in the Downloads folder)
mkfs.ubifs -v -x zlib
-m 2048 -e 126976 -c 1992 -r /mnt/ubifs Downloads/ubifs.img
mkfs.ubifs
root: /mnt/ubifs/
root: /mnt/ubifs/
min_io_size: 2048
leb_size: 126976
max_leb_cnt: 1992
output: Downloads/ubifs.img
jrn_size: 8388608
reserved: 0
compr: zlib
keyhash: r5
fanout: 8
orph_lebs: 1
space_fixup: 0
super lebs: 1
master lebs: 2
log_lebs: 5
lpt_lebs: 2
orph_lebs: 1
min_lebs: 3
gc lebs: 1
index lebs: 1
leb_cnt: 14
UUID: 3CE0EE8F-32C6-4B7B-9CC3-FBDDD5CDEDF6
leb_size: 126976
max_leb_cnt: 1992
output: Downloads/ubifs.img
jrn_size: 8388608
reserved: 0
compr: zlib
keyhash: r5
fanout: 8
orph_lebs: 1
space_fixup: 0
super lebs: 1
master lebs: 2
log_lebs: 5
lpt_lebs: 2
orph_lebs: 1
min_lebs: 3
gc lebs: 1
index lebs: 1
leb_cnt: 14
UUID: 3CE0EE8F-32C6-4B7B-9CC3-FBDDD5CDEDF6
Success!
Create a text file named
ubi.cfg in the Downloads folder (or anywhere else you want it but then change
the path in the subsequent ubinize command) containing the following text;
[ubifs]
mode=ubi
image= Downloads/ubifs.img
vol_id=0
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
mode=ubi
image= Downloads/ubifs.img
vol_id=0
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
(ubinize the image; note
that the Offset I found to work is 2048 and the offset of 512 from the Beyond
Logic page didn’t work for me)
ubinize -v -o
Downloads/goflex_home.ubi -m 2048 -p 128KiB -s 512 -O 2048 Downloads/ubi.cfg
ubinize: LEB size: 126976
ubinize: PEB size: 131072
ubinize: min. I/O size: 2048
ubinize: sub-page size: 512
ubinize: VID offset: 2048
ubinize: data offset: 4096
ubinize: UBI image sequence number:
969735018
ubinize: loaded the ini-file
"Downloads/ubi.cfg"
ubinize: count of sections: 1
ubinize: parsing section
"ubifs"
ubinize: mode=ubi, keep parsing
ubinize: volume type: dynamic
ubinize: volume ID: 0
ubinize: volume size was not specified in
section "ubifs", assume minimum to fit image
"Downloads/ubifs.img"1777664 bytes (1.7 MiB)
ubinize: volume name: rootfs
ubinize: volume alignment: 1
ubinize: autoresize flags found
ubinize: adding volume 0
ubinize: writing volume 0
ubinize: image file: Downloads/ubifs.img
ubinize: writing layout volume
ubinize: done
That’s it. Now you can
replace the stock firmware hipserv2_seagateplug-20120508.ubi file with the goflex_home.ubi
file you just created and together with the stock initrd and uImage files you
should have a bootable firmware.