Procedure for replacing a disk

balanga

Patron
Joined
Jul 10, 2014
Messages
271
My TrueNAS box is running low on space and I was thinking of replacing the disk with a bigger one. Is there a recommended procedure for doing this? I was thinking of initially attaching the new disk via a USB enclosure and copying all the data from the old disk to the new disk and then replacing the old disk...

Any guidance would be appreciated.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Is there a recommended procedure for doing this?
You can follow the process in the manual: https://www.truenas.com/docs/core/storage/disks/diskreplace/ treating the disk to be replaced as if it's failed.

This assumes you have no free space to put an additional disk in the system during the resilvering.

Personally, I would advise you to avoid the use of USB attached disks where possible, but it is technically possible to do it as you suggested.
 
Joined
Jun 2, 2019
Messages
591
Assuming you are using any form of RAID > 1 (i.e. other than 0). If you are not using any form of RAID > 1, you are SOL.


1. Confirm auto expand enabled, if not enable

Code:
zpool get autoexpand
zpool set autoexpand=on {pool}


2. Click on pools, status, select replace from pull down for disk you want to replace.

3. Remove old drive and insert new larger drive

4. Select new larger off line disk and click replace

5. Wait for resilver to complete.

6. Repeat process until all disks are replaced with larger disks.

P.S. Google can be your friend
 

balanga

Patron
Joined
Jul 10, 2014
Messages
271
You can follow the process in the manual: https://www.truenas.com/docs/core/storage/disks/diskreplace/ treating the disk to be replaced as if it's failed.

This assumes you have no free space to put an additional disk in the system during the resilvering.

Personally, I would advise you to avoid the use of USB attached disks where possible, but it is technically possible to do it as you suggested.

There is no space for a second disk so I can only attach it via USB, so the new disk would be the USB disk initially until everything was copied and then it would replace the original, but would I need to do anything to the new disk to make it bootable?

Alternatively I thought about taking out both disks and attaching them to a FreeBSD system, mounting both and then copying the contents from one to the other, but don't know if that would work.
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
There is no space for a second disk so I can only attach it via USB, so the new disk would be the USB disk initially until everything was copied and then it would replace the original, but would I need to do anything to the new disk to make it bootable?
OK, if the forum is going to help you without proposing something dangerous, we need to know more about your setup.

Can you share the hardware and pool layout of your TrueNAS Box? (it may help to share the output from zpool status -v)
 

Dan Tudora

Patron
Joined
Jul 6, 2017
Messages
276
Alternatively I thought about taking out both disks and attaching them to a FreeBSD system, mounting both and then copying the contents from one to the other, but don't know if that would work.
hello
Can boot with "Recovery is possible" RIP linux and use dd_rescue to do the job.
dd_rescue /dev/old_disk /dev/new-usb-disk and after that you are a "verrry" exact copy of the old_disk
cheers
 

balanga

Patron
Joined
Jul 10, 2014
Messages
271
OK, if the forum is going to help you without proposing something dangerous, we need to know more about your setup.

Can you share the hardware and pool layout of your TrueNAS Box? (it may help to share the output from zpool status -v)

I have TrueNAS running on Lenovo M92 Tiny with a 2TB disk and 8GB of RAM. It has been running as a home system for the last four years and with the constant dumping of data onto it, space is running out.

zpool status -v
Code:
  pool: freenas-boot
 state: ONLINE
status: Some supported 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(5) for details.
  scan: scrub repaired 0B in 00:04:27 with 0 errors on Sun May 16 03:49:27 2021
config:

    NAME                                          STATE     READ WRITE CKSUM
    freenas-boot                                  ONLINE       0     0     0
      gptid/e7bb47c4-a91d-11e6-869d-00232467a5a8  ONLINE       0     0     0

errors: No known data errors

  pool: nas
 state: ONLINE
status: Some supported 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(5) for details.
  scan: scrub repaired 0B in 08:22:12 with 0 errors on Sun Apr 25 08:22:17 2021
