Migrating from a commercial home NAS

Status
Not open for further replies.

Dan

Cadet
Joined
Jul 6, 2013
Messages
2
Hi all,

I've recently set up a FreeNAS system from drives taken from a commercial 'home' NAS (a D-Link DNS-303).

My situation was that in the old NAS I had two 1TB disks setup in RAID 1 (mirroring), with an ext3 file system. The old NAS worked fine for years but it's little processor hasn't got the grunt for quick file transfers and I'll be upgrading to gigabit LAN speeds soon.

I had some RAM (just 1GB) and a Celeron G440 laying around (ideal low power processor for this but faster than atoms) so I decided to build a mini ITX system and add in the existing hard drives and use FreeNAS instead.

My board does not have hardware RAID though so ZFS mirroring was the goal for the remaining system and I wanted to transfer the data into this setup as easily as possible - especially as not having another 1TB disk handy would make it difficult to restore.

However since the disks both already contain the data (ext3) replicated, here was the plan:
1. Import one of the disks (lets say ada0) into freenas as EXT3
2. Create a blank ZFS volume on the second disk (ada1)
3. Copy the data from the ext3 disk to the new zfs volume
4. Wipe the ext3 disk (ada0)
5. Create ZFS partitions and import the first disk into the ZFS volume and let the system replicate the data to it

Point 1 was quite easy - using the web interface I went to View Volumes, then clicked Import Volume. I called is disk0, choose the first disk (ada0) from the list and selected EXT2FS (which will support the ext3 system anyway just without the journalling - ok for my purpose!)

It took a while to mount it but afterwards I setup permissions for my freenas user and used to console to cd /mnt/disk0 followed by ls and there was all my data.

Point 2 was also quick easy, but here some fear sets in because you know your about to delete the second disk! Quite an easy step though - just go to View Volumes, then click Volume Manager. Enter the main of the volume (I used "main"), choose the disk ada1 and choose ZFS as the option. The add volume already warns you existing data will be be cleared so after clicking this up came a blank ZFS volume that I could go to in the console using cd /mnt/main.

Ponit 3 I did in the console. Quite simply:
Code:
cd -ax /mnt/disk0 /mnt/main


Then left it overnight to run as it took quite some time!

The next morning I used the console and did:
Code:
cd /mnt/main
ls

(result was disk0)
I wasn't too keen on having the old disk0 folder so I used the below to move everything out of disk0 to just /mnt/main
Code:
mv /mnt/main/disk0/* /mnt/main
cd /mnt/main
(check my directories/files are there)
rm -r /mnt/main/disk0


Now it was cleaner and I have my ZFS volume setup as I wish.

Now for point 4. For this one I needed to erase the ext3 disk (ada0) so another zfs system could be setup. A little lost for how to do this I came across these posts which were extremely useful: http://forums.freenas.org/threads/i...-a-single-disk-volume-into-a-zfs-mirror.9766/

As a starting point I detached the volume from the freenas web interface. Then I went into the console and tried to use gpart to delete the existing partitions.

Code:
gpart show ada0
(this listing my partitions on the ext3 drive)
gpart delete -i4 ada0 (not sure why I had this partition but it went succesfully)
gpart delete -i2 ada0 (this one was the main data partition)
gpart delete -i1 ada0 (this one was the old linux swap partition from the old nas)


The last two commands did not work though due to a device busy error. A restart of the box fixed this so I retried the last two commands. Then I ran:
Code:
gpart destory ada0


This cleared the whole disk - now I'm ready to create the zfs setup:
Code:
gpart create -s gpt ada0
gpart add -i 1 -t freebsd-swap -s 2G ada0
gpart add -i 2 -t freebsd-zfs ada0


I also the below commands to verify the partition setup was the same
Code:
gpart status ada0
gpart status ada1


Oddly ada1 (the setup created through freenas) had 47k free whereas the commands above left no free space, but this doesn't seem to cause an issue

Now point 5. There is only one command to do this but you need to use the correct volume name and disk ID:

To get this information, use zpool status:
Code:
[root@freenas /mnt]# zpool status
  pool: main
 state: ONLINE
  scan: none requested
config:

        NAME                                          STATE     READ WRITE CKSUM
        main                                          ONLINE       0     0     0
          gptid/e409c5f2-e5ba-11e2-a5c4-902b3457a440  ONLINE       0     0     0


So the command to add the second disk is:

Code:
zpool attach main gptid/e409c5f2-e5ba-11e2-a5c4-902b3457a440 ada0p2


After a slight delay, this completed with no messages. Nervous I went to cd /mnt/main and listed the contents - they were there - phew!

Running zpool status again confirmed that the drive was replicating (resilvering):

Code:
[dan@freenas /mnt/main]$ zpool status
  pool: main
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Sat Jul  6 12:59:14 2013
        303G scanned out of 701G at 110M/s, 1h1m to go
        303G resilvered, 43.27% done
config:

        NAME                                            STATE     READ WRITE CKSUM
        main                                            ONLINE       0     0     0
          mirror-0                                      ONLINE       0     0     0
            gptid/e409c5f2-e5ba-11e2-a5c4-902b3457a440  ONLINE       0     0     0
            ada0p2                                      ONLINE       0     0     0  (resilvering)

errors: No known data errors


At the end a good result - freenas running a mirrored zfs volume without losing any data. I will of course suggest you have a backup, especially of important stuff. I took some peace in knowing backups of all my music, pictures and documents were on my laptop and some other bits on usb hard drives.

Happy for better suggestions in this guide but hopefully you'll this useful!
 

xvk4

Dabbler
Joined
Jul 6, 2013
Messages
11
Impressive, I thought you always needed lots of memory to use ZFS. Is your system working fine on your 1 GByte memory, if so I will change mine over (I have 4 GByte with 3 by 1TByte disks which I would like to have mirrored, or at least try it out.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
I didn't notice the 1GB of RAM at first. If you really do have that little memory you should have thorough backups. You're far below the recommended 6GB minimum. There have been plenty of people that have lost their zpool because of a kernel panic related to insufficient RAM(as well as panics and loss of power without an UPS). So be careful. I'd upgrade it to 4GB minimum even if its only meant as a backup.

Good guide though.. pretty impressive stuff.
 

Dan

Cadet
Joined
Jul 6, 2013
Messages
2
Thanks for the feedback.

Around the RAM I'm definitely going to upgrade so I can benefit from better reliability and the prefetch (going to get 8GB...). At the moment I get the message during boot that prefetch is disabled due to low RAM but currently my average is 540MB free and it works, though I did suffer the system not waking from low power earlier which needs some investigation...
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I didn't notice the 1GB thing, sorry, I kinda skimmed. I liked that you appeared to have a good strategy. It isn't really the lack of prefetch that's the problem, it is that the overall system is tuned for larger RAM and FreeNAS itself is kind of big. FreeBSD developers have had ZFS systems working on 1GB (or less!) since inception, and it is possible to use some of the same tuning strategies to make ZFS "fit" a smaller system, but this is no longer 2008 where 8GB of memory is "a ton" and priced as though it were gold. You can get 8GB RAM for sixty bucks, and really there aren't many good reasons other than "my system can't handle it" anymore.
 
Status
Not open for further replies.
Top