Truenas how to replace disk using command line

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
Good evening!

Can you please tell me how to correctly enter the command to replace the disk through the terminal?

my button in truenas is not working


zpool replace tank /dev/gptid/b03def73-6ac9-11e2-a0b8-50465db1a7ad /dev/da9

Is this example correct?
 

Redcoat

MVP
Joined
Feb 18, 2014
Messages
2,925

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
I assume this is with 13-RELEASE? If so please see the release notes https://www.truenas.com/docs/core/corereleasenotes/#cli-disk-replacements for a full description of the CLI workaround for this issue.
Please tell me, I have one disk renamed, how can I return it to the pool?

truenas.png



How to rename it to da9 instead of /dev/da9. Thanks
 
Joined
Jun 2, 2019
Messages
591
I didn't even know there was a problem "replacing" a drive via the webGUI in 13.0-RELEASE. I just skipped that step altogether 10 days ago

1. depower
2. replace drive
3. boot
4. add new drive to pool
5. delete defunct gptid

No magical python scripts or complicated procedure required.

Just curious, when is 13.0-U1 planned to be released?
 
Last edited:

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
Yes, Truenas 13.0 has problems with disk replacement. Why release a program with such a serious mistake?
 

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
I didn't even know there was a problem "replacing" a drive via the webGUI in 13.0-RELEASE. I just skipped that step altogether 10 days ago

1. depower
2. replace drive
3. boot
4. add new drive to pool
5. delete defunct gptid

No magical python scripts or complicated procedure required.

Just curious, when is 13.0-U1 planned to be released?
Tell me, zfs can't mount the disk. It can be redefined (reassigned) in the system.

44334.png
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
How to rename it to da9 instead of /dev/da9. Thanks
Never use entire disks (like /dev/da9). You must create a GPT partition table and use the first or second partition depending on whether there is swap configured on the disk or not.
Never use the device paths to add/attach disks to pools on the command line. Always use the GPTID. Only then will the UI show the correct information and future operations will work.

The simplest way to replace a disk on the command line - assuming you have a working disk "da8" of identical capacity in the same pool or vdev:
Code:
# Copy partition table
gpart backup da8 | gpart restore -F da9

# check partitions - the one with type "freebsd-zfs" is the one we are looking for
# then copy the "rawuuid" field of that partition
gpart list da9

# Finally replace the failed disk
zpool replace tank gptid/<uuid of failed disk> gptid/<uuid of new disk>


So you need to perform a detach, create the partition table via the command in my example, look for the rawuuid, then attach with the ID instead of the device.

HTH,
Patrick
 

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
Never use entire disks (like /dev/da9). You must create a GPT partition table and use the first or second partition depending on whether there is swap configured on the disk or not.
Never use the device paths to add/attach disks to pools on the command line. Always use the GPTID. Only then will the UI show the correct information and future operations will work.

The simplest way to replace a disk on the command line - assuming you have a working disk "da8" of identical capacity in the same pool or vdev:
Code:
# Copy partition table
gpart backup da8 | gpart restore -F da9

# check partitions - the one with type "freebsd-zfs" is the one we are looking for
# then copy the "rawuuid" field of that partition
gpart list da9

# Finally replace the failed disk
zpool replace tank gptid/<uuid of failed disk> gptid/<uuid of new disk>


So you need to perform a detach, create the partition table via the command in my example, look for the rawuuid, then attach with the ID instead of the device.

HTH,
Patrick
Thanks for the reply, I'll see what I can do.
 

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
Never use entire disks (like /dev/da9). You must create a GPT partition table and use the first or second partition depending on whether there is swap configured on the disk or not.
Never use the device paths to add/attach disks to pools on the command line. Always use the GPTID. Only then will the UI show the correct information and future operations will work.

The simplest way to replace a disk on the command line - assuming you have a working disk "da8" of identical capacity in the same pool or vdev:
Code:
# Copy partition table
gpart backup da8 | gpart restore -F da9

# check partitions - the one with type "freebsd-zfs" is the one we are looking for
# then copy the "rawuuid" field of that partition
gpart list da9

# Finally replace the failed disk
zpool replace tank gptid/<uuid of failed disk> gptid/<uuid of new disk>


So you need to perform a detach, create the partition table via the command in my example, look for the rawuuid, then attach with the ID instead of the device.

HTH,
Patrick
When I want to attach a disk to a pool, I get a response

6787.png

You don't know what can be done?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Hardware problem with your controller, cable, backplane, and/or the disk.

Is your controller flashed to IT mode? mprutil show adapter
 

EugenioTF

Dabbler
Joined
Jan 23, 2019
Messages
22
Hardware problem with your controller, cable, backplane, and/or the disk.

Is your controller flashed to IT mode? mprutil show adapter

Good afternoon. There is a strange situation.
The disk in the pool shows UNAVAIL, but the system sees it, formats it, the table is marked up, everything is fine. But in the UNAVAIL pool. I checked the cables, swapped them, even installed a spare controller.


