Solved Migrate system disk to new drive

Hello,

I have a ssd as system disk (UFS) and two hdd as a zpool. The ssd is some-years-old and I plan to move the system disk to new hardware, keeping UFS.

Plan is:
---------
1. Buy a new ssd (obviously...)
2. Add it to the system
3. Prepare it with gparted: Add partition(s), make it bootable
4. Create filesystem
5. Mount it to /mnt/newdisk
6. Copy everything from old_partitions to new_partitions using rsync: rsync -axAHX /oldpartitions /mnt/newdisk/newpartitions
7. Poweroff the system
8. Remove old ssd, plug new ssd to its bay
9. Poweron

Do I miss something? Will the zpool just work or do I have to remove it and re-add it?

Thanks,

Steffen
 
Don't forget the file flags. If rsync is your preferred tool, it seems to support them using the --fileflags option. The base system uses the immutable flag (and maybe others?).
 
tar(1) is usable without any non-base software and understands extended attributes and ACLs natively; rsync is more limited. Some invocation of tar like this should work: tar -C /oldpartitions -cf - . | tar -C /mnt/newdisk/newpartitions -xf -

There is also dump(8) and restore(8), but they only work in certain circumstances.
 
I'm always doing fresh installs and restore my configs/data from the backup since over a dozen years. So I get rid of leftovers, and have a clean system. Second benefit: It's a super check that tells me that my backup concept truly works, if it's fast and easy enough to restore when things go wrong, etc. ;)
 
Here comes the transcript of how I do this employing sysutils/clone:

1. Become system admin (root):
sudo -s

2. Find the device identifier of the target disk, maybe ada1, in the following adaX needs to be replaced by the actual ID:
ls -l /dev/ada*
gpart show


3. Partition the target disk:
gpart destroy -F adaX
gpart create -s GPT adaX
gpart add -b 40 -s 128 -t freebsd-boot adaX
gpart add -s 81752 -t efi adaX
gpart add -s 8G -t freebsd-swap -l swap adaX
gpart add -t freebsd-ufs -l system adaX

4. View the new partitions -- this should look something like this:
gpart show -l adaX
Code:
=>    40  937703008  adaX  GPT  (447G)
      40        128     1  (null)  (64K)
     168      81752     2  (null)  (40M)
   81920   16777216     3  swap  (8.0G)
16859136  920843912     4  system  (439G)

5. Make the disk bootable for both BIOS and UEFI:
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 adaX

newfs_msdos -F 32 -c 1 /dev/adaXp2
mount -t msdosfs /dev/adaXp2 /mnt
mkdir -p /mnt/EFI/BOOT
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
umount /mnt

gpart set -a bootme -i 4 adaX

Note: The following tells the computer to boot from this disk in BIOS mode, for UEFI mode omit this:
gpart set -a active adaX

6. Format the FreeBSD system partition:
newfs -njtEU /dev/adaXp4
tunefs -a enable /dev/adaXp4

7. Mount the FreeBSD system partition to the /mnt mount point:
mount -o noatime /dev/adaXp4 /mnt

8. The clone(1) command - depending on the speed of the hard disks or SSDs this may take some time:
clone -c rwoff -x .sujournal / /mnt

9. Edit the file /mnt/etc/fstab. Once the whole thing looks like this, then save and exit:
Code:
# Device            Mountpoint      FStype  Options Dump    Pass#
/dev/gpt/system     /               ufs     rw      1       1
/dev/gpt/swap       none            swap    sw      0       0
proc                /proc           procfs  rw      0       0

10. Remove the finished clone from the mount point:
umount /mnt

11. Become a normal user and DONE!!!
exit
 
Here comes the transcript of how I do this employing sysutils/clone:

1. Become system admin (root)
sudo -s

2. Find the device identifier of the target disk, mayve ada1, in the following adaX needs to be replaced by the actual ID:
ls -l /dev/ada*
gpart show


3. Partition the target disk
gpart destroy -F adaX
gpart create -s GPT adaX
gpart add -b 40 -s 128 -t freebsd-boot adaX
gpart add -s 81752 -t efi adaX
gpart add -s 8G -t freebsd-swap -l swap adaX
gpart add -t freebsd-ufs -l system adaX

4. View the new partitions -- this should look something like this:
gpart show -l adaX
Code:
=>    40  937703008  adaX  GPT  (447G)
      40        128     1  (null)  (64K)
     168      81752     2  (null)  (40M)
   81920   16777216     3  swap  (8.0G)
16859136  920843912     4  system  (439G)

5. Make the disk bootable for both BIOS and UEFI:
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 adaX

newfs_msdos -F 32 -c 1 /dev/adaXp2
mount -t msdosfs /dev/adaXp2 /mnt
mkdir -p /mnt/EFI/BOOT
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
umount /mnt

Note: The following tells the computer to boot from this disk in BIOS mode, for UEFI mode omit this:
gpart set -a bootme -i 4 adaX

6. Format the FreeBSD System Partition
newfs -njtEU /dev/adaXp4
tunefs -a enable /dev/adaXp4

7. Mount the FreeBSD system partition to the /mnt mount point:
mount -o noatime /dev/adaXp4 /mnt

8. The clone(1) command - depending on the speed of the hard disks or SSDs this may take some time
clone -c rwoff -x .sujournal / /mnt

9. Edit the file /mnt/etc/fstab. Once the whole thing looks like this, then save and exit:
Code:
# Device            Mountpoint      FStype  Options Dump    Pass#
/dev/gpt/sytem      /               ufs     rw      1       1
/dev/gpt/swap       none            swap    sw      0       0
proc                /proc           procfs  rw      0       0

10. Remove the finished clone from the mount point:
umount /mnt

11. Become a normal user and DONE!!!
exit
Very helpful, thanks!
 
Back
Top