Sysprepping an Ubuntu image
Is there a way to make a capture-ready Ubuntu image? something like Sysprep for Windows, where you remove all the user-specific data from the image (like user accounts, passwords, etc …) to make a ‘golden’ universal image ready to be capture by FOG and then deployed on other computers.
@anisgh There isn’t a concept of sysprep (like) solution for ubuntu. If you spin up a new golden image from dvd you have a generic ubuntu instance. Unless you specifically add users there is no user data to remove.
Sysprep also removes the current driver store from windows making it redetect the hardware ids again, in ubuntu (linux) all of the drives are built into the kernel, it auto detects the hardware on every reboot.
What specific problem are you trying to solve?
@george1421 Thanks for the reply!
I’m trying to capture an Ubuntu image and deploy it to other computers using FOG.
The problem I’m facing is when I install Ubuntu on a machine and then capture it, when deployed on other machines, it is 100% identical to the captured image, which is obviously not good, as every machine should have its own hostname, user names and password should not carry on from the captured image to the deployed image etc …
I understand this is easily done on Windows using the FOG client (does not work on Linux) or Sysprep (not available for Linux).
I just thought of a work-around: As an image I can use an raw ISO Ubuntu image (which I can customize with software, configs etc … using Cubic for example) and then deploy this image with PXE using FOG, this would solve 95% of my problems, only if I knew how to configure FOG in such a way to boot from ISO …
bviously not good, as every machine should have its own hostname, user names and password
when I install Ubuntu on a machine and then capture it, when deployed on other machines, it is 100% identical to the captured image
FOG is doing exactly as it was designed to do. It may not be what you want, but its doing what it was designed to do. The rest we can fix once we understand the issue.
When you say usernames and passwords what are you referring to? Are you referring to unbuntu forces you to create the first user when you make the golden image from dvd? The only user you might create is root in the golden image.
The host name we can fix with a post install script, I’m just trying to understand the other bits.
As for booting iso images with FOG, it can be done directly for bios modes, usually for uefi you would expand the iso image to the fog server then reference that iso image over nfs to the pxe booting OS. I have a large tutorial on booting your favorite installer using FOG that might give you a direction if you wanted to move that way.
@george1421 Let’s say when I installed Ubuntu, during the installation a user ‘X’ was created with a specific password. Now let’s say I captured that image with FOG and deployed it to another machine then that other machine would have a user ‘X’ on it with the same password, that’s the problem I’m facing. A perfect scenario would be that this image that I captured, when deployed on another machine would ask the user to create a new account, or at least to login with his account present on an active directory (adding the deployed Ubuntu image to the active directory is a problem I’m gonna deal with later)
I managed to handle the host name change with a post install script, that was easy to do.
As for the booting from an ISO image using FOG, I followed your tutorial here which was pretty clear, but sadly I’m stuck in this loop after trying to boot from the ISO
after a quick google search, it seems to me this is not possible anymore in the latest version of Ubuntu …
@anisgh Ok so lets follow that sysprep concept. The easiest solution is to not create the user when you build the golden image. I don’t use ubuntu so I don’t know if that’s an option. But lets say its not. So lets create a script called sysprep, and you would run that on your ubuntu golden image. Within that sysprep script you could execute a series of commands and then call a system shutdown (just like sysprep does). Now you need to decide what this sysprep script will do before shutting down ubuntu.
You might have it reset the hostname back to some generic name, and then remove the default added user with something like
deluser --remove-home usernameThe last thing you will need to setup is a first run script (akin to windows setupcomplete.cmd batch file) https://askubuntu.com/questions/156771/run-a-script-only-at-the-very-first-boot This will let you do some customization on first boot of the computer (like creating new use and such). You would do this with the unattend.xml file or the setupcomplete.cmd in windows anyway.
Now that you have the ubuntu image cleaned up shutdown the computer.
To extend this a bit more, in your post install script that renames the computer. You could access FOG fields like other1, other2, and (assigned user, don’t remember the actual field name). You use one of those fields to hold the name of the user account to create on the computer. You will write that user name to a text file that your first run script will find and create the user. When you create the user account with a generic password (like Password-1) use this to expire the account so they would be forced to reset the password on first login
passwd --expire <username>
The point is to use FOG to leave bread crumbs in the target system based on deployment time values, then use a first run script in the target OS to pickup the crumbs and do something with them. This is the same for windows as well as linux. While FOS is linux, its not the target system linux so it can’t do much more than leave bread crumbs behind for the target OS to find.