Building a Home FreeNAS Server - Copying Data From Linux HD

Once my FreeNAS server was up and running, I needed to get my existing data on to it. One possibility is copying over the LAN, but since most of my data is held on ext2 Linux had drives, it made sens to me to mount these drives in the FreeNAS server, and copy using the command line.

Here is an example on how to achieve it. I have chosen to copy the contents of a 400GB IDE HD which holds my MP3 music collection into the FreeNAS file store.

Firstly the 400GB IDE drive needs to be connected into the system. This is straightforward - just connect an IDE ribbon cable from the motherboard to the disk, and connect up a MOLEX power connector from the power supply. Once that's done, boot up the machine.

Using a remote browser pointing to the FreeNAS server, I pointed it to 192.168.0.9 which is the IP address allocated to the server by the DHCP service running on my hub. Then click on Shell in the GUI. This loads up the root shell in a dialog box. Very handy!

Firstly, I needed to determine which partition (or slice in FreeBSD parlance) my music collection resides on the disk. After a little playing around using fdisk I discovered it's /dev/ada0s1

[root@freenas /]# fdisk /dev/ada0                                              
******* Working on device /dev/ada0 *******                                    
parameters extracted from in-core disklabel are:                               
cylinders=486341 heads=16 sectors/track=63 (1008 blks/cyl)                     
                                                                               
Figures below won't work with BIOS for partitions not in cyl 1                 
parameters to be used for BIOS calculations are:                               
cylinders=486341 heads=16 sectors/track=63 (1008 blks/cyl)                     
                                                                               
Media sector size is 512                                                       
Warning: BIOS sector numbering starts with sector 1                            
Information from DOS bootblock is:                                             
The data for partition 1 is:                                                   
sysid 131 (0x83),(Linux native)                                                
    start 63, size 490223412 (239366 Meg), flag 0                              
        beg: cyl 0/ head 1/ sector 1;                                          
        end: cyl 1023/ head 254/ sector 63                                     
The data for partition 2 is:                                                   
<UNUSED>                                                                       
The data for partition 3 is:                                                   
<UNUSED>                                                                       
The data for partition 4 is:                                                   
<UNUSED>                                                                       
[root@freenas /]# 

Next the partition table needs to be edited which is held in /etc/fstab

[root@freenas /]# cd /etc                                                      
[root@freenas /etc]# cat fstab                                                 
/dev/ufs/FreeNASs1a / ufs ro 1 1                                               
/dev/ufs/FreeNASs3 /cfg ufs rw,noauto 2 2                                      
/dev/ufs/FreeNASs4 /data ufs rw,noatime 2 2                                    
/dev/ada1p1     none                    swap            sw              0      0
/dev/ada2p1     none                    swap            sw              0      0
/dev/ada0s1     /mnt/music ext2fs ro 0 0                                       
[root@freenas /etc]# 

I have added an entry here for my Linux partition which is ext2fs, and a mount point of /mnt/music which will need to be created.
[root@freenas /etc]# mkdir /mnt/music

Before an attempt is made to mount the drive, you should check it for errors. Indeed if you do not, it may not mount anyway.

[root@freenas /etc]# fsck /dev/ada0s1                                          
e2fsck 1.41.14 (22-Dec-2010)                                                   
Pass 1: Checking inodes, blocks, and sizes  
Pass 2: Checking directory structure                                           
Pass 3: Checking directory connectivity                                        
Pass 4: Checking reference counts                                              
Pass 5: Checking group summary information                                     
/dev/ada0s1: 46265/30654464 files (29.7% non-contiguous), 50023891/61277926 bloc
ks 

It's now possible to mount the drive

[root@freenas /etc]# mount -t ext2fs /dev/ada0s1 /mnt/music    

And now I can copy the files into my FreeNAS file system

[root@freenas /mnt/music]# cd /mnt/vol1/Music/mp3                              
[root@freenas /mnt/vol1/Music/mp3]# cp -R /mnt/music/* . 

Success and in my case, repeat for each of my IDE disks. Don't forget to remove the entry from the /etc/fstab file. Laughing out loud