DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Loop Device in Linux
  • Debugging Core Dump Files on Linux - A Detailed Guide
  • Analyzing “java.lang.OutOfMemoryError: Failed to create a thread” Error
  • Understanding ldd: The Linux Dynamic Dependency Explorer

Trending

  • Go 1.24+ Native FIPS Support for Easier Compliance
  • Manual Sharding in PostgreSQL: A Step-by-Step Implementation Guide
  • Metrics at a Glance for Production Clusters
  • Exploring Intercooler.js: Simplify AJAX With HTML Attributes
  1. DZone
  2. Coding
  3. Tools
  4. Creating Customized and Bootable Disk Images of Host Systems

Creating Customized and Bootable Disk Images of Host Systems

In this article, discover how to create a customized and bootable disk image of a host system with the tools mkisofs and SystemBack.

By 
Constantin Kwiatkowski user avatar
Constantin Kwiatkowski
·
Sep. 13, 23 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
8.2K Views

Join the DZone community and get the full member experience.

Join For Free

In the realm of Linux and operating systems, disk imaging plays a vital role in various scenarios. Disk images, also known as ISOs, are essentially digital replicas of physical media such as CDs, DVDs, or hard drives. They serve as a convenient means to store and distribute entire file systems, preserving their integrity and structure. One powerful tool available in the Linux world for creating disk images is mkisofs. Developed by Eric Youngdale, mkisofs stands for "make ISO filesystem" and is commonly used to generate ISO-9660 file systems, which are the standard format for disk images. 

What Is mkisofs?

Now, let's dive into how you can utilize mkisofs to create disk images on Linux. Before getting started, let us take a closer look at what mkisofs is and how to install the tool on your system. 

According to Ran, mkisofs is a utility that creates an ISO 9660 image from files on disk. It is effectively a pre-mastering program to generate an ISO9660/JOLIET/HFS hybrid filesystem capable of generating the System Use Sharing Protocol records (SUSP) specified by the Rock Ridge Interchange Protocol. This is used to further describe the files in the iso9660 filesystem to a UNIX host, and provides information such as longer filenames, UID/GID, POSIX permissions, symbolic links, block, and character devices. mkisofs takes a snapshot of a directory tree and generates a binary image that corresponds to an ISO9660 or HFS filesystem when it is written to a block device. Each specified pathspec describes the path of a directory tree to be copied into the ISO9660 filesystem; if multiple paths are specified, the files in all the paths are merged to form the image.

Option Description
-o output_file.iso Specifies the name of the output ISO file
-b boot_image Specifies the location of the boot image
-c boot_catalog Specifies the location of the boot catalog
-no-emul-boot Indicates the boot process should not emulate a floppy disk
-boot-load-size size Specifies the size of the boot loader in sectors
-boot-info-table Specifies that a boot information table should be included in the ISO image
-J Indicates use of Joliet extensions
-R Indicates use of Rock Ridge extensions
-V volume_id Specifies the volume ID for the ISO image
-A application_id Specifies the application ID for the ISO image
-p publisher_id Specifies the publisher ID for the ISO image
-copyright copyright Specifies the copyright information for the ISO image
-hide-rr-moved Specifies that Rock Ridge moved files should be hidden

The upper table shows some options you can select. By default, mkisofs generates ISO-9660 file systems, but it also supports other formats such as Joliet and Rock Ridge extensions. These extensions provide additional features not present in the base ISO-9660 standard, such as longer filenames and POSIX file attributes. To enable Joliet extensions, you can use the "-J" flag when invoking mkisofs. Similarly, the "-R" flag enables Rock Ridge extensions. In addition to these extensions, mkisofs allows you to set various metadata for the disk image, such as volume names, publisher information, and even bootable attributes.

You can find mkisofs in most Linux distributions' package repositories under the same name. 

  • On Ubuntu:

# apt-get install mkisofs

  • On CentOS:

# yum install mkisofs

