Edit: Some links no longer work. Originally published on IBM Systems Magazine
mksysb backups make AIX recovery easy
February 2011 | by Anthony English
If you ever need to restore your AIX system, you’ll need a reliable OS backup. You can create this via the mksysb command, which, as the name implies, makes a system backup. That’s not to say it gets your entire AIX system, but it does create a backup of the OS itself, the root volume group. For any other volume groups you’ll need to rely on other backup utilities.
You might need to build a system from a mksysb for disaster recovery or if your OS has become corrupted, but those aren’t the only times a backup comes in handy. A mksysb is a simple and effective way of migrating to new hardware. It can also be used to clone an existing AIX system. For example, you could create a Standard Operating Environment (SOE) LPAR, take a mksysb backup of it and use that to build new LPARs.
Tracing Your Roots
A mksysb is much more than a backup of the files in the rootvg file systems. It includes a boot image, optional software that has been installed into rootvg and system informational files. The mksysb contains the layout of the rootvg logical volumes and the file systems. This is important, as those file systems get created as part of the mksysb restoration process. That saves a lot of work and time. Restoring a mksysb even gives you the option of recovering your devices, so you don’t have to reconfigure network settings, disk attributes and so on. You’d normally use this only when you’re restoring onto the same system you backed up.
In the days of stand-alone systems, the mksysb command would write to a dedicated device such as a tape drive. Today it’s more common for the mksysb to be written to a file on disk and stored on a different LPAR. That way it can be made ready for use without needing to load physical media such as tapes or DVDs.
At Your Command
The mksysb command can be run from the command line or using the SMIT fastpath smitty backsys. You have to specify the output device or file. The mksysb file that’s created is typically between 2 and 4 GB, but it could be much larger, depending on the size of your rootvg. The target file system needs to have enough space for this file, and be large-file-enabled. The ulimit should be set to unlimited for the user who runs the backup.
Updating Your Image
When the mksysb is run, it includes details about volume groups, logical volumes, file systems, paging space and physical volumes. These details are stored in a file called /image.data, which can be created at any time with the mkszfile command, or at the time of the mksysb using the -i flag. This flag provides get an up-to-date snapshot of the file system sizes and mount points. Figure 1 shows the output of a mksysb command that has been written to a file on the /backup file system. As the -i option was used, you can see that a new /image.data file was created.
Be Exclusive
There may be files or directories in your rootvg that you don’t want to include in the mksysb. You can use another utility to back them up, or you may not want to back them up at all. To exclude certain files from your backup, create a file called /etc/exclude.rootvg and enter the patterns of file names or directories that you don’t want to include. Figure 2 shows an example of /etc/exclude.rootvg. When using this exclude file, you need to call the mksysb command with the -e flag. The mksysb command documentation provides more details on the file format.
mksysb to DVD
It’s common to create the mksysb backup from a NIM server (see links), or with the mkdvd command which will create the backup in a format suitable for DVDs. Many administrators are familiar with using NIM to create the mksysb, so I’ll focus on creating a mksysb backup in DVD-compatible format. This doesn’t require burning the backup onto a physical DVD. If you’re using the virtual I/O server (VIOS) Virtual Media Library, you can use mkdvd to create the mksysb file in ISO format, copy it to the VIOS and then load onto a virtual optical device when you want to use it. This is a simple and quick way of cloning or recovering your AIX OS, and it lets you keep bootable OS backups handy without the need for physical media. For more information about the virtual media library, read “Media Release.”
When creating the mksysb in DVD format, the mkdvd command can use an existing mksysb file or create a new mksysb. If the mksysb has been created beforehand, mkdvd can point to it using the -m flag. If you create a new mksysb backup first, the mkdvd creates a new /image.data file. It also accepts the -e flag to exclude unwanted files or directories.
New File Systems
To create a new mksysb and save it in ISO file format, use mkdvd -eS. This creates some temporary file systems in rootvg, so make sure you have spare disk space. You can specify an alternate volume group for the file systems with the -V flag. The -S flag will ensure the final ISO files don’t get deleted, so you can copy them to a remote host such as the VIOS. You’ll need to clean them up on the source host after you’ve done the copying.
The final mksysb file in ISO format is put into /mkcd/cd_images and is called “cd_image_” followed by the process ID as its suffix. If multiple volumes are required, the final images have suffixes to indicate their volume number. You can see a sample output of the mkdvd command with its default file systems in Figure 3.
You can leave the mkdvd to create the file systems it needs in the default locations, or point to other directories using the flags outlined in Figure 4.
A backup is only useful if it can be relied on for successful restores. When it comes to restoring the mksysb, you may need more than the original backup to proceed. The restore process requires 1) a device to boot from, 2) the mksysb backup itself and possibly 3) the AIX product media for installing devices. Ordinarily, if you’re restoring to the same system you backed up from, the mksysb will serve as the boot device, provided the backup itself is bootable. If you’re restoring to a different system, for example for a disaster recovery test, or if the backup was done via mkdvd with the -B flag (non-bootable), you’ll need to boot off the AIX installation media. The media can be a file-backed device presented via a virtual optical device on the VIOS.
You can customise your mksysb backup to specify options such as the disks you want to restore to, and whether to recover device information such as network settings. You can make these selections via the System Managed Storage (SMS) menus when you boot the target LPAR in maintenance mode. You can also do the restoration in unattended mode by editing the /bosinst.data file before you run the backup. If the system you’re restoring to has access to a diskette drive, you can create your own /bosinst.data and point to that at the time of the restore.
How do you know if your mksysb contains all of the device drivers you need for restoration? If you’re restoring to a different server, you’ll generally want to boot from the AIX product media to get any missing device drivers installed. If you are restoring to the same hardware configuration you backed up from, but have booted from product media that is a later version than your mksysb, you’ll be asked to load the product media so that the system you restore to will have its AIX software updated. You can overwrite these additional installations by editing the bosinst.data file and setting INSTALL_DEVICES_AND_UPDATES to no. The default is yes.
Ready-Made Recovery
It’s important to do regular tests of the mksysb restoration, not only to ensure the backup was successful, but also as a means of having documented procedures for rebuilding your system in the event of a disaster. It pays to be confident with your mksysb restoration procedures. Hardware failures aren’t the only reason you may need to use them. Simple mistakes can damage or render an OS as unusable, and the ability to restore AIX quickly and reliably is a key element in your system-recovery strategy.