config:

    NAME                                          STATE     READ WRITE CKSUM
    nas                                           ONLINE       0     0     0
      gptid/e1a792a8-1145-11e5-9c84-00232467a5a8  ONLINE       0     0     0

errors: No known data errors
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
OK, so now it's clear. You can't do anything else than attach via USB to replace the disk (through the GUI) as you have no redundancy.

You could also follow the process suggested by others to use dd or some other block-level duplication of the disk via another OS with both disks connected.
 

balanga

Patron
Joined
Jul 10, 2014
Messages
271
OK, so now it's clear. You can't do anything else than attach via USB to replace the disk (through the GUI) as you have no redundancy.

You could also follow the process suggested by others to use dd or some other block-level duplication of the disk via another OS with both disks connected.

I want to partition and format the new disk correctly before doing anything else, so if I connect it via USB and run gpart I'd like to add the appropriate partitions. I note that gpart show ada0 looks like this:

Code:
=>        34  3907029101  ada0  GPT  (1.8T)
          34          94        - free -  (47K)
         128     4194304     1  freebsd-swap  (2.0G)
     4194432  3902834696     2  freebsd-zfs  (1.8T)
  3907029128           7        - free -  (3.5K)

With a 4TB disk should I do this initially:-
Code:
gpart destroy -F da1
gpart create -s gpt da1
gpart add -t freebsd-swap -s 2G da1
gpart add -t freebsd-zfs da1


Not really that familiar with ZFS so don't know how to format/initialise it...
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
connect it via USB and run gpart I'd like to add the appropriate partitions.
Depending on what you're doing, either the GUI (and middleware behind it) or the dd command will create the partitions needed. You shouldn't do anything other than identify which disk is to be used.
 

balanga

Patron
Joined
Jul 10, 2014
Messages
271
Depending on what you're doing, either the GUI (and middleware behind it) or the dd command will create the partitions needed. You shouldn't do anything other than identify which disk is to be used.
If i dd if=/dev/ada0 of=/dev/da1 won't that create a 1.8T partition on the 4T disk? Just asking as I don't know how dd actually deals with such situations...
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
If i dd if=/dev/ada0 of=/dev/da1 won't that create a 1.8T partition on the 4T disk? Just asking as I don't know how dd actually deals with such situations...
Yes, but the autoexpand feature will (or can be forced to if necessary) expand that partition to the full disk capacity.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Should I follow instructions here
The autoexpand property is set by default, so it shouldn't be necessary.

If it doesn't happen, you can force it from the GUI under Storage | Pools:
1621596118003.png
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
There's no need for autoexpand or anything at the CLI at all--just replace the old disk with the new disk through the GUI. When resilvering completes, power down, remove the old disk, install the new disk, power up.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
There's no need for autoexpand or anything at the CLI at all
Maybe you didn't read the whole thread... I think he's planning to use @Dan Tudora 's suggestion to use dd to duplicate the disk to a bigger one (there's only one disk in the pool and no space for a second in the box), so no resilver will happen.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I think he's planning to use @Dan Tudora 's suggestion to use dd to duplicate the disk
Yes, but why? GUI replacement will do the job--in which case a resilver will happen.
 

balanga

Patron
Joined
Jul 10, 2014
Messages
271
There's no need for autoexpand or anything at the CLI at all--just replace the old disk with the new disk through the GUI. When resilvering completes, power down, remove the old disk, install the new disk, power up.

Can't get my head around this.... I would need to have both disks attached, right? The new one via USB and the old one inside the machine... I can only install the new disk after powering down, or could I boot up the new disk from USB initially to make sure everything is working correctly first.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
You don't boot from your data disk, you boot from your boot device, which wouldn't be changing here. But if you'd like to remove the old disk, keep the new one in the USB dock, and boot to ensure that the data's there, that should work too.
 
Top