LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-13-2024, 03:01 AM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 567

Rep: Reputation: 10
Post How do I use virt-sysprep in Debian?


Hello,
I have a Debian virtual machine and I use it as a web server. I need three more web servers and want to clone this virtual machine. I heard that I should use virt-sysprep, but I don't know what to do. Do I need to install virt-sysprep on the virtual machine?

Thank you.
 
Old 05-13-2024, 02:05 PM   #2
yvesjv
Member
 
Registered: Sep 2015
Location: Australia
Distribution: Slackware, Devuan, Freebsd
Posts: 578

Rep: Reputation: Disabled
Depends what technology you are using to run your VMs.
They usually have a cloning tool.
 
1 members found this post helpful.
Old 05-14-2024, 02:58 AM   #3
___
Member
 
Registered: Apr 2023
Posts: 155
Blog Entries: 1

Rep: Reputation: Disabled
https://libguestfs.org/virt-sysprep.1.html after https://docs.oracle.com/en/virtualiz...ser/clone.html so maybe not(?)
 
1 members found this post helpful.
Old 05-14-2024, 05:12 AM   #4
Jason.nix
Member
 
Registered: Feb 2023
Posts: 567

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by yvesjv View Post
Depends what technology you are using to run your VMs.
They usually have a cloning tool.
Hello,
Thank you so much for your reply.
I use XCP-ng and Citrix XenServer. Do you mean that using the cloning tool they provide will do all the required work? Tasks such as removing SSH host keys, removing persistent network MAC configuration, etc.
 
Old 05-14-2024, 07:31 PM   #5
Ladowny
Member
 
Registered: Oct 2006
Distribution: Debian, OpenBSD, FreeBSD
Posts: 54

Rep: Reputation: 15
Not using Citrix XenServer myself now (have used it in the past), but it's functionality is pretty similar to VMWare for example. In VMWare ( an in Citrix too ) you can export an import your VM to Open Virtualization Format (OVF and OVA) or clone VM. These tools will not make changes to the OS configuration. Your ssh keys, users, network config and other settings will remain the same on the clone. You will need to make changes eg. hostname, IP address etc yourself. Only the MAC address of your NIC's will change as this is on the virtual hardware side and is managed by virtualization platform.

However, do you really need to use virt-sysprep? You would if you wanted to create a clone to share with the world to avoid revealing your ssh private keys, password hashes or other confidential data. If you will be the one using clones I see no need to do that.

I used to do a lot of VM cloning in the past. The downside is that if you use the free version of virtualization platform you need to shut your VM down (at least in VMWare). With paid version you can actually clone a running VM. What I was doing on the paid version of VMWare was:

1. Clone running VM
2. Disconnect NIC's (network interfaces) in the clone to avoid IP address conflicts with the running original VM and power on the clone
3. Log in with virtual remote console and ( in Debian ) edit /etc/hostname , /etc/network/interfaces and /etc/hosts to assign new name, IP address and mapping of the new host name to the IP address.
4. Shut down the clone, re-enable NIC's and power it back on.

If you use the host name or IP somewhere else in your configs you may need to make changes to these as well eg. /etc/ssh/sshd_config, your web server configs (you don't mention what web server you use), your Exim config (if you use default MTA), firewall rules. Otherwise you may end up with your daemons listening on the IP address you do not have on this machine and in result not be able to connect. I would just grep your /etc directory for your old host name/IP and change everywhere.
If you use free version you will need to power of your VM before cloning, the rest remains the same. Don't forget to power it back on when done ;-)

However these days I'm using CFEngine to build a server from scratch in unattended way rather than cloning. This way I get a fresh machine with all the latest security updates quicker than if I was to copy the VM especially if it is big. There are plenty of other tools like Puppet, Ansimble, Chef that do the same. With these tools setting up a web server takes 5-10 mins of work (most of it to choose the hostname and the IP address and write it down in CMDB) and 30 - 60 mins (depending on the internet connection and disk storage speed) of drinking coffee and waiting for the server to be prepared.

I'm still using the feature to export VM's though on for my critical infrastructure hosts to be able to quickly recover in case of a disaster. I have them exported into OVA (sigle file) format and keep them offsite on a NAS storage as a backup.

Last edited by Ladowny; 05-14-2024 at 07:44 PM.
 
1 members found this post helpful.
Old 05-18-2024, 02:02 PM   #6
yvesjv
Member
 
Registered: Sep 2015
Location: Australia
Distribution: Slackware, Devuan, Freebsd
Posts: 578

Rep: Reputation: Disabled
Thumbs up

@Ladowny, nice write up
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sysprep like alternative for Ubuntu 18.04 and customization possibilities Mangosniper Ubuntu 4 05-12-2020 10:46 AM
How to clone a Linux virtual image to redeploy in vm? (like sysprep for Win) rfreiberger Linux - Newbie 2 05-20-2010 04:05 AM
Sysprep Alternative f9Pete Linux - Software 2 07-04-2008 02:44 PM
Issues combining sysprep with ntfsclone gd2shoe Linux - Software 5 07-18-2006 03:45 PM
SysPrep for RedHat After Using Ghost 7.5?? gerhardbartsch Linux - Distributions 2 08-27-2003 05:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration