In opposite to Linux’ mdadm, ZFS doesn’t provide a possibility to create a Raid with a missing disk. Therefore it’s not possible to create a RaidZ with two of three devices added. But this is essential for my migration from the old NAS. Fortunaly a RaidZ can be created either with disks or with files. This gives us the chance, to fake a third disk and remove it before copying the data.

deveth0@nas:~# mkfile -n 1500G fakedisk

Afterwards we create a RaidZ pool with two disks and one file. The file can be deleted after the successful creation. If you now start a ZFS scrub you’ll see the “faulty” devices in the pool’s status. As we want to share the pool with samba, we need to add the “-o casesensitivity=mixed” option.

deveth0@nas:~# zpool create tank raidz c0 c3t4d0 c3t5d0 ~/fakedisk
deveth0@nas:~# rm fakedisk
deveth0@nas:~# zpool scrub tank

pool: tank
state: ONLINE
scan: scrub repaired 0 in 4h32m with 0 errors on Fri Jul 15 11:35:36 2011
config:

        NAME        STATE          READ WRITE CKSUM
        tank        ONLINE            0     0     0
          raidz1-0  ONLINE            0     0     0
            c3t4d0  ONLINE            0     0     0
            c3t5d0  ONLINE            0     0     0
            ~/fakedisk2  UNAVAIL      0     0     0  cannot open

Now we can copy the data from Debian to the ZFS-pool. I decided to rsync the data via ssh. After finishing, add the new drive to your system and then replace the fakedisk with it.

deveth0@nas:~# rsync -avPe ssh root@nas_old:/mnt/data/ /tank/
deveth0@nas:~# ...
deveth0@nas:~# zpool replace tank ~/fakedisk c3t6d0
deveth0@nas:~# zpool status tank

pool: tank
state: ONLINE
scan: scrub repaired 0 in 4h32m with 0 errors on Fri Jul 15 11:35:36 2011
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            c3t4d0  ONLINE       0     0     0
            c3t5d0  ONLINE       0     0     0
            c3t6d0  ONLINE       0     0     0

As the old NAS systems currently runs full, it’s time for a new one. I decided to replace my debian system with an OpenIndiana and enjoy the ZFS/Zones features as I did years ago with my experimental server.
Currently OpenIndiana build 148 is up to date an will be used for the NAS. I want to reuse the existing harddisks and migrate all data from the old NAS to a RaidZ. My current setup features an ABit Board with an Intel Mobile Core Duo U2500, 2GB RAM and two Raid1 with 1.5TB each. This makes a sum of 4 disks plus at least one boot-disk. The old NAS boots from an USB-Stick with 8GB which is good for a Debian but as SSDs become cheaper and cheaper every day, I’ll use a small SSD. Probably I’ll add another one in the future as Mirror or ZIL device…
The ABit Board supports 2 SATA Devices and has to be replaced too.

Therefore the current plan is to get this hardware:

The OpenIndiana installation is quite straigh forward with a good wizard. It automatically sets up a ZFS pool for boot and we don’t have to make the whole fuzz as with the old OpenSolaris installations which couldn’t boot from ZFS.
The installation contains everything needed for a NAS including Samba, NFS etc.
In the first step I’ll setup a RaidZ Pool with two devices and copy my data from the old NAS.

Bei der Einrichtung des PCs war ich eigentlich von einem Mirror als Datenspeicher ausgegangen. Da ich nun aber doch noch etwas mehr Speicher benötige, wollte ich noch eine zusätzliche Platte dazuhängen und ein RaidZ draus machen.

Leider kann man diesen Vorgang nicht direkt ausführen, sondern muss ein bisschen Daten hin und her kopieren. Benötigt werden hier die 3 Platten für das RaidZ (2 davon aktuell im Mirror), außerdem noch eine Platte für die temporäre Speicherung der Daten im Mirror.

Der Mirror besteht aus c0d0s7 und c1d0s7. Hier ersetze ich ersteinmal eine Platte durch die Temporäre:

# zpool replace tank c1d0s7 c3d0s7

Danach entferne ich die zweite Platte

# zpool detach tank c0d0s7

Dann bleibt noch ein Mirror mit einer Platte (c3d0s7) übrig.

Als nächstes wird ein RaidZ erstellt

# zpool create store raidz c0d0s7 c1d0s7 c2d0s7

und für jedes Dateisystem ein Snapshot gemacht:

# zfs snapshot tank/home@home & zfs snapshot tank/opt@opt & zfs snapshot tank/xen@xen

Danach sollte der Pool so aussehen:

# zfs list
NAME             USED  AVAIL  REFER  MOUNTPOINT
store            448K   320G  24,0K  /store
tank            6,01G   222G    18K  /tank
tank/home       2,82G   222G  2,82G  /export/home
tank/home@home      0      -  2,82G  -
tank/opt        2,62G   222G  2,62G  /opt
tank/opt@opt        0      -  2,62G  -
tank/xen         583M   222G   583M  /export/xen
tank/xen@xen        0      -   583M  -

Um nun die Daten von tank auf store zu bekommen, verwende ich ein zfs send | zfs receive:

# zfs send tank/home@home | zfs receive store/home
# zfs send tank/opt@opt | zfs receive store/opt
# zfs send tank/xen@xen | zfs receive store/xen

Schon sind die Daten sowohl in tank als auch store:

# zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
store            6,04G   314G  29,3K  /store
store/home       2,82G   314G  2,82G  /store/home
store/home@home      0      -  2,82G  -
store/opt        2,66G   314G  2,66G  /store/opt
store/opt@opt        0      -  2,66G  -
store/xen         583M   314G   583M  /store/xen
store/xen@xen        0      -   583M  -
tank             6,01G   222G    18K  /tank
tank/home        2,82G   222G  2,82G  /export/home
tank/home@home   1,51M      -  2,82G  -
tank/opt         2,62G   222G  2,62G  /opt
tank/opt@opt         0      -  2,62G  -
tank/xen          583M   222G   583M  /export/xen
tank/xen@xen         0      -   583M  -

Jetzt müssen nur noch tank gelöscht und die Mountpoints angepasst werden und schon ist das RaidZ fertig…

Wie erstelle ich ein Raid1?

Darauf möchte ich hier eine kleine Antwort liefern…

Den Rest des Beitrags lesen »