LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-19-2004, 11:39 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Rep: Reputation: 56
Command line question - creating ISO image


Hi folks,

If I want to create an ISO image from files in several folders say

/path/to/folder-A
/path/to/folder-B
/path/to/folder-C
etc.

Instead of copying all of them to a directory can I use following command line

# mkisofs -R -o Image.iso -J -hide-rr-moved "/path/to/folder-A /path/to/folder-B /path/to/folder-C"

TIA

B.R.
satimis
 
Old 09-19-2004, 03:06 PM   #2
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Yes. Here's what the manpage says:

SYNOPSIS
mkisofs [ options ] [ -o filename ] pathspec [pathspec ...]

DESCRIPTION

[...]

pathspec is the path of the directory tree to be copied into the
iso9660 filesystem. Multiple paths can be specified, and mkisofs will
merge the files found in all of the specified path components to form
the cdrom image.

[...]
 
Old 09-19-2004, 08:16 PM   #3
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
HI gypsy_rabbi,

Tks for your advice.

That is what I got. All files in 3 directories merged together, not under 'Direcotry-A', 'Directory-B', 'Directory-C', etc. separately. So in the past I have to do the stupid way copying all of them to a NEW directory for creating ISO image. If there are 40+ directories, it will take a lot of work.

I'm now searching an easy way to eliminate copying steps.

B.R.
satimis
 
Old 09-19-2004, 09:28 PM   #4
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Ah, I see. The way you do that is using graft-points. There's more info in the mkisofs manpage and also on these two pages:
http://www.linuxquestions.org/questions/history/195035
http://lists.freebsd.org/pipermail/f...er/029909.html

Basically, you say A=/path/to/A B=/path/to/B etc.

HTH.
 
Old 09-19-2004, 10:28 PM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi gypsy_rabbi,

Tks for your further advice.

I solve my problem with -graft-points. It can handle multiple directories, not only one directory, which I did not know in the past.

Now I'm searching how to create a shortcut to execute following command, ON TERMINAL;

mkisofs -R -o Image.iso -J -graft-points -hide-rr-moved dir-A=/path/to/dir-A dir-B=/path/to/dir-B dir-C=/path/to/dir-C

creating an ISO image to a pre-selected directory, say ~/ISO_image/ and with variable for adding additional directories.

TIA

B.R.
satimis
 
Old 09-20-2004, 12:23 AM   #6
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Hi satimis,

I'm not quite sure I understand the question. Are you asking how to automate this with an unspecified number of directory arguments and with a variable path to the ISO image?

If so, you might want to check out the following sections in the bash manpage (which is worth flipping through anyway): aliases, functions (shell functions), parameter expansion (specially ##, %%), etc.

So you could have something like this:
Code:
function make_iso_file ()
{
    # first argument is the path to the iso file
    iso_file_path=$1; shift

    # initialize the following loop
    # we're going to build the args to mkisofs, set it to the empty string
    mkisofs_args=""
    # and set the paths variable to all the remaining command-line arguments
    paths="$@"
    # and now iterate through all paths given on the command-line
    for path in $paths
    do
        # for each path given, add the appropriate graft-point to mkisofs's arguments
        mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
    done

    # and now call mkisofs
    mkisofs ....
}
I'm not sure if this is the sort of thing you were asking for. Hope this helps!
 
Old 09-20-2004, 01:56 AM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi gypsy_rabbi,

Tks for your assistance.

Quote:
...... Are you asking how to automate this with an unspecified number of directory arguments and with a variable path to the ISO image?
Yes
1) I expect to embed the command to a desktop icon, executed with a click. OR the command to be executed on Terminal with a WORD, e.g mozilla <ENTER> to start Mozilla browser.
2) The directory for keeping ISO image is fixed.
3) Number of directories is variable, i.e further directories can be added in addition to pre-fixed directories
4) Paths to pre-fixed directories fixed. Paths to added directories being variable

