Formatting disks for ZFS on Linux

Discussion in 'Linux Admins, Storage and Virtualization' started by karpodiem, May 8, 2018.

  1. karpodiem

    karpodiem New Member

    Joined:
    Jan 1, 2014
    Messages:
    16
    Likes Received:
    1
    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?
     
    #1
  2. vl1969

    vl1969 Active Member

    Joined:
    Feb 5, 2014
    Messages:
    465
    Likes Received:
    48
    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
     
    #2
    karpodiem likes this.
  3. karpodiem

    karpodiem New Member

    Joined:
    Jan 1, 2014
    Messages:
    16
    Likes Received:
    1
    That worked! Thanks so much for your help. Now I just need to configure the SMART/Zpool scrub alert settings .
     
    #3
  4. MiniKnight

    MiniKnight Well-Known Member

    Joined:
    Mar 30, 2012
    Messages:
    2,679
    Likes Received:
    745
    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.
     
    #4
  5. vl1969

    vl1969 Active Member

    Joined:
    Feb 5, 2014
    Messages:
    465
    Likes Received:
    48
    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
     
    #5
  6. karpodiem

    karpodiem New Member

    Joined:
    Jan 1, 2014
    Messages:
    16
    Likes Received:
    1
    *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.
     
    #6
    Last edited: May 9, 2018
    vanfawx likes this.
  7. dkong

    dkong New Member

    Joined:
    Apr 3, 2018
    Messages:
    5
    Likes Received:
    1
    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?
     
    #7
  8. karpodiem

    karpodiem New Member

    Joined:
    Jan 1, 2014
    Messages:
    16
    Likes Received:
    1
    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.
     
    #8
Similar Threads: Formatting disks
Forum Title Date
Linux Admins, Storage and Virtualization Getting SMART data from ZFS disks in Proxmox Mar 10, 2018
Linux Admins, Storage and Virtualization Changing the disks from /sdX to UUID on an OS bootable ZFS raid-1 pool? Sep 18, 2017
Linux Admins, Storage and Virtualization ESXi 6 M1015 passthrough no disks detected Apr 24, 2016

Share This Page