Clone NAS hard drive to SSD

If I remember right (without access to Linux at the moment) you can use the Linux file manager to find the Download folder then right click on the folder or file and tell Linux to open a terminal window in that folder. I think I was able to do that using the Ubuntu LiveCD.

Tell Firefox where to download it to; there’s a preferences setting to ‘always ask where to download’. I always have this selected, so I know where FF will put stuff.

If you don’t know where Firefox has downloaded it to, click on the download icon at top right (down arrow with underscore). Hit ‘show all downloads’. Find your image download. Hit the little folder icon to the right; that will open the location it was downloaded to. Move/copy the tar.gz file to/mnt.

To check it is there, use ls when in /mnt

Are you using a GUI desktop, or a pure shell? The GUI desktop will have a file manager.

Do an ls while in the /home/bill directory.

That’s what I’ve been trying to do. the tar.gz file is in the download folder, so what is the “mv” command to move it from download to /mnt? I’ve not been able to get that to work.

mv ~/Downloads/[name.tar.gz] /mnt/[name.tar.gz]

On linux systems, the ~/ folder is special, and is shorthand for the sometimes absurdly long path to your user’s home directory. You will have to do that under your normal user’s credentials so that the shell knows who’s home directory to navigate to. THEN you can become super user and do the needful.

Yes. *nix systems use proper case sensitivity in their file systems. A fun feature (if you dont want to type out hugely long filenames) is “tab completion”.

Basically, when doing the tar invocation, do “tar -xvfz orig” then press the tab key. Watch in pleased wonder as the command line magically completes for you. :stuck_out_tongue:

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

Unless “Mount Points” are not treated like folder names I have no clue what the problem is here?
Screenshot%20from%202018-08-06%2009-43-56

Why have you got square braces around the filename?

You’ve got a graphical file manager there. Use it to copy to /mnt.

Or just use

cp ~/Downloads/original_v04.01.02-417.tar.gz /mnt

You don’t have to give the full target path, just the directory.

Because Wierd_w replied to my question showing brackets.

Linux won’t let me copy either:

Are you logged in as root? Or a common user?

“Common” but it didn’t work in root either

Were there any error messages when you did the mkfs or mount commands for /dev/sda4?

Can you do a ls -la /mnt

and a parted /dev/sda p

and a ls -la / while we’re at it.

Sure. 1st ls and the parted: (sda is debian and sdb is the “brick”)

and the 2nd of your requests:

Get the path right. You have used capitals, where you shouldn’t have, and have got confused with /root and /home and ~/

Note the error messages: one says it cant find the file, one says no permission. Those error messages are Clues. Use them.

cp /home/bill/Downloads/original_v3.04.02-230.tar.gz /mnt

Or, as I keep suggesting, use the graphical file manager, as it’s clear you’re struggling with understanding linux file systems.

Somehow we’re not tracking. My post 129 clearly shows my attempts with what you stipulated and it failed. I will try your 133 post exactly as posted:

There is a Mount Point /mnt in /dev/sdb4

okay, let’s see what you’ve actually got in your Downloads folder:

ls -la /home/bill/Downloads

Screenshot%20from%202018-08-06%2011-05-32

And now can you spot the mistake?

cp /home/bill/Downloads/original_v03.04.01-230.tar.gz /mnt

Check I’ve got the filename right this time.

Or use your graphical file manager…

Sure. The problem originated from a copy/paste operation where the file name stipulated was for version 04. When the copy/paste operation was completed the “02” never got changed to “01”, only the “04” to “03”. My BAD I think.

A very small computer response delay while the file copied without error message so I will proceed with the de-bricking menu.

Screenshot%20from%202018-08-06%2011-15-27

No, it was my bad; typing in the .tar.gz filename incorrectly.

That’s why graphical file managers and drag and drop are much nicer…

But if the error message says ‘No such file or directory’, you check you’ve typed the names correctly. If the error message is ‘Permission denied’, you check the directory file permissions.