If you don’t know your way around a linux file system using a console, open a graphical environment, and use a file manager app. Drag and drop.
I used a systemrescue live CD linux to do my clone. Once systemrescue had booted, I used ‘startx
’ to enter the graphical environment. That opens a console window and a file manager window. After changing the console window colours to something sensible, rather than the daft colour scheme it comes up in, I had no problem. I was able to access the image tar file on my existing networked MyCloud, by entering smb:\\<mycloud ip address>
in the file manager location field.
I’ve now written a script to do the clone. If I could find an address that wget would use for the file location, it would be a one-step process. As it is, it requires the user to manually copy the file once the partitions have been created, and the data partition mounted. Script used to create a clone, which worked first time. I’m still not happy with fox’s raid setup, as that still throws warning. I need to investigate how to do this properly, to convince myself that the raid system is working properly.
Here’s the script.
Copy all the formatted text below, save to a file called ‘clone_wd
’,
Put it somewhere in your linux file system that you can get at (e.g. /root
), whatever linux you are using (installed, or liveCD).
Make it executable under linux (chmod 777 clone_wd
).
BEFORE YOU RUN IT, find out what disk you are cloning to (fdisk -l
to list them), and ensure there are NO PARTITIONS ON IT (parted <disk> p
to list, parted <disk> rm <x>
to remove, where <disk>
is e.g. /dev/sda
, etc, and <x>
is the existing partition number). MAKE SURE YOU PICK THE RIGHT DISK; you don’t want to run it on you OS disk…
It may complain if it sees residues of old partitions; select ‘ignore’ of ‘continue’ or ‘accept’ for the warnings.
It’s fairly brutal, and doesn’t handle errors, or anything clever. But it does work. No warranty given or implied… Credit to fox_exe for the original instructions; I’ve just added a bit of automation, and a better (binary) partition map.
Note that isn’t entirely automatic; half way through, it will prompt you to put the original_v4.01.02-417.tar.gz
file in /mnt
. You can either copy it from somewhere, or download it from the link, and get your browser to download it to /mnt
v4.01.02-417: https://drive.google.com/open?id=0B_6OlQ_H0PxVR2czRHB5cnU2bVk
I’ve run it on two disks, and the resulting HDD booted first time in each case.
Run the script as follows
./clone_wd <letter>
where <letter>
is the drive you want to clone to (e.g. ./clone_wd a
for /dev/sda
)
#!/bin/bash
# script to create a WD MyCloud HDD
# cp 04/08/18
# call by 'clone_wd <drive id>'
# e.g. for /dev/sda, use 'clone_wd a'
# n.b. expects a clean HDD, with no pre-existing partitions
# Windows format can be useful, as it will destroy any pre-existing Linux partitions
# set drive name
drive="/dev/sd"$1
# check user wants to do this
echo "This will create a WD MyCloud clone HDD on" $drive
echo "IT WILL DELETE ALL EXISTING DATA"
echo
read -p "Are you sure (y/n)? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Creating clone on" $drive
echo
# Configure HDD partitions
# print existing partitions (should be empty)
echo "the drive should start with no partitions"
echo $drive "contains the current partitions:"
parted $drive unit MiB print
# create partitons
echo
echo "Creating new partitions"
parted $drive mklabel gpt
parted $drive mkpart primary 528MiB 2576MiB
parted $drive mkpart primary 2576MiB 4624MiB
parted $drive mkpart primary 16MiB 528MiB
parted $drive mkpart primary 4828MiB 100%
parted $drive mkpart primary 4624MiB 4724MiB
parted $drive mkpart primary 4724MiB 4824MiB
parted $drive mkpart primary 4824MiB 4826MiB
parted $drive mkpart primary 4826MiB 4828MiB
# configure partitions 1-4
echo
echo "Configuring partitions 1-4"
parted $drive set 1 raid on
parted $drive set 2 raid on
# Set up RAID file system
echo "Creating RAID array on clone"
# stop any existing RAID system
mdadm --stop /dev/md*
# create RAID partitions 1 & 2
# RAID Level 1, with two devices: partitions 1 & 2
mdadm --create /dev/md0 --level=1 --metadata=0.90 --raid-devices=2 ${drive}1 ${drive}2
echo "Setting up swap and data partitions"
# set up swap partition 3
mkswap ${drive}3
# set up data partition 4
mkfs -t ext4 ${drive}4
# show result of partition creation
echo; echo
echo "Partition creation completed"
echo "partitions are created as follows:"
echo
parted $drive unit MiB print
# clone partition data
echo; echo
# use data partition as temporary folder:
echo "Mounting data partition for working area"
mount -t ext4 ${drive}4 /mnt
echo "/mnt created"
echo
# download one of the archives to /mnt folder:
echo "Please copy original_v04.01.02-417.tar.gz to /mnt"
echo
read -p "press 'y' when you have done this " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# extract partition images from archive
echo "Extracting images"
cd /mnt
tar xvfz original_v04.01.02-417.tar.gz
# copy images to partitions 5-8
echo
echo "Copying images to partitions 5-8"
dd if=kernel.img of=${drive}5
dd if=kernel.img of=${drive}6
dd if=config.img of=${drive}7
dd if=config.img of=${drive}8
# start RAID array
echo
echo "Starting RAID array"
mdadm --stop /dev/md0
mdadm --assemble /dev/md0 ${drive}1 ${drive}2
# copy rootfs image to RAID array
echo "Copying rootfs"
echo "this could take a while..."
dd if=rootfs.img of=/dev/md0
# Tell device to do fresh install (Fix for "0 MB usage" in webgui)
echo
echo "Preparing for first boot"
mkdir /mnt/hdd
mount /dev/md0 /mnt/hdd
touch /mnt/hdd/etc/.fresh_install
umount /mnt/hdd
cd ~
umount /mnt
echo
echo "Finished!"
echo
echo "now connect HDD to MyCloud PCB"
echo "connect ethernet and apply power"
echo "should get white light, followed by blue light after 5-10 minutes"
echo "do a 40-second reset when the LED turns blue"
echo "wait for blue LED, then access Dashboard"
echo "upgrade to whatever firmware you want"
echo "do another 40-second reset when LED turns blue"
echo "configure device as required"
else
echo "abandoning"
fi
else
echo "abandoning"
fi