Code:
function make_iso_file ()
{
    # first argument is the path to the iso file
    iso_file_path=$1; shift
What is $1? Is it an argument for entry, i.e. requesting to enter the /Path/to/dir-ISO_image. It is fixed. I suppose this line can be erased.

Code:
# initialize the following loop
    # we're going to build the args to mkisofs, set it to the empty string
    mkisofs_args=""
Can I change it to read
mkisofs=/path/to/dir-ISO_image

Code:
# and set the paths variable to all the remaining command-line arguments
    paths="$@"
    # and now iterate through all paths given on the command-line
    for path in $paths
    do
        # for each path given, add the appropriate graft-point to mkisofs's arguments
        mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
    done
Here I'm a little bid confusing. Suppose I have 3 pre-fixed directories, say.
/path/to/dir-A
/path/to/dir-B
/path/to/dir-C

Plus a number of directories to be added later which are variable including their path
Code:
    # and now call mkisofs
    mkisofs ....
Is it the number of dots must be four (4) otherwise 'mkisofs' can't be called.

TIA

B.R.
satimis
 
Old 09-20-2004, 06:48 PM   #8
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Hi Satimis,

If you're going to be delving into this stuff I strongly recommend that you read some sort of shell-scripting manual. Check out the appropriate howtos at tldp.org: http://www.google.com/search?q=site%...hell+scripting (TLDP is The Linux Documentation Project). Or even just the section on bash in the O'Reilly Unix in a Nutshell book.

Yes. $1 is the first argument to a function or script, in this case the ISO image file's full path (including filename). You can hardcode that if you like -- if it's not going to change and doesn't need to be a command-line parameter.

The initial value of mkisofs_args can be either blank or the basic stuff that's not going to change (in your case all this: -R -o Image.iso -J -hide-rr-moved A=/path/to/A B=/path/to/B)

The for loop in the function I gave you adds the appropriate graft-point for each additional pathspec that you give the function.

The four dots just indicated "whatever you want to call mkisofs with."

So this might work for you:

Code:
function make_iso_file ()
{
    # initialize the following loop
    # we're going to build the args to mkisofs, set it to the empty string
    mkisofs_args="-R -o Image.iso -J -hide-rr-moved A=/path/to/A B=/path/to/B"
    # and set the paths variable to all the remaining command-line arguments
    paths="$@"
    # and now iterate through all paths given on the command-line
    for path in $paths
    do
        # for each path given, add the appropriate graft-point to mkisofs's arguments
        mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
    done

    # and now call mkisofs
    mkisofs $mkisofs_args
}
Now if you call make_iso_file without any arguments it'll do just the standard thing (A, B, etc.); if you add any more arguments it'll add those into the ISO image as well.
 
Old 09-25-2004, 03:18 AM   #9
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi gypsy_rabbi,

Tks for your advice and assistance.

Quote:
If you're going to be delving into this stuff I strongly recommend that you read some sort of shell-scripting manual. Check out the appropriate howtos at tldp.org: http://www.google.com/search?q=site%...hell+scripting (TLDP is The Linux Documentation Project). Or even just the section on bash in the O'Reilly Unix in a Nutshell book.
Tks for your advice and links.

Quote:
Yes. $1 is the first argument to a function or script, in this case the ISO image file's full path (including filename). You can hardcode that if you like -- if it's not going to change and doesn't need to be a command-line parameter.

The initial value of mkisofs_args can be either blank or the basic stuff that's not going to change (in your case all this: -R -o Image.iso -J -hide-rr-moved A=/path/to/A B=/path/to/B)

The for loop in the function I gave you adds the appropriate graft-point for each additional pathspec that you give the function.

The four dots just indicated "whatever you want to call mkisofs with."
Noted with tks.
Quote:
So this might work for you:

Code:
function make_iso_file ()
{
    # initialize the following loop
    # we're going to build the args to mkisofs, set it to the empty string
    mkisofs_args="-R -o Image.iso -J -hide-rr-moved A=/path/to/A B=/path/to/B"
    # and set the paths variable to all the remaining command-line arguments
    paths="$@"
    # and now iterate through all paths given on the command-line
    for path in $paths
    do
        # for each path given, add the appropriate graft-point to mkisofs's arguments
        mkisofs_args="${mkisofs_args} ${path##*/}=${path}"
    done

    # and now call mkisofs
    mkisofs $mkisofs_args
}
I shall perfom follow;

# touch /usr/sbin/make_iso_file
(without extension/argument)

use 'nano' to edit /usr/sbin/make_iso_file
copying your codes to this file and save it.

# chmod +x /usr/sbin/make_iso_file

Run follow to start it
# /usr/sbin/make_iso_file <ENTER>

Then it will popup a window for me to enter addtional directories.

If I'm wrong please advise.

TIA

B.R.
satimis

Last edited by satimis; 09-25-2004 at 03:21 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
K3B and creating an .iso image from a CD? rgbrock1 Linux - Software 5 11-23-2005 11:17 AM
Creating an ISO image of a CD tawalker Linux - Software 2 01-26-2005 11:03 PM
Bash script to do copying and ISO image creating, etc. satimis Programming 2 09-19-2004 09:47 PM
Creating ISO image question satimis Linux - Software 1 07-16-2004 11:32 PM
Creating dvd iso image chevy2410 Linux - Software 1 06-08-2004 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration