Re: frequent disk error, need guidance

From: David Christensen <dpchrist_at_holgerdanske.com>
Date: Sat, 15 Apr 2023 21:21:51 UTC
On 4/15/23 12:25, Gary Aitken wrote:

> Thanks all who responded.
> Replaced the cable and retried, no change.
> Used different port with new cable, no change.
> Brought up, tested (smartctl --test=long), set up a new disk.
> Having never actually done this (I've always installed a newer version
> of fbsd in such cases), wanted to see if the following is a good way
> to copy the old disk to the new one.
> 
> mount /dev/ada1p2 /mnt/newsys
> cd /mnt/newsys
> dump -0 -f - /dev/ada0p2 | restore -r -Dv -f -
> 
> However... this is a running system, which seems unlikely to produce
> a consistent result.
> 
> There are only 2 sata slots on the mobo, so I can't mount a third
> system, although I might be able to build a memstick and use that.
> Can I reboot in a read-only manner and do the above?
> Never done that, not sure what's involved.
> Is single-user mode sufficient?
> 
> Thanks,
> 
> Gary


Okay.  So, it sounds like the HDD is failing.


I would not attempt to clone the system drive of running OS -- it is a 
moving target, and I do not have the expertise.


If you boot a live drive, I expect dump/ restore of each file system 
could work.  But, you also have to deal with partitioning schemes, 
partition table(s), slices, partitions, boot loaders, file systems, 
etc..  AIUI Clonezilla facilitates such, but I am unsure of its FreeBSD 
support:

https://clonezilla.org/


I do imaging/ cloning the KISS way -- I shut down the computer, connect 
a large HDD, boot a live USB stick, and use dd(1) to copy the system 
drive blocks 0 through the end of the last slice to an image file on the 
external HDD.  I typically pipe the stream through gzip(1) to reduce 
storage space and run time.  I restore by copying the image file to the 
system drive or to a replacement drive.  I clone by copying the source 
drive or the image file to a target drive.  This process is complete for 
MBR partitioning.  For GPT partitioning, you must account for the backup 
partition table; the simplest approach is to copy the entire system drive.


David