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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-19-2004, 12:39 PM
|
#1
|
Senior Member
Registered: Apr 2003
Posts: 3,695
Rep:
|
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
|
|
|
09-19-2004, 04:06 PM
|
#2
|
Member
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109
Rep:
|
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.
[...]
|
|
|
09-19-2004, 09:16 PM
|
#3
|
Senior Member
Registered: Apr 2003
Posts: 3,695
Original Poster
Rep:
|
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
|
|
|
09-19-2004, 11:28 PM
|
#5
|
Senior Member
Registered: Apr 2003
Posts: 3,695
Original Poster
Rep:
|
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
|
|
|
09-20-2004, 01:23 AM
|
#6
|
Member
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109
Rep:
|
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!
|
|
|
09-20-2004, 02:56 AM
|
#7
|
Senior Member
Registered: Apr 2003
Posts: 3,695
Original Poster
Rep:
|
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
|
|
|
09-20-2004, 07:48 PM
|
#8
|
Member
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109
Rep:
|
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.
|
|
|
09-25-2004, 04:18 AM
|
#9
|
Senior Member
Registered: Apr 2003
Posts: 3,695
Original Poster
Rep:
|
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 04:21 AM.
|
|
|
All times are GMT -5. The time now is 05:04 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|