Formatting disks for ZFS on Linux

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

karpodiem

New Member
Jan 1, 2014
16
1
3
This past weekend I installed Ubuntu 18.04 and ZFS on Linux. Admittedly, I am a complete Linux noob and my knowledge pertains to Googling and copy and pasting commands into the terminal. Everybody has to start somewhere!

I've got some old disks I'd like to create a storage pool with just so I can get more comfortable with administering ZoL.

Here's what it looks like -

Dropbox - 2018-05-08 07_33_40-Window.png

sda and sdb are 500GB disks that were from an old mirrored zpool when I tried this a few months ago. sdc and sdd are disks that I added.

My first question -

1) How do I erase a current mirrored zpool and make the disks available for a new zpool?
2) Do I need to format a disk prior to using with ZoL?
3) What commands would I use to I delete all partitions on a disk and then initialize to GPT?
4) Doing some Googling, it seems that a 4 disk mirror can be created with the command -

zpool create zfspool mirror disk1 disk2 mirror disk3 disk4

Is this correct?
 

vl1969

Active Member
Feb 5, 2014
634
76
28
Well the command looks good. This is the way I created mine.[emoji13][emoji3][emoji12]

You do not need to format the disks. Just use gdisk or parted to create new partition table. This should wipe everything and make disk clean and ready for reuse. It is possible to just wipe the disk with dd com and using null dev as input but takes too long. Imho.

Sent from my LG-TP450 using Tapatalk
 
  • Like
Reactions: karpodiem

karpodiem

New Member
Jan 1, 2014
16
1
3
Well the command looks good. This is the way I created mine.[emoji13][emoji3][emoji12]

You do not need to format the disks. Just use gdisk or parted to create new partition table. This should wipe everything and make disk clean and ready for reuse. It is possible to just wipe the disk with dd com and using null dev as input but takes too long. Imho.

Sent from my LG-TP450 using Tapatalk
That worked! Thanks so much for your help. Now I just need to configure the SMART/Zpool scrub alert settings .
 

MiniKnight

Well-Known Member
Mar 30, 2012
3,072
973
113
NYC
Yea always clean the disks before using them. ZFS is neat since it has combines so much of the storage management and file system stuff into a single solution.
 

vl1969

Active Member
Feb 5, 2014
634
76
28
Well BTRFS does a lot of similar or even the same things zfs do and some of them do even better. But BTRFS at this moment has limited raid level support so may not be for everyone. BTRFS was my primary fs. Until I had to build my current setup. Since proxmox have issues with it zfs had to be my primary choice. So far it works as advertised.

Sent from my LG-TP450 using Tapatalk
 

karpodiem

New Member
Jan 1, 2014
16
1
3
*Edit - found my answer. Thank you vanfawx on IRC for helping out.

First, I need to find the process that's using the zpool -

fuser -m /zfspool/zfsdata

The data returned was

/zfspool/zfsdata: 26661c

I then needed to kill the process -

kill -9 26661

Then I could destroy the zpool.

(Original question below) -

I tried to un-mount/destroy the pool to start over now that I'm feeling comfortable with it, but I'm having a few issues.

I found this thread - How do I remove a pool from ZFS?

When I try the commands listed, I receive this error -

root@austin:~# sudo zpool destroy zfspool
umount: /zfspool/zfsdata: target is busy.
cannot unmount '/zfspool/zfsdata': umount failed
could not destroy 'zfspool': could not unmount datasets
root@austin:~# sudo zpool export zfspool
umount: /zfspool/zfsdata: target is busy.
cannot unmount '/zfspool/zfsdata': umount failed

Unmounting doesn't seem to work either -

root@austin:~# zpool export zfspool
umount: /zfspool/zfsdata: target is busy.
cannot unmount '/zfspool/zfsdata': umount failed

I found this - [Solved] ZFS error: "could not destroy 'tank': could not unmount datasets" - KorbinBrown.com

to identify what process might be using zfspool -

root@austin:~# fuser -c /zfspool

but nothing is returned upon entering that command.
 
Last edited:
  • Like
Reactions: vanfawx

dkong

New Member
Apr 3, 2018
6
1
3
123
Can you reboot into single user mode, or maybe boot some kind of live CD, so you can manage the disks without having some data locked?
 

karpodiem

New Member
Jan 1, 2014
16
1
3
I ended up asking for help on the STH IRC channel and the basic commands are as follows -

sudo zpool add zfspool mirror /dev/disk/by-id/id_of_drive_1 zpool add zfspool mirror /dev/disk/by-id/id_of_drive_2

So for my two disks, it looked a little something like this -

sudo zpool replace zfspool /dev/sda/by-id/ata-WDC_WD20EZRZ-00Z5HB0_WD-WMC4N0LATZS2 /dev/sdc/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4ERPR9SKV

I'm all set, thank you for all your help! Let me know if anyone else has questions, I'd be happy to pass on my knowledge/experience.