How to create and mount a CD image under CentOS?

Time:2020-1-15

In CentOS, it is very convenient to pack the contents of multiple files or folders into the disc image. We can use:

mkisofs -r -v -o xxx.iso /root /home

The command packs the files under the / root and / home directories into the xxx.iso disc image, and then mounts them through mount loop:

mount -o loop xxx.iso /mnt

At this point, there is a small problem that files in multiple directories will be placed in the root directory of ISO in a “tiled” way, which may not be our intention

We can manually set the placement path in the way of – Grant point:

mkisofs -r -v -V “my_iso” -o xxx.iso -m /home/lost+found -graft-point /root=/root /home=/home

Where – M is the meaning of excluding the specified path