As I have lost a lots of time to find out those scripts that allows to reinstall the
firmware I think it is a good idea to put it there for those who will experience same problem as me:
updateFirmwareFromFile.sh
share-param.sh
disk-param.sh
and maybe:
freshInstall.sh
partitionDisk.sh
Quick remind of the whole process:
1. get the last firmware .deb file:
Link western digital official manual firmware install page:
(not allowed to post links)
support[dot]wdc[dot]com[slash]product[slash]release2info[dot]asp?lang=en
from /CacheVolume/ folder
#wget <put the url here>
like for the last, today:
#wget http:[slash][slash]download[dot]wdc[dot]com[slash]nas[slash]apnc-021109-053-20120413[dot]deb
rename the file
#mv apnc-021109-053-20120413.deb updateFile.deb
2.verify if you have those files in /usr/local/sbin
#ls -l /usr/local/sbin
you should have minimum:
updateFirmwareFromFile.sh
share-param.sh
disk-param.sh
and maybe:
freshInstall.sh
partitionDisk.sh
that can be usefull
3.if not create by copy paste from here (winscp is good for that from windows)
4.change files roles to allows execute
# chmod +x *.sh
5.launch force reinstall
# updateFirmwareFromFile.sh /CacheVolume/updateFile.deb
# reboot
the scripts:
updateFirmwareFromFile.sh
#!/bin/bash
#
# � 2010 Western Digital Technologies, Inc. All rights reserved.
#
# updateFirmwareFromFile.sh <filename>
#
#
#---------------------
# add stderr to stdout
exec 2>&1
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
. /usr/local/sbin/share-param.sh
. /usr/local/sbin/disk-param.sh
source /etc/system.conf
SYSTEM_SCRIPTS_LOG=${SYSTEM_SCRIPTS_LOG:-"/dev/null"}
# Output script log start info
{
echo "Start: `basename $0` `date`"
echo "Param: $@"
} >> ${SYSTEM_SCRIPTS_LOG}
#
{
#---------------------
# Begin Script
#---------------------
restoreRaid ()
{
currentRootDevice=`cat /proc/cmdline | awk '/root/ { print $1 }' | cut -d= -f2`
duplicate_md=
if [ "${currentRootDevice}" != "/dev/nfs" ]; then
# stop any duplicate md devices and make sure both disks are part of the current rootfs md device
if [ "${currentRootDevice}" == "/dev/md0" ]; then
if [ -e /dev/md1 ]; then
duplicate_md="/dev/md1"
fi
elif [ "${currentRootDevice}" == "/dev/md1" ]; then
if [ -e /dev/md0 ]; then
duplicate_md="/dev/md0"
fi
fi
if [ ! -z ${duplicate_md} ]; then
echo "stopping duplicate md device ${duplicate_md}"
mdadm --stop ${duplicate_md}
mdadm --wait ${duplicate_md}
sleep 1
fi
# always attempt to add both mirror partitions - its ok to fail if they are already there
mdadm ${currentRootDevice} --add ${rootfsDisk1} > /dev/null 2>&1
mdadm --wait ${currentRootDevice}
mdadm ${currentRootDevice} --add ${rootfsDisk2} > /dev/null 2>&1
mdadm --wait ${currentRootDevice}
sleep 1
fi
}
filename=${1}
updatelog="/CacheVolume/update.log"
if [ $# != 1 ]; then
echo "usage: updateFirmwareFromFile.sh <filename>"
exit 1
fi
if [ ! -f ${filename} ]; then
echo "File not found"
exit 1
fi
# check disk usage
dfout=`df | grep /DataVolume`
avail=`echo "$dfout" | awk '{printf("%d",$2-$3)}'`
if [ "${avail}" -lt "${fwUpdateSpace}" ]; then
error="failed 201 \"not enough space on device for upgrade\""
echo ${error} > /tmp/fw_update_status
echo ${error}
exit 1
fi
# ITR No. 34229 Abstract: 3.5G allows down rev code to be applied from file
version_current=`cat /etc/version | tr -d .-`
version_newfile=`dpkg -f ${filename} Version`
version_newfile=`echo ${version_newfile} | tr -d .-`
echo "version_newfile=$version_newfile"
echo "version_current=$version_current"
package_newfile=`dpkg -f ${filename} Package`
echo "package_newfile=$package_newfile"
echo "master_package_name=$master_package_name"
if [ "${master_package_name}" != "${package_newfile}" ] || [ "${version_newfile}" -lt "${version_current}" ]; then
error="failed 200 \"invalid firmware package\""
echo ${error} > /tmp/fw_update_status
echo "Error: $0 (${filename}) version ($version_newfile) is less than current system version ($version_current)"
echo "Error: $0 (${filename}) version ($version_newfile) is less than current system version ($version_current)" | logger
exit 1
fi
old_color=`cat /usr/local/nas/led_color`
echo white > /usr/local/nas/led_color
#upgrade
dpkg -i ${filename} 2>&1 | tee ${updatelog} > /dev/null
status=$?
# remove update files
rm -f /CacheVolume/*.deb
cat ${updatelog} | grep -q "not a debian format archive"
if [ $? -eq 0 ]; then
error="failed 200 \"invalid firmware package\""
echo ${error} > /tmp/fw_update_status
echo ${error}
restoreRaid
if [ "$old_color" == "red" ]; then
echo "red" > /usr/local/nas/led_color
else
echo "green" > /usr/local/nas/led_color
fi
exit 1
fi
if [ ${status} -ne 0 ]; then
echo "dkpg exited with non-zero status: ${status}"
error="Update failed. Check ${updatelog} for details."
echo ${error} > /tmp/fw_update_status
echo ${error}
restoreRaid
if [ "$old_color" == "red" ]; then
echo "red" > /usr/local/nas/led_color
else
echo "green" > /usr/local/nas/led_color
fi
fi
#---------------------
# End Script
#---------------------
# Copy stdout to script log also
} | tee -a ${SYSTEM_SCRIPTS_LOG}
# Output script log end info
{
echo "End:$?: `basename $0` `date`"
echo ""
} >> ${SYSTEM_SCRIPTS_LOG}
exit ${status}
share-param.sh
#!/bin/sh
#
# ? 2010 Western Digital Technologies, Inc. All rights reserved.
#
###########################################
# share setup files
###########################################
trustees=/etc/trustees.conf
sambaOverallShare=/etc/samba/overall_share
hostsConfig=/etc/hosts
networkConfig=/etc/network/interfaces
dnsConfig=/etc/resolv.conf
dhclientConfig=/etc/dhcp3/dhclient.conf
ntpConfig=/etc/default/ntpdate
smbConfig=/etc/samba/smb.conf
remoteAccessConfig=/etc/remote_access.conf
itunesConfig=/etc/forked-daapd.conf
upgrade_link=/tmp/fw_upgrade_link
userConfig=/etc/passwd
passwdConfig=/etc/shadow
smbpasswdConfig=/etc/samba/smbpasswd
ownerUid=999
adminDefaultAlias="admin-dfalias-wd"
# 3G required for F/W update
fwUpdateSpace="3000000"
fileTally=/var/local/nas_file_tally
twonky_dir=/usr/local/twonkymedia-5
# bash scripts logging for debugging use.. currently not all scripts are instrumented.
# SYSTEM_SCRIPTS_LOG="/var/log/wdscripts.log"
disk-param.sh
#!/bin/sh
###########################################
# ? 2010 Western Digital Technologies, Inc. All rights reserved.
#
# definition list for a 1NC product
###########################################
factoryRestoreSettings=/etc/.factory_restore_settings
reformatDataVolume=/etc/.reformat_data_volume
diskWarningThresholdReached=/etc/.freespace_failed
disk=/dev/sdf
dataVolumeDevice="${disk}4"
swapDevice="${disk}3"
rootfsDevice="/dev/md0"
rootfsDisk1="${disk}1"
rootfsDisk2="${disk}2"
blockSize=64k
blockCount=31247
# The fill pattern needs to be verified for every release to manufacturing
backgroundPattern=0xE5
freshInstall.sh
#!/bin/sh
#
# � 2010 Western Digital Technologies, Inc. All rights reserved.
#
# freshInstall.sh
#
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
. /path/to/parted/disk-param.sh
# create the new disk partitions
./partitionDisk.sh
# clear out any old md superblock data
mdadm --zero-superblock --force --verbose ${rootfsDisk1} > /dev/null
mdadm --zero-superblock --force --verbose ${rootfsDisk2} > /dev/null
sync
mdadm --create ${rootfsDevice} --verbose --raid-devices=2 --level=raid1 --run ${rootfsDisk1} missing
mdadm --wait ${rootfsDevice}
sleep 1
# create the swap partition
mkswap ${disk}3
# format the rootfs raid mirror file system
mkfs.ext3 -c -b 4096 ${rootfsDevice}
# format the data volume file system
mkfs.ext4 -b 65536 -m 0 ${disk}4
#mkfs.xfs -f -b size=65536 ${disk}4
sync
sleep 2
# mount and configure the data volume
# add the second partition to the raid mirror
mdadm ${rootfsDevice} --add --verbose ${rootfsDisk2}
sleep 1
echo
echo "Please wait for raid RE-SYNC to complete.."
sleep 1
mdadm --wait ${rootfsDevice}
mdadm --detail ${rootfsDevice}
echo "Done."
sync
# a reboot is performed by the caller
partitionDisk.sh
#!/bin/sh
#
# � 2010 Western Digital Technologies, Inc. All rights reserved.
#
# partitionDisk.sh
#
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
. /path/to/disk-param.sh
# Apollo 3G parition layout:
#
# /dev/md0 -RFS
# /dev/${disk}1 - RFS (main)
# /dev/${disk}2 - RFS (backup)
#/dev/${disk}3 - swap
#/dev/${disk}4 - /DataVolume (includes /var)
#
echo "Partition Disk: ${disk}..."
backgroundPattern="${backgroundPattern:-0}"
#
# this script assumes that all preparatory steps have already been taken!
#
# clear any old partitioning data, etc.
if [ -e "${disk}1" ]; then
dd if=/dev/zero of=${disk}1 bs=1M count=32
fi
if [ -e "${disk}2" ]; then
dd if=/dev/zero of=${disk}2 bs=1M count=32
fi
if [ -e "${disk}3" ]; then
dd if=/dev/zero of=${disk}3 bs=1M count=32
fi
if [ -e "${disk}4" ]; then
dd if=/dev/zero of=${disk}4 bs=1M count=32
fi
if [ -e "${disk}" ]; then
# use badblocks here to preseve any background pattern
badblocks -swf -b 1048576 -t ${backgroundPattern} ${disk} 16 0
fi
sync
sleep 2
#parted $disk mklabel msdos
# use a 'here document' to allow parted to understand the -1M
parted $disk --align optimal <<EOP
mklabel gpt
mkpart primary 528M 2576M
mkpart primary 2576M 4624M
mkpart primary 16M 528M
mkpart primary 4624M -1M
set 1 raid on
set 2 raid on
quit
EOP
#parted $disk --align optimal <<EOP
#mklabel gpt
#mkpart primary 16M 2064M
#mkpart primary 2064M 4112M
#mkpart primary 4112M 4624M
#mkpart primary 4624M -1M
#set 1 raid on
#set 2 raid on
#quit
#EOP
# 2064 - 16 = 2048
# 4112 - 2064 = 2048
# 4624 - 4112 = 512
#
sync
sleep 1
parted $disk print
Maybe, if the system is too broken (like mine I guess) and you don't have all needed package to allow the upgrade to complete in addition of the scripts,
you should ask for replacement (if you bought the disk, go on western digital support page, they send first a new device and you send your old one when you received the new,
I propose you to select "firmware upgrade process failed"),
link to western digital support page:
hxxps:[slash][slash]westerndigital[dot]secure[dot]force[dot]com[slash]apex[slash]WD_RMA_Advanced
but you loose all your data or you run throw the whole disk erasing from another linux PC (with prior uncelling of the box that will break the guaranty) :
link yo complete debrick guide:
hxxp:[slash][slash]mybookworld[dot]wikidot[dot]com[slash]forum[slash]t-317579[slash]complitly-debricking-guide-draft#post-1025024