Total Pageviews

Wednesday, August 4, 2010

Creation of zpool

A while back I created a zpool. since I didn't have unused disks lying around, I used a 32 GB usb drive. I created four files to be treated as separate disks so that I could create a zpool and mirror disks. Although this would not really offer the protection of mirroring, it did allow me to become familiar with zpools and zfs filesystems, though I had previously created a ZFS filesystem on a spare disk.

The first thing I did was create the four disk files. The USB drive was mounted as /media/Lexar. I then created a sub-directory called 'zfs-testbed'. I "cd'd" to it and created the files:

mkfile 1g /media/Lexar/zfs-testbed/disk1
mkfile 1g /media/Lexar/zfs-testbed/disk2
mkfile 1g /media/Lexar/zfs-testbed/disk3
mkfile 1g /media/Lexar/zfs-testbed/disk4

That created four 1 GB files.

Next I created a zpool consisting of the one 'dive' :

zpool create gregory /media/Lexar/zfs-testbed/disk1

zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
gregory 1016M 73K 1016M 0% ONLINE -
rpool 148G 17.1G 131G 11% ONLINE -
zfs-ramos 148G 12.4G 136G 8% ONLINE -

Then I destroyed the pool, so I could create a mirror:

zpool destroy gregory

zpool create clifford mirror /media/Lexar/zfs-testbed/disk1 /media/Lexar/zfs-testbed/disk2


zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
clifford 1016M 74.5K 1016M 0% ONLINE -
rpool 148G 17.1G 131G 11% ONLINE -
zfs-ramos 148G 12.4G 136G 8% ONLINE -


Now I intentionally destroy the label:

dd if=/dev/random of=/media/Lexar/zfs-testbed/disk1 bs=512 count=1

zpool status
pool: clifford
state: DEGRADED
status: One or more devices could not be used because the label is missing or
invalid. Sufficient replicas exist for the pool to continue
functioning in a degraded state.
action: Replace the device using 'zpool replace'.
see: http://www.sun.com/msg/ZFS-8000-4J
scrub: scrub completed after 0h0m with 0 errors on Wed Aug 4 14:47:35 2010
config:

NAME STATE READ WRITE CKSUM
clifford DEGRADED 0 0 0
mirror DEGRADED 0 0 0
/media/Lexar/zfs-testbed/disk1 UNAVAIL 0 0 0 corrupted data
/media/Lexar/zfs-testbed/disk2 ONLINE 0 0 0


Now detach the bad disk:

zpool detach clifford /media/Lexar/zfs-testbed/disk1


Attach a new 'disk':

zpool attach clifford /media/Lexar/zfs-testbed/disk2 /media/Lexar/zfs-testbed/disk3

# zpool status clifford
pool: clifford
state: ONLINE
scrub: resilver completed after 0h0m with 0 errors on Wed Aug 4 14:55:33 2010
config:

NAME STATE READ WRITE CKSUM
clifford ONLINE 0 0 0
mirror ONLINE 0 0 0
/media/Lexar/zfs-testbed/disk2 ONLINE 0 0 0
/media/Lexar/zfs-testbed/disk3 ONLINE 0 0 0 85K resilvered

errors: No known data errors


Here I rebooted to complete the process. After the reboot:

zpool status clifford
pool: clifford
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
clifford ONLINE 0 0 0
mirror ONLINE 0 0 0
/media/Lexar/zfs-testbed/disk2 ONLINE 0 0 0
/media/Lexar/zfs-testbed/disk3 ONLINE 0 0 0

errors: No known data errors

No comments:

Post a Comment