Solved New SSD, best way to move OS from old disk to new one?



Reaction score: 3
Messages: 52

I have old small 16GB SSD and now I got better 128GB Samsung 850 pro SSD. Copying stuff to new one is easy with dd, but what block size I should use with it?
I not sure what to do with old 16GB SSD, maybe it is good place for swap? 16GB SSD is ada0 and 128GB ada1.

gpart list
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 31277191
first: 40
entries: 152
scheme: GPT
1. Name: ada0p1
   Mediasize: 209715200 (200M)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 20480
   Mode: r0w0e0
   efimedia: HD(1,GPT,825b80ce-33bc-11e9-80b5-c8cbb82b4d7a,0x28,0x64000)
   rawuuid: 825b80ce-33bc-11e9-80b5-c8cbb82b4d7a
   rawtype: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
   label: efiboot0
   length: 209715200
   offset: 20480
   type: efi
   index: 1
   end: 409639
   start: 40
2. Name: ada0p2
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 209735680
   Mode: r0w0e0
   efimedia: HD(2,GPT,8288cb49-33bc-11e9-80b5-c8cbb82b4d7a,0x64028,0x400)
   rawuuid: 8288cb49-33bc-11e9-80b5-c8cbb82b4d7a
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: gptboot0
   length: 524288
   offset: 209735680
   type: freebsd-boot
   index: 2
   end: 410663
   start: 409640
3. Name: ada0p3
   Mediasize: 2147483648 (2.0G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 210763776
   Mode: r1w1e0
   efimedia: HD(3,GPT,829fb6ae-33bc-11e9-80b5-c8cbb82b4d7a,0x64800,0x400000)
   rawuuid: 829fb6ae-33bc-11e9-80b5-c8cbb82b4d7a
   rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
   label: swap0
   length: 2147483648
   offset: 210763776
   type: freebsd-swap
   index: 3
   end: 4605951
   start: 411648
4. Name: ada0p4
   Mediasize: 13655605248 (13G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 2358247424
   Mode: r1w1e1
   efimedia: HD(4,GPT,82b147a8-33bc-11e9-80b5-c8cbb82b4d7a,0x464800,0x196f800)
   rawuuid: 82b147a8-33bc-11e9-80b5-c8cbb82b4d7a
   rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
   label: zfs0
   length: 13655605248
   offset: 2358247424
   type: freebsd-zfs
   index: 4
   end: 31277055
   start: 4605952
1. Name: ada0
   Mediasize: 16013942784 (15G)
   Sectorsize: 512
   Mode: r2w2e3



Reaction score: 99
Messages: 71

The best way to move an OS to another disk is to connect the other disk on another port, or possibly use a USB enclosure, and prepare it with GPART, format it.

Then you simply use sysutils/cpdup, the most stupid tool in the world but the most efficient, and the tool I use the most since I hack FreeBSD.

With cpdup which is simply a local file synchronizer, you have not to worry with not matching partition size... this is just an exact file copier
So you mount the target partitions one by one, and you duplicate.

By default, cpdup doesn't cross soft links and mount points, so this is a secure tool.

When I want to setup a new computer, I start from a special USB key running FreeBSD with an updated base system layout with all the basic configuration, and I first duplicate this base system to the target with CPDUP. After I go to the target and I customize... fstab etc etc
  • Thanks
Reactions: s5e


Active Member

Reaction score: 36
Messages: 183

You mean bs parameter of dd?
I think that isn't really important. Usually 1M is used for large data transfert.

If you use dd for transfering the whole OS, you will have two problems.
First, you'll have two pools with the same name/id on two disks. So I advise you to boot only on your new disk after you copied the old one.
Second, your GPT scheme (edit: if GPT you use) on your new disk will be corrupted because the backup header/table won't be at the end of the disk. You will have to mend it after reboot: gpart recover ada0

After that, you'll have to initialize your old disk (connect it and boot on another system without zfs) and fill it with 0 for example. Then you can reconnect it on your FreeBSD machine and use as you want.

At least, this is how I see the thing using dd.


Active Member

Reaction score: 16
Messages: 102

  • Thanks
Reactions: s5e


Active Member

Reaction score: 36
Messages: 183


I installed FreeBSD 12.0-RELEASE in a VM (VirtualBox) on a virtual 5 GiB sized ssd. Then I added another virtual ssd but with a 8 GiB size. The goal is to transfert the system on the new ssd.

Well, pictures worth better than words.


Here, I take out the "small" ssd from the machine and then restart it. ada1 became ada0.



Active Member

Reaction score: 62
Messages: 162

This is what zfs send | zfs recv are for.

  1. Partition your new disk.
  2. Create a new pool on it.
  3. Take a recursive snapshot of the old ZFS datasets.
  4. zfs send | zfs recv to your new pool.
It even works when your disks are on two different systems: you boot into a LiveCD of FreeBSD, set up the network (including SSH), and fire away. If you're on a LAN and not super paranoid (we all are though), you can even just use nc (system's netcat) without setting up sshd().

This guide has the steps for off-system clones.


New Member

Reaction score: 4
Messages: 12

Why not add the new disk as a zpool mirror to the 1st one, scrub the disk and then remove the small disk from the mirror and let zfs autosize it? zfs also checks that its all good and it works with a live file system.

Format the disk the way you want it, (maybe increase boot and swap?)
If you want it the same, you can just dd if=/dev/ada0 of=/dev/ada1 and then use gpart() to expand ada1p4.

zpool add zroot mirror ada0p4 ada1p4 # make sure you have 'mirror' in there. You will need -f if you used dd on the whole disk
zpool scrub zroot
zpool status # repeat until done... 16 gig ssd should be a few minutes.
install the boot loader if you didn't use dd
At this point you should have a RAID1 clone of your disk.
verify new disk is bootable. I would power down, remove the old disk and reboot to test.
On reboot, it should complain about half the mirror being bad. Use the zpool() commands to remove the disk or you could use zpool split but I'm not sure how stable that is on a running root disk.
Use the zpool set autoexpand=on zroot once your happy with your new clone and your disk will be full size.


Well-Known Member

Reaction score: 93
Messages: 413

I have old small 16GB SSD and now I got better 128GB Samsung 850 pro SSD. Copying stuff to new one is easy with dd, but what block size I should use with it?
I not sure what to do with old 16GB SSD, maybe it is good place for swap? 16GB SSD is ada0 and 128GB ada1.
If you use ZFS, I would do this: Partition the new drive, create the ZFS pools on the new disk, then ZFS send / receive the file systems to the new disk.
You would probably have to copy your EFI system partition and/or install the bootcode with gpart.

If you don't use ZFS, you could partition the disk as described above, then mount the partitions in /mnt and then simply rsync or tar/untar the contents to the new disk. Keep in mind to ignore /mnt when syncing.
Also, update ESP and/or bootcode.

And also, I have read somewhere that using SSDs for swap is not recommended. SSDs don't like lots of writes, because it lowers their lifespan and swaps could write heavily depending on your memory usage.

If you have lots of RAM, swap is actually not necessary, I use SSDs for years without any swap.
If you have little RAM and swap IS necessary, then it would probably wear out your SSD quickly, so maybe find another solution for SWAP - HDD if you could attach one.