Previous Section  < Day Day Up >  Next Section

Recipe 11.5. Building File Trees on a Data CD

11.5.1 Problem

When you select directories for writing to CD, mkisofs discards the root directories and keeps only the files and subdirectories. But you'd like to preserve the file trees, or create new ones.

11.5.2 Solution

Use the -graft-points option in mkisofs. This example preserves the existing directory structure for the directories scripts and finances:

$ ls

finances  scripts

$ mkisofs -r -J -v  -o cdimg1.iso -graft-points scripts/=scripts  finance/=finances

...

Which is easily verified by mounting the image and viewing the file tree with the tree -d command:

$ sudo mount -t iso9660 -o ro,loop cdimg1.iso  /mnt/iso

$ tree -d /mnt/iso

mnt

|-- finances

`-- scripts

Suppose you want to move these two directories into /files/archive/june on the CD. First, the directory /files/archive/june must be present on the hard drive. Then run:

$ mkisofs -r -J -v  -o cdimg1.iso -graft-points  \

files/archive/june/finances/=finances   files/archive/june/scripts/=scripts

Again, we can mount it and check:

$ tree -dL 4 /mnt/iso

mnt

`-- files

    `-- archive

        `-- june

            |-- finances

            `-- scripts

This works for both files and directories.

11.5.3 See Also

  • tree(1), mkisofs(8)

    Previous Section  < Day Day Up >  Next Section