There are many possibilities in order to customize an ISO. By modifying the ISO image, we can automatically partition the hard drives, install Linux, install several add-on packages, create user accounts, and set up the networking. In the following steps, we will see how to customize an existing ISO template. 

What Is SystemBack? 

SystemBack is a free and open-source backup and system recovery tool for Linux-based operating systems. It is designed to create system backups, which include the entire operating system, user data, and configuration settings. With SystemBack you can create bootable ISO images via a graphical user interface (GUI) that makes it user-friendly and accessible to users who may not be comfortable with command-line tools. Be aware that the development of SystemBack appeared to have slowed down in recent years, and it may not be actively maintained or updated to support the latest Linux distributions. In this article, SystemBack works without any issue with the Ubuntu version ubuntu-18.04.6-live-server-amd64.iso.

How To Create a Disk Image of the Host System

Let us assume we have installed Ubuntu (ubuntu-18.04.6-live-server-amd64.iso) on our machine and tailored the operating system. In this use case, the customized system boots automatically and does not have a boot menu. 

Next, we want to create a bootable ISO image of the adjusted system in order to distribute the system to the client.  

In the first place, create a system backup of the running system as follows:

  1. Create a SystemBack backup.
  2. Click on the "Live system create" option.
  3. Select the backup you created in Step 1 from the list of available backups.
  4. Configure system settings: You can customize various settings like the ISO file name, user accounts, hostname, and other boot options as needed.
  5. Click the "Create new" button to generate the live system ISO. SystemBack will compile the backup into a bootable image.

If you boot the generated ISO image, you will see the following boot menu created by SystemBack:

If you boot the generated ISO image, you will see this boot menu created by SystemBack

To fix this bug, we use mkisofs. 

Therefore, we need to create a folder under /tmp where we specify the source directory test_iso where we save the files and folders of the generated ISO image. 

Shell
 
mkdir /tmp/test_iso


In order to access and modify the contents of an ISO file, you can mount it as a device. Linux will treat it as a separate file system, and allow you to browse the files as you would normally browse the directory structure of your hard drive. The fastest way to mount an ISO image is via the command line. For that reason, let us jump into the source directory:

Shell
 
cd /tmp/test_iso/


We execute the mount command in order to mount the generated ISO image:

Shell
 
mount -t iso9660 -o loop template_linux.iso /mnt/


According to the main page of the mount command: The option -t tells the kernel to attach the filesystem iso9660 found on the loop device. If no explicit loop device is mentioned (but just an option -o loop is given), then mount will try to find some unused loop device and use that and will set up the loop device such as /dev/loop1 to correspond to the generated ISO image, and then mount this device on /mnt. 

We will see a warning: the generated ISO image is read-only. To modify the content of the generated ISO image, we need to copy the content into the source directory after we have switched to the folder /mnt: 

Shell
 
cp -r /mnt/* /tmp/test_iso


Another command for copying the content of the ISO image to the source folder: 

Shell
 
tar cf - . | (cd /tmp/test_iso; tar xfp -)


Now, we can adjust the isolinux config file to remove the boot menu and enable the automatic boot process. 

In the last step, we will create a new bootable ISO image from the source folder. First, switch to the folder /tmp/test_isoand then execute the following command: 

Shell
 
mkisofs -o custom_live_system.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "Custom Live System" .


Conclusion

Creating customized and bootable disk images with SystemBack and mkisofs is a powerful way to distribute pre-configured operating systems tailored to your needs. Whether you're a system administrator or developer, mastering this process will help you streamline deployments and ensure consistency across multiple systems.

File system ISO 9660 Linux (operating system) Disk Copy

Opinions expressed by DZone contributors are their own.

Related

  • Loop Device in Linux
  • Debugging Core Dump Files on Linux - A Detailed Guide
  • Analyzing “java.lang.OutOfMemoryError: Failed to create a thread” Error
  • Understanding ldd: The Linux Dynamic Dependency Explorer

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!