# Getting ready to clone a KVM machine



## FlorinMarian (Jan 22, 2020)

Hello!
I run a SolusVM KVM slave and I would like to give for my further customers FreeBSD with auto-install via "Reinstall" button.
I would like to know:
1. What files should I delete from original KVM machine before cloning?
2. It's there any way to resize partitions at first boot or I need multiple clones for each disk size?
3. Any tips?

Thank you!


----------



## SirDice (Jan 23, 2020)

FlorinMarian said:


> What files should I delete from original KVM machine before cloning?


From the top of my head, make all log files empty so there's no "old" information lingering. Delete the /etc/ssh/host_* keys, new ones will be automatically generated when the sshd service is started the first time. If you don't do this all your clones will have the same host keys. Create a /firstboot file (empty file is fine, it just needs to exist). It's the trigger for various useful firstboot-* packages. 



FlorinMarian said:


> It's there any way to resize partitions at first boot


sysutils/firstboot-growfs, sysutils/firstboot-freebsd-update might be useful too. 


FlorinMarian said:


> 3. Any tips?


Change the order of the partitions. Put the freebsd-ufs or freebsd-zfs partition last. That way it's easy to expand without the freebsd-swap partition getting in the way.

Use `ifconfig_DEFAULT="DHCP"` in rc.conf. The `_DEFAULT` will automatically pick the first ethernet interface it finds, in case you switch the driver for it.


----------



## FlorinMarian (May 12, 2020)

SirDice said:


> From the top of my head, make all log files empty so there's no "old" information lingering. Delete the /etc/ssh/host_* keys, new ones will be automatically generated when the sshd service is started the first time. If you don't do this all your clones will have the same host keys. Create a /firstboot file (empty file is fine, it just needs to exist). It's the trigger for various useful firstboot-* packages.
> 
> 
> sysutils/firstboot-growfs, sysutils/firstboot-freebsd-update might be useful too.
> ...


Can you tell me, please, how to proceed with firstboot-freebsd-* in my case?
I mean, I have to install fresh freebsd, install via pkg those modules and then?
Thank you!


----------



## SirDice (May 12, 2020)

FlorinMarian said:


> I have to install fresh freebsd, install via pkg those modules and then?


Add to /etc/rc.conf:

```
firstboot_freebsd_update_enable="YES"
```
Remove the SSH host keys: `rm -f /etc/ssh/ssh_host_*`
Create the /firstboot file: `touch /firstboot`
Shutdown and clone away.


----------

