Last active
January 28, 2019 21:22
-
-
Save mmuruev/220dc5dd181303d8c32ffe954e86f8c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# WD Cloud repair script will destroy all data and system partitions!!! | |
# based on http://anionix.ddns.net/WDMyCloud/WDMyCloud-Gen1/Replace%20HDD.txt | |
DEVICE=/dev/sdd | |
MOUNT_DIR=/mnt/wdcloud | |
echo 'WD Cloud repair script will destroy all data and system partitions!!!' | |
echo 'Formating device: ' ${DEVICE} | |
read -p "Are you sure? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
# do dangerous stuff | |
OUTPUT=$( | |
parted --script ${DEVICE}\ | |
mklabel gpt \ | |
mkpart primary 528M 2576M \ | |
mkpart primary 2576M 4624M \ | |
mkpart primary 16M 528M \ | |
mkpart primary 4828M 100% \ | |
mkpart primary 4624M 4724M \ | |
mkpart primary 4724M 4824M \ | |
mkpart primary 4824M 4826M \ | |
mkpart primary 4826M 4828M \ | |
set 1 raid on \ | |
set 2 raid on | |
) | |
echo ${OUTPUT} | |
sync | |
echo $(mkswap ${DEVICE}3) | |
echo $(mkfs.ext4 ${DEVICE}4) | |
sync | |
echo $(mdadm --stop /dev/md*) | |
echo $(mdadm -A /dev/md0 ${DEVICE}1 ${DEVICE}2) | |
echo $(mdadm --create /dev/md0 --level=1 --metadata=0.9 --raid-devices=2 ${DEVICE}1 ${DEVICE}2) | |
# mkdir -p "$(dirname ${MOUNT_DIR})"; | |
# mount -t ext4 ${DEVICE}4 ${MOUNT_DIR} # && cd ${MOUNT_DIR} && tar xvfz original_v3.04.01-230.tar.gz | |
sync | |
dd if=kernel.img of=${DEVICE}5 bs=128M status=progress && | |
dd if=kernel.img of=${DEVICE}6 bs=128M status=progress && | |
dd if=config.img of=${DEVICE}7 bs=128M status=progress && | |
dd if=config.img of=${DEVICE}8 bs=128M status=progress && | |
dd if=rootfs.img of=/dev/md0 bs=128M status=progress | |
# && umount ${MOUNT_DIR} | |
#FIRST RUN MARK | |
sync | |
mkdir -p ${MOUNT_DIR}/hdd | |
mount /dev/md0 ${MOUNT_DIR}/hdd | |
touch ${MOUNT_DIR}/hdd/etc/.fresh_install | |
umount ${MOUNT_DIR}/hdd && | |
rmdir ${MOUNT_DIR}/hdd | |
sync | |
echo "ALL DONE!!" | |
fi | |
echo "Exit" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment