OPNsense Forum

Archive => 22.1 Legacy Series => Topic started by: peterwkc on July 13, 2022, 12:43:31 am

Title: Create Image of my current installation
Post by: peterwkc on July 13, 2022, 12:43:31 am
Dear all,
I would like to create a image(ISO file) of my current configuration. I know there is configuration restore but the plugins is not installed so i want to create my custom ISO file.
Title: Re: Create Image of my current installation
Post by: CGrisamore on July 13, 2022, 01:32:26 am
Maybe Clonezilla?
Title: Re: Create Image of my current installation
Post by: Patrick M. Hausen on July 13, 2022, 06:00:47 am
An ISO will be difficult but a binary image can be created with regular Unix tools.

Example:

dd if=/dev/ada0 bs=1m | gzip -c | ssh user@some.host 'dd of=/some/place/to/store/opnsense-image-20220713.gz'
Title: Re: Create Image of my current installation
Post by: peterwkc on July 13, 2022, 07:11:57 am
Imm looking into clonezilla now. Thanks. Any idea how to clone the hard disk as ISO file???
Title: Re: Create Image of my current installation
Post by: Patrick M. Hausen on July 13, 2022, 09:18:57 am
That is not possible. An ISO filesystem does not support a 1:1 replication of either a UFS or a ZFS installation. And you want the boot partitions, swap partitions etc. too, because otherwise it's again not a one step restore.

Why don't you use the command I wrote? Restore can be done from a live booted USB medium with a similar one liner.
Title: Re: Create Image of my current installation
Post by: peterwkc on July 14, 2022, 08:38:37 am
Is this command correct?

 if=/dev/ada0 bs=5m | gzip -c of=/some/place/to/store/opnsense-image-20220713.gz'
Title: Re: Create Image of my current installation
Post by: peterwkc on July 27, 2022, 02:07:57 am
Is this command correct?

 if=/dev/ada0 bs=5m | gzip -c of=/some/place/to/store/opnsense-image-20220713.gz'
Title: Re: Create Image of my current installation
Post by: Patrick M. Hausen on July 27, 2022, 06:47:46 am
That command is complete nonsense. Compare with my example, please. The tool you use is named "dd" so that goes first on the command line. And of course you need to have a second host where to store the image with ssh access (the "ssh" part of my example) and you need to replace the example directory path with a real path with space to store your image.

My example is complete and syntactically correct. But it needs to be adjusted to your environment.
Title: Re: Create Image of my current installation
Post by: peterwkc on July 29, 2022, 08:53:01 am
Yes, I know of dd command, I don't need ssh access.

dd if=/dev/ada0 bs=1m | gzip -c | of=/some/place/to/store/opnsense-image-20220713.gz'


Title: Re: Create Image of my current installation
Post by: Patrick M. Hausen on July 29, 2022, 09:17:15 am
That looks good but for the trailing '

Do you have a USB drive connected? Or how do you plan to save the image without going over SSH?
Title: Re: Create Image of my current installation
Post by: peterwkc on August 08, 2022, 09:59:34 am
I'm using usb drive.
Title: Re: Create Image of my current installation
Post by: Patrick M. Hausen on August 08, 2022, 11:08:01 am
Ah ... sorry, it does *not* look good :-)
Code: [Select]
dd if=/dev/ada0 bs=1m | gzip -c | of=/some/place/to/store/opnsense-image-20220713.gz'
                                  ^
                                  |
this is nonsense -----------------+

Correct:
Code: [Select]
dd if=/dev/ada0 bs=1m | gzip -c >/some/place/to/store/opnsense-image-20220713.gz

HTH,
Patrick
Title: Re: Create Image of my current installation
Post by: tiermutter on August 24, 2022, 01:27:15 pm
Hi Patrick,

I tried backup and restore from one VM to another (ZFS with multiple BE). I succesfully saved the uncompressed image to my NAS with
Code: [Select]
dd if=/dev/ada0 bs=32m | ssh user@10.13.12.5 'dd of=/share/CACHEDEV7_DATA/Backup/opnsense-image.img'
For restore I used
Code: [Select]
ssh user@10.13.12.5 'dd if=/share/CACHEDEV7_DATA/Backup/opnsense-image.img' | dd of=/dev/ada0 bs=32mRestore looked fine for the first time, as dd writes 20G (Disk size of the source VM) to the destination VM (running OPNsense live), but trying to boot from disk I only got some errors, e.g. calling
Code: [Select]
ZFS: i/o error - all block copies unavailable
Cant find /boot/zfsloader
Cant find /boot/loader
Cant find /boot/kernel/kernel

What am I missing?