Category:LS-WTGL/R1/Restoring from empty disks

I just got a Buffalo LinkStation Pro Duo from a friend without any disks in it. I installed a single 1TB disk in it, but quickly found out it wouldn't boot as the OS is installed on the disk. However, after a few hours of work, I got it running like a normal LinkStation from scratch. For future reference, I'm writing down here how I did it.

(adapt yourself for multiple disks)

Boot Windows or use a Windows VM

 * Connect it directly via ethernet, set its IP address to 192.168.11.1
 * Make sure the firewall is disabled
 * Run TFTP Boot Recovery
 * Leave the boot recovery running, you will need it for reboots later

Run a DHCP server to give your LinkStation an IP address
%% buffalo 1 00:1d:73:df:ad:f9 192.168.11.150 1
 * Preferably 192.168.11.150, since that's also its default IP address
 * On Mac OS X, write this in /etc/bootptab:
 * (the %% should be there, replace the MAC address with yours)
 * Then run: sudo /usr/libexec/bootpd -v -d -D -i en0

Turn on the LinkStation
Make sure it's connected via ethernet directly to the Windows machine and the Mac. If the Windows machine is a VM, you can bridge its interface to the wired interface of the Mac and just connect it with the LinkStation over a single ethernet cable.

The LinkStation won't come up (as it's broken), so press the FUNC button on the back a few times until the power LED comes on. It will request TFTP boot files from the Windows machine:



The bootpd server will say something like:

Jan 16 01:08:51 hostname bootpd[pid] : ACK sent buffalo 192.168.11.150 pktsize 300

Leave the tftpd and bootpd running, you will need them for reboots later.

Gain telnet access to the LinkStation

 * Get acp_commander.jar from somewhere on this wiki
 * Use java -jar acp_commander.jar -t 192.168.11.150 -o
 * "You can now telnet to your box as user 'root' providing no / an empty password"

Partition & format the disk

 * fdisk -l
 * For me it said:
 * disk /dev/sda: 1000.2 GB, ….

Partitioning

 * fdisk /dev/sda
 * new partition: n
 * primary: p
 * number: 1
 * first: 1 (default, just press enter)
 * last: +256M
 * This will be the boot partition (it has to be nr 1)


 * new partition: n
 * primary: p
 * number: 2
 * first: (default, just press enter)
 * last: +16G
 * This will be the root partition (has to be number 2)


 * new partition: n
 * extended: e
 * number: 3
 * first: (default, just press enter)
 * last: (enter)


 * new partition: n
 * logical: l
 * first: (enter)
 * last: +1G
 * this will be the swap partition, it will be number 5


 * new partition: n
 * logical: l
 * first: (enter)
 * last: (enter)
 * And finally, this will be the share partition.


 * To check, give the command "p"
 * It should give 5 partitions, sda1 to sda6 except for sda4.


 * We will set the type of the swap one to "linux swap".
 * Command: t
 * Partition number: 5
 * Type: 82


 * Command: w (to save)

Setting up RAID

 * mdadm -C --force -n 1 -l raid1 /dev/md0 /dev/sda1
 * (-C = create, --force = allow creating a RAID with 1 device, -n 1 = create 1 device, -l raid1 = use raid1, then the RAID name, then the partitions in it)
 * mdadm -C --force -n 1 -l raid1 /dev/md1 /dev/sda2
 * mdadm -C --force -n 1 -l raid1 /dev/md2 /dev/sda6
 * mdadm -C --force -n 1 -l raid1 /dev/md10 /dev/sda5

Formatting the partitions

 * mkfs.ext3 -f /dev/md0
 * mkfs.xfs -f /dev/md1
 * mkfs.xfs -f /dev/md2
 * mkswap /dev/md10
 * mkdir -p /rootfs /boot
 * mount /dev/md0 /boot
 * mount /dev/md1 /rootfs

Install the base system

 * Get a firmware update (i.e. version 310b) from Buffalo
 * Unzip hddrootfs.img and initrd.img using one of these passwords (see Create a custom firmware image)
 * NFM_TUPSBHFNFM_TUPSBHF
 * 1NIf_2yUOlRDpYZUVNqboRpMBoZwT4PzoUvOPUp6l
 * aAhvlM1Yp7_2VSm6BhgkmTOrCN1JyE0C5Q6cB3oBB
 * YvSInIQopeipx66t_DCdfEvfP47qeVPhNhAuSYmA4
 * IeY8omJwGlGkIbJm2FH_MV4fLsXE8ieu0gNYwE6Ty
 * Put the unzipped files along with uImage.buffalo on a usb stick (in my case, in the /nas dir) and connect it. Then mount it:
 * mkdir /usb
 * mount /dev/sdb1 /usb -t vfat
 * cd /usb/nas
 * cp initrd.buffalo uImage.buffalo /boot
 * tar xvzf hddrootfs.buffalo.updated -C /rootfs

Make any changes you want to the root filesystem

 * change /rootfs/etc/melco/diskinfo to remove the disk2 line, and change "raid0" to "raid1"

Reboot
Reboot the linkstation. It will fail to come up. Press the button at the back twice to get it back into recovery mode. It will boot from TFTP again, and get an IP address from DHCP. However, now that we do have the mdX devices, the machine will come up as an installed LinkStation. But we're not done yet. Things are still missing, but at least the auto-updater can now fix things itself.

Re-flash firmware
Take the LSUpdater.exe from the firmware update and run it on Windows. It will detect a running device and if you click "Update", it will start the upgrade process. If that doesn't work, re-activate telnet (using the acp_commander), and make sure the boot partition is mounted using "mount /dev/md0 /boot".

Once the firmware updater is done, you can turn off the tftpd and dhcpd; the machine will come up autonomously as a fully installed Buffalo LinkStation.