Using 3TB drives in your D-Link DNS-323

[Recovered: Original post date June 24th 2012]

I’ve been using my D-Link DNS-323 as a place to store backups in our apartment, but space has been getting a little tight. Hard drive prices haven’t come back down to their historic lows, but as 3TB (3TiB?) models can be found for $149 here in Toronto I decided to pick up a pair to use in the upgrade.

There was one problem: the DNS-323 was designed and shipped back when 1TB drives were the norm, and it couldn’t “see” any larger than 2TB. How to get around this? Aftermarket firmware to the rescue! The “Alt-F” project provides new firmware with many new features, including the internal software versions required to use large drives.

First I logged in to the admin interface (with the old D-Link v1.10 firmware) and pointed it to the “Alt-F-0.1RC2.bin” file I had downloaded, then clicked Apply and rebooted it when complete:

When it came back up I logged in again, but this time the D-Link web theme was gone, and replaced with the Alt-F admin pages. After stepping through a first-boot wizard that asked for things like timezone, IP settings and hostname/workgroup I was glad to see it had picked my old drives (sda and sdb, the old 1.5TB SATA models)

I used the System–Utilities page to shut down the enclosure, and swapped in my two new 3TB drives. I chose the Seagate Barracuda (ST3000DM001) SATA3 64MB-cache versions, which I was going to run as a mirror for redundancy. Booted up and there they were: showing up with “3000.6 GB” of space:

From reading the Alt-F forums I knew the admin UI had issues running the standard disk utils on large drives (see forum instructions here), so I SSH’d in directly using Putty (user: root, password: same-as-web-ui). These are the commands I ran against the first disk (“/dev/sda”)

# sgdisk –zap-all /dev/sda
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
# sgdisk –set-alignment=8 –new=1:64:+512M –typecode=1:8200 /dev/sda
Creating new GPT entries.
The operation has completed successfully.
# end=$(sgdisk –set-alignment=8 –end-of-largest /dev/sda)
# sgdisk –set-alignment=8 –new=2:0:${end} –typecode=2:8300 /dev/sda

The operation has completed successfully.
# sgdisk -p /dev/sda
Disk /dev/sda: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): D07A22ED-A279-4FC8-B0F6-133DF4450139
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 64-sector boundaries
Total free space is 30 sectors (15.0 KiB)

Number Start (sector) End (sector) Size Code Name
1 64 1048639 512.0 MiB 8200
2 1048640 5860533134 2.7 TiB 8300

I then repeated the commands for the second disk (“/dev/sdb”):

# sgdisk –zap-all /dev/sdb
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
# sgdisk –set-alignment=8 –new=1:64:+512M –typecode=1:8200 /dev/sdb
Creating new GPT entries.
The operation has completed successfully.
# end=$(sgdisk –set-alignment=8 –end-of-largest /dev/sdb)
# sgdisk –set-alignment=8 –new=2:0:${end} –typecode=2:8300 /dev/sdb

The operation has completed successfully.
# sgdisk -p /dev/sdb
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 674BA261-9F48-47A4-9A19-8C63889CAFA8
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 64-sector boundaries
Total free space is 30 sectors (15.0 KiB)

Number Start (sector) End (sector) Size Code Name
1 64 1048639 512.0 MiB 8200
2 1048640 5860533134 2.7 TiB 8300

Then I activated the swap partitions on both disks:

# mkswap /dev/sda1
Setting up swapspace version 1, size = 536866816 bytes
# mkswap /dev/sdb1
Setting up swapspace version 1, size = 536866816 bytes
# swapon /dev/sda1
# swapon /dev/sdb1

Next, I couldn’t tell from the forum if I should even try using the web UI to mirror the disks (since the page showed an error), so I mirrored them from the command line. Note: This command uses the latest metadata format that is too new for the OEM D-Link firmware – if you think you may want to go back to the original firmware one day don’t use this command! (and use the next one below it instead):

# mdadm –create /dev/md0 –bitmap=internal
–chunk=64 –level=raid1 –raid-devices=2 /dev/sda2 /dev/sdb2

mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store ‘/boot’ on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
–metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

If you wanted to use the older metadata format that would allow you to flash back to D-Link defaults, add the “–metadata=0.90″ flag, like this:

# mdadm –create /dev/md0 –bitmap=internal
–metadata=0.90 –chunk=64 –level=raid1 –raid-devices=2 /dev/sda2 /dev/sdb2

You can check if the two disks are starting to be stitched together with the “cat /proc/mdstat” command. You should see the word “resync” with an estimated finish time. (Note: it may take hours, but you don’t have to wait for it to complete before performing the next steps).

# cat /proc/mdstat
Personalities : [linear] [raid1]
md0 : active raid1 sdb2[1] sda2[0]
2929741087 blocks super 1.2 [2/2] [UU]
[==>………………] resync = 11.3% (331414528/2929741087) finish=41952.7min speed=1031K/sec>

Next I switched back to the Alt-F web UI to create an EXT4 filesystem on top of the new /dev/md0 mirror. (Think of /dev/md0 as the name for the combination of your /dev/sda and /dev/sdb disks). This also could have done from the terminal, but I wanted to use point-and-click 🙂

Because the two disks are still being joined, filesystem creation can take a long time (for me about 45 minutes). You can see that it’s working by running “top” in your terminal and looking for “mkfs.ext4″:

You can also monitor the progress from the status page:

After it completed I made one last change: I ran a command to prevent the enclosure from saving so much extra space (almost 150GB) for the “root” user. On regular Linux system space is reserve so even if regular users fill the disk an admin still has room to fix things… but that doesn’t really apply for home use since even if the DNS-323 gets full it’s not booting from those disks so there’s little consequence:

# tune2fs -m 0 /dev/md0
tune2fs 1.41.14 (22-Dec-2010)
Setting reserved blocks percentage to 0% (0 blocks)

Success! The status page shows the formatted base-2 capacity of the mirror as 2.7TB (and you can also see the resync on md0 is still happening under-the-covers)

Many people are done at this point, but I needed to share the new space back out to my network using the same share name as when I was running D-Link firmware (“Volume_1″)

Note: If you hadn’t been using “user” accounts with Samba and the old firmware, you may need to SSH in one more time to run this command to let people save files to the share.

# chmod 777 /mnt/md0

Warning: This command effectively says “anyone can change anything” on the share. Probably OK for home use, but not the type of security you would use in a business.

Finally: I could see it in Windows, hooray!

Special thanks to Joao Caroso from the Alt-F project and the other users that figured all this out before me in the forums!

Leave a Reply