# UFS to ZFS



## atomant (May 12, 2012)

I have one HDD 1,5 TB which is used as a share among home users. In the near future I would like to add another drive for larger capacity but I don't want to l*o*se existing data. As I read about ZFS it is easy to configure a pool of disks and then just add new disk(s) to it.


Is it possible to convert existing HDD filesystem UFS to ZFS without losing any data or
do I need first to get new disk, configure it as ZFS, copy everything from the old one, reformat the old one and finally add it to the ZFS pool?

Regards,
Sasa


----------



## bbzz (May 12, 2012)

If you mean keep data as you install ZFS on same disk, no.
That's the formula. Keep in mind what kind of pool you are creating. If you create simple one disk vdev, then later add another one disk vdev, that's a RAID0 in a nutshell. Is this what you want?


----------



## jb_fvwm2 (May 13, 2012)

On second thought, for "regular" disk usage all of the below is not
usually recommended (controller timeouts ) I was thinking more along
the line of rsync and one-time copying... but it may be workable for
a permanently installed, primary-bus disk(s).  (Inexperienced here with
that latter case.) 

One can also add the second disk to a mountpoint (SUJ, gjournal, UFS etc).

```
mount -o async /dev/ad10p1 /mnt
# or add space within a filesystem
mount -t ufs -o union /dev/da0 /usr
```
In the latter case, if /obj /src  were on the /dev/da0 but empty on /usr, the new space would be 
avail. within that filesystem. YMMV... (I only use the latter case on very slow machines, due to the usb stuff...


----------



## atomant (May 13, 2012)

bbzz said:
			
		

> If you mean keep data as you install ZFS on same disk, no.
> That's the formula. Keep in mind what kind of pool you are creating. If you create simple one disk vdev, then later add another one disk vdev, that's a RAID0 in a nutshell. Is this what you want?



Yes, that is exactly what I want to do, RAID0 (or JBOD).


----------



## bbzz (May 13, 2012)

Are you aware that loss of one disk in RAID0 will in most cases render whole pool unusable? If you care for data, something like raidz (RAID5) would be much better. You would need one more disk for this, however. In any case, both options are easy to setup.


----------



## zodias (May 13, 2012)

Not lo*n*g ago I had to mirror a 1TB disk with 320GB of data on it. I installed a new 1TB disk and created *a* 2x500GB zpool mirror on the same disk and transferred the data onto it. Then I offlined one of the mirrored partitions and replaced it with the old drive's 1TB partition. After the zpool finished resilvering I offlined the other 500GB part of the mirror and recreated a 1TB partition. Replaced the offlined partition with the last one and resilvered.

All the partitioning I did was with the *gpart* utility.

Hope it is clear.


----------



## phoenix (May 15, 2012)

bbzz said:
			
		

> If you mean keep data as you install ZFS on same disk, no.
> That's the formula. Keep in mind what kind of pool you are creating. If you create simple one disk vdev, then later add another one disk vdev, that's a RAID0 in a nutshell. Is this what you want?



If you *zfs add* the second disk, then you create a pool with 2 single-disk vdevs, aka RAID0.


```
# zpool create storage disk1
# zpool add storage disk2
# zpool status
  pool: storage
 state: ONLINE
  scan: scrub repaired 0 in 30h34m with 0 errors on Tue Jan 17 03:12:28 2012
config:

        NAME             STATE     READ WRITE CKSUM
        storage          ONLINE       0     0     0
          disk1          ONLINE       0     0     0
          disk2          ONLINE       0     0     0
```

If you "zfs attach" the second disk, then you create a pool with a mirror vdev, aka RAID1.


```
# zpool create storage disk1
# zpool attach storage disk1 disk2
# zpool status
  pool: storage
 state: ONLINE
  scan: scrub repaired 0 in 30h34m with 0 errors on Tue Jan 17 03:12:28 2012
config:

        NAME             STATE     READ WRITE CKSUM
        storage          ONLINE       0     0     0
          mirror-1       ONLINE       0     0     0
            disk1        ONLINE       0     0     0
            disk2        ONLINE       0     0     0
```


----------