00001.png


It is visible in the system.

00002.png


It shows outside the system

00003.png


Please tell me how to find out the gptid of the old disk if it is not already in the system. Thanks
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Please tell me how to find out the gptid of the old disk if it is not already in the system. Thanks
It should show in zpool status output. The other command that shows you the IDs even for disks that are not part of a pool is gpart list. Look for the partition of type freebsd-zfs and the rawuuid field.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,079
I didn't even know there was a problem "replacing" a drive via the webGUI in 13.0-RELEASE. I just skipped that step altogether 10 days ago

1. depower
2. replace drive
3. boot
4. add new drive to pool
5. delete defunct gptid

No magical python scripts or complicated procedure required.

Just curious, when is 13.0-U1 planned to be released?
If you don't do it correctly, using the script, there will be no swap space partition created on the disk. Doing a replace using standard ZFS commands works, but it will break other functionality of TreuNAS.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Doing replace with zpool commands works like a charm if

1. you create the correct GPT partition table first
2. use the GPTID of the second partition in your zpool command instead of the disk device

None of this is rocket science.
 

denis4o

Dabbler
Joined
Nov 30, 2019
Messages
21
Doing replace with zpool commands works like a charm if

1. you create the correct GPT partition table first
2. use the GPTID of the second partition in your zpool command instead of the disk device

None of this is rocket science.
I disagree. I have been fighting with TrueNAS Core for the past two days just to grow my pool with higher capacity HDDs and none of the suggested CLI methods worked so far.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
If you're up-to-date, none of the "suggested CLI methods" are needed--just use the Replace button in the GUI. If you're still on -0, unwilling to update, and unwilling to use the tools iX provided to cover for their massive f-up, then the commands to partition and find the gptids can be find in this resource:
 

denis4o

Dabbler
Joined
Nov 30, 2019
Messages
21
Unfortunately, the GUI doesn't do anything since the names of the 3 of the 4 HDDs are ada0p2 and etc. and it seems that the UI works only with gptid/xxxxxxxx names, thus rendering it useless in my case. Other users having the same issue (https://www.truenas.com/community/t...ows-device-id-da0-only-truenas-12-0-u1.90124/)
Code:
 zpool status
  pool: freenas-boot
 state: ONLINE
status: Some supported and requested features are not enabled on the pool.
        The pool can still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
        the pool may no longer be accessible by software that does not support
        the features. See zpool-features(7) for details.
  scan: scrub repaired 0B in 00:01:57 with 0 errors on Sun Jan  8 03:46:57 2023
config:

        NAME          STATE     READ WRITE CKSUM
        freenas-boot  ONLINE       0     0     0
          da0p2       ONLINE       0     0     0

errors: No known data errors

  pool: home_server
 state: ONLINE
  scan: resilvered 168K in 00:00:01 with 0 errors on Thu Jan 12 21:20:54 2023
config:

        NAME                                            STATE     READ WRITE CKSUM
        home_server                                     ONLINE       0     0     0
          raidz1-0                                      ONLINE       0     0     0
            gptid/fb50dea3-9265-11ed-be0b-7085c25f11d1  ONLINE       0     0     0
            ada0p2                                      ONLINE       0     0     0
            ada2p2                                      ONLINE       0     0     0
            ada3p2                                      ONLINE       0     0     0


P.S. I am all up-to-date (TrueNAS-13.0-U3.1) and I know the gptids of the other disks, however, I cannot offline the current adaXp2. I don't even know how they were added to the pool but I suspect I didn't replace them correctly after failure.
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
the names of the 3 of the 4 HDDs are ada0p2 and etc.
So you've already been messing with your pool at the CLI, and doing it wrong. But what makes you think the GUI is useless in your case? Is it giving you an error when you try to offline one of those, or when you try to replace it with another? If so, what's the error?

And if you just want to use the CLI for the sake of using the CLI, as Patrick said six months ago, it isn't rocket science:
  • zpool offline home_server <device>
  • Install the replacement disk
  • Partition the replacement disk following the instructions at the link I gave up-thread
  • zpool replace home_server <old device> <new gptid>
  • Repeat for the rest of the disks
 

Davvo

MVP
Joined
Jul 12, 2022
Messages
3,222
adaXpY are usually partitions if I'm not wrong. Not having the gptid might be sign of a hardware (controller) issue.
 

denis4o

Dabbler
Joined
Nov 30, 2019
Messages
21
So you've already been messing with your pool at the CLI, and doing it wrong.
I would assume you are right. These are three drives that failed (not at once) and were replaced via the CLI following tutorials from the forum few years ago (edit: I found the guide that I used, it was not on the forum: http://notesofaprogrammer.blogspot.com/2019/01/replacing-corrupt-hard-drive-for-freenas.html)

There is no error when I try to offline the disk via the GUI, but nothing happens. Video attached.
 

Attachments

  • Recording 2023-01-13 014037.mp4
    6.4 MB · Views: 0
Top