Internet Message Access Protocol version 4 (IMAP 4 ) is an email retrieval protocol which is a lot more robust than the Post Office Protocol version 3 ( POP3). It provides features like name spaces,folders,sub folders,flags etc.. A discussion of all the features is beyond the scope of this article. Here we will see how we can test the basic functionalities of an IMAP server using telnet.
First, establish a connection to the IMAP server using telnet on port 143.
safeer@penguinpower:~$ telnet imap.safeer.in 143
Trying 10.25.0.3...
Connected to imap.safeer.in
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. See COPYING for distribution information.
The last line of the output is a greeting from the IMAP server. Further conversation with the IMAP server will be a series of requests and responses. Requests are also known as commands and should begin with an arbitrary tag (an alpha numeric string ) followed by a command and its optional arguments, all separated by spaces. The response, if positive will be the request tag name followed by OK and further by a server message. This is for a single line response. If the response is multi line, all except the last line with begin with a "*" and the last line will be request tag followed by OK and then server message. A negative response will begin with request tag followed by a "NO" and a server message.
To test the IMAP server at a minimum we should login,select INBOX, retrieve a message and logout. Let us start by providing a tag followed by the command "login" followed by the IMAP username and password, all separated by spaces.
A01 LOGIN safeer fake_Password
A01 OK LOGIN Ok.
With IMAP, you can have multiple mailboxes. "INBOX" is the default and only one mailbox if you have not configured additional mailboxes. Let us see the mailboxes and its sub folders using list command. It takes two arguments, first being the folder to list and the second being a search parameter. Since we are looking for mail boxes, we should be searching the root of the IMAP indicated by a blank "". The search parameter is a wildcard ( "*" ) here since we want to see all folders under the root.
A02 list "" "*"
* LIST (\Marked \HasNoChildren) "." "INBOX"
1 OK LIST completed
This is a multi line response from the server and it says there is only one mailbox "INBOX" with no sub folders. Now let us see the status of the "INBOX" and find out the number of messages in it.
A03 STATUS INBOX messages
* STATUS "INBOX" (MESSAGES 1)
A03 OK STATUS Completed.
There is only one message in the INBOX. In order to view messages in the mailbox INBOX ( or any IMAP folder for that matter ) we should first select the folder.
A04 SELECT INBOX
* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited
* 1 EXISTS
* 1 RECENT
* OK [UIDVALIDITY 1358664910] Ok
* OK [MYRIGHTS "acdilrsw"] ACL
A04 OK [READ-WRITE] Ok
In the response, 1 EXISTS means there is only one message in INBOX and 1 RECENT means that 1 message is unread. We can list/read the emails by using the fetch command. Let us read the message ( since there is only one message in the INBOX, the id of the message will be 1 and that is passed as an argument to fetch command). Let us first view the email headers.
A05 FETCH 1 body[header]
* 1 FETCH (BODY[HEADER] {501}
Return-Path: <info@safeer.in>
X-Original-To: safeer@safeer.in
Delivered-To: safeer@smtp.safeer.in
Received: from penguinpower (penguinpower [128.1.0.5])
by smtp.safeer.in (Postfix) with ESMTP id AD10226089C
for <safeer@safeer.in>; Thu, 10 Feb 2011 00:42:29 +0530 (IST)
Subject: POP3 Check
Message-Id: <20110210191235.AD10226089C@smtp.safeer.in>
Date: Thu, 10 Feb 2011 00:42:29 +0530 (IST)
From: info@safeer.in
)
* 1 FETCH (FLAGS (\Seen \Recent))
A05 OK FETCH completed.
You can see the message headers. Now let us read the message text.
A06 FETCH 1 body[text]
* 1 FETCH (BODY[TEXT] {14}
Testing POP3
)
A06 OK FETCH completed.
We are done retrieving the message. Note that fetch command can operate on a single message id or a range or ids in the format START:END.
Now logout of the session:
A07 LOGOUT
* BYE Courier-IMAP server shutting down
A07 OK LOGOUT completed
Connection closed by foreign host.
To know more about IMAP checkout the IMAP RFC at ITEF
Saturday, February 12, 2011
Tuesday, January 25, 2011
Test your POP3 server with Telnet
Post Office Porotocl version 3 ( POP3 ) is the protocol used to retrieve emails from a mail server. We generally use email clients like thunderbird, outlook etc to connect to the server and read the emails. But when you want to test your pop3 server it is useful to connect to the server through a direct tcp channel and examine its basic functionalities. The communication with the server is through a series of requests and responses. The requests are also know as pop3 commands and have specified syntaxes.
To start with we have to establish a tcp session with the pop3 server. The is done using the telnet utility to connect to the pop3 server on the pop3 port ( the default is 110, but this can be changed in the pop3 server configuration).
safeer@penguinpower:~$ telnet pop.safeer.in 110
Trying 10.25.0.2...
Connected to pop.safeer.in.
Escape character is '^]'.
+OK Dovecot ready.
The first three lines of the output is common for any telnet session, it just says the connection is successfully established.
The fourth line is the response from the pop3 server. The pop3 server has two standard responses, positive and negative. They start with a positive or negative response code +OK or -ERR respectively followed by a server message. Here the response is positive as you can see, and the message says "Dovecot ready" - dovecot being the pop3 server software running on pop.safeer.in
Once you establish the connection with the server, you have to identify yourself by providing a username and password in the following format.
USER safeer
+OK
PASS fake_Password
+OK Logged in.
This section is self explanatory. Now let us inspect a summary statistics of my mailbox.
STAT
+OK 3 2086
The response code is OK, the second column is the number of messages in the mailbox and the third is the total size of the messages
Let us list all the three messages
LIST
+OK 3 messages:
1 501
2 1035
3 550
.
First line of the response says, the listing is successful ( +OK ) and the mailbox has 3 messages. Subsequent lines list each messages, the first column being the message id and the second being the message size.
Now let us view a mail, to do so issue the command RETR followed by message id.
RETR 1
+OK 501 octets
Return-Path: <info@safeer.in>
X-Original-To: safeer
Delivered-To: safeer@safeer.in
Received: from penguinpower (penguinpower [128.0.0.5])
by smtp.safeer.in (Postfix) with SMTP id C53EFG509TH;
Mon, 24 Jan 2011 10:49:06 +0530 (IST)
subject: POP3 server setup
Message-Id: <20110124051909.C53EFG509TH@smtp.safeer.in>
Date: Mon, 24 Jan 2011 10:49:06 +0530 (IST)
From: info@safeer.in
Mail server setup successfully
.
So the server responded +OK followed by size of the message, and the subsequent lines prints out the email with all the headers included.
Let us delete the message now, issue the command DELE followed by the message id.
DELE 1
+OK Marked to be deleted.
LIST
+OK 2 messages:
1 1035
2 550
Be aware that issuing the DELE command just marks the message for deletion. The actual deletion of message happens when the user disconnects from the current pop3 session. So while you are in the session, it is still possible to recover your message by issuing RSET command.
RSET
+OK
LIST
+OK 3 messages:
1 501
2 1035
3 550
We are done, now exit the session by issuing the QUIT command.
QUIT
+OK Logging out.
If you had messages marked for deletion, the server response would also say "messages deleted"
To learn more about POP3, look at the POP3 RFC at IETF
To start with we have to establish a tcp session with the pop3 server. The is done using the telnet utility to connect to the pop3 server on the pop3 port ( the default is 110, but this can be changed in the pop3 server configuration).
safeer@penguinpower:~$ telnet pop.safeer.in 110
Trying 10.25.0.2...
Connected to pop.safeer.in.
Escape character is '^]'.
+OK Dovecot ready.
The first three lines of the output is common for any telnet session, it just says the connection is successfully established.
The fourth line is the response from the pop3 server. The pop3 server has two standard responses, positive and negative. They start with a positive or negative response code +OK or -ERR respectively followed by a server message. Here the response is positive as you can see, and the message says "Dovecot ready" - dovecot being the pop3 server software running on pop.safeer.in
Once you establish the connection with the server, you have to identify yourself by providing a username and password in the following format.
USER safeer
+OK
PASS fake_Password
+OK Logged in.
This section is self explanatory. Now let us inspect a summary statistics of my mailbox.
STAT
+OK 3 2086
The response code is OK, the second column is the number of messages in the mailbox and the third is the total size of the messages
Let us list all the three messages
LIST
+OK 3 messages:
1 501
2 1035
3 550
.
First line of the response says, the listing is successful ( +OK ) and the mailbox has 3 messages. Subsequent lines list each messages, the first column being the message id and the second being the message size.
Now let us view a mail, to do so issue the command RETR followed by message id.
RETR 1
+OK 501 octets
Return-Path: <info@safeer.in>
X-Original-To: safeer
Delivered-To: safeer@safeer.in
Received: from penguinpower (penguinpower [128.0.0.5])
by smtp.safeer.in (Postfix) with SMTP id C53EFG509TH;
Mon, 24 Jan 2011 10:49:06 +0530 (IST)
subject: POP3 server setup
Message-Id: <20110124051909.C53EFG509TH@smtp.safeer.in>
Date: Mon, 24 Jan 2011 10:49:06 +0530 (IST)
From: info@safeer.in
Mail server setup successfully
.
So the server responded +OK followed by size of the message, and the subsequent lines prints out the email with all the headers included.
Let us delete the message now, issue the command DELE followed by the message id.
DELE 1
+OK Marked to be deleted.
LIST
+OK 2 messages:
1 1035
2 550
Be aware that issuing the DELE command just marks the message for deletion. The actual deletion of message happens when the user disconnects from the current pop3 session. So while you are in the session, it is still possible to recover your message by issuing RSET command.
RSET
+OK
LIST
+OK 3 messages:
1 501
2 1035
3 550
We are done, now exit the session by issuing the QUIT command.
QUIT
+OK Logging out.
If you had messages marked for deletion, the server response would also say "messages deleted"
To learn more about POP3, look at the POP3 RFC at IETF
Friday, January 14, 2011
Test your SMTP server with Telnet
SMTP ( Simple Mail Transfer Protocol ) is the protocol email servers use to send and receive mails. Normally we do use email clients like Thunderbird,Outlook or the web-mail to send and receive mails. But what happens behind the scene is an exchange of SMTP commands and responses between the client and the mail server. Knowing how to use these commands directly will help you in testing a mail servers functionality. Here we will examine the basic commands and use them to connect to a mail server and send mail.
We will use the telnet program to establish a connection to the mail server ( on port 25 - this can be different based on your mail server configuration )
safeer@penguinpower:~$ telnet smtp.safeer.in 25
Trying 10.25.0.1...
Connected to smtp.safeer.in.
Escape character is '^]'.
220 smtp.safeer.in ESMTP Postfix (Ubuntu)
The first three lines of the output is common for any telnet session, it just says the connection is successfully established.
The fourth line is a response from the mail server. Every response from a mail server starts with an SMTP response code followed by further information. Now in the above line the mail server is displaying its banner which mentions the hostname of the mail server ( smtp.safeer.in ) , the mail server software ( Postfix ) and the operating system on which the server is running ( Ubuntu ). This banner is configurable in your mail server.
In order to communicate with the mail server, you should send SMTP request commands which will be in the format of a command followed by arguments.
1) Once you establish a connection with the mail server, to initiate a conversation with it you would greet the server with the command HELO followed by your hostname. The server will greet you back with response code 250 followed by its hostname.
HELO penguinpower
250 smtp.safeer.in
Now let us compose a mail
2) The first step is to specify the "from" email address. The command is "MAIL FROM: <your email id>". The response code will be 250 followed by the message OK
MAIL FROM: safeer@safeer.in
250 2.1.0 Ok
3) Next specify the recipient address using the command "RCPT TO: <recipient email id>". The response again will be code 250 followed by message.
RCPT TO: praveen@gmail.com
250 2.1.5 Ok
This can be repeated multiple times to allow multiple recipients.
4) Once you are ready to type in the message, enter the command "DATA". Response will be code 354 followed by message.
DATA
354 End data with <CR><LF>.<CR><LF>
The email body will contain your email message and optionally email headers (which should be added at the beginning of the message). A few commonly used message headers are Subject,From,To,Cc
A message header should be of the following syntax:
<HEADER NAME>: <HEADER VALUE>
After the headers, add your message then put a period ( . ) on a new line and press enter to finish the message.
Let us compose our message now.
Subject: Happy New Year!!!
From: safeer@safeer.in
To: praveen@gmail.com
Happy New Year
.
250 2.0.0 Ok: queued as C53E7265CB0
The response from mail server says the message is accepted for delivery.
Remember that the delivery of the message is not dependant on the From/To/Cc headers within the message body. MAIL FROM & RCPT TO parameters decides the delivery. The headers in message is as such delivered to the recipients, and it is the duty of the mail client of the recipient to interpret and present the message headers to the user.
5) If after entering RCPT TO or MAIL FROM you feel that you provided wrong information and want to start over without terminating the existing connection, issue the command RSET ( stands for reset ).
4) We are done. Say goodbye to server.
QUIT
221 2.0.0 Bye
Connection closed by foreign host.
Second line above is the response from server while the third line is the output of telnet command terminating.
For more information on smtp protocol, refer to SMTP RFC at IETF
We will use the telnet program to establish a connection to the mail server ( on port 25 - this can be different based on your mail server configuration )
safeer@penguinpower:~$ telnet smtp.safeer.in 25
Trying 10.25.0.1...
Connected to smtp.safeer.in.
Escape character is '^]'.
220 smtp.safeer.in ESMTP Postfix (Ubuntu)
The first three lines of the output is common for any telnet session, it just says the connection is successfully established.
The fourth line is a response from the mail server. Every response from a mail server starts with an SMTP response code followed by further information. Now in the above line the mail server is displaying its banner which mentions the hostname of the mail server ( smtp.safeer.in ) , the mail server software ( Postfix ) and the operating system on which the server is running ( Ubuntu ). This banner is configurable in your mail server.
In order to communicate with the mail server, you should send SMTP request commands which will be in the format of a command followed by arguments.
1) Once you establish a connection with the mail server, to initiate a conversation with it you would greet the server with the command HELO followed by your hostname. The server will greet you back with response code 250 followed by its hostname.
HELO penguinpower
250 smtp.safeer.in
Now let us compose a mail
2) The first step is to specify the "from" email address. The command is "MAIL FROM: <your email id>". The response code will be 250 followed by the message OK
MAIL FROM: safeer@safeer.in
250 2.1.0 Ok
3) Next specify the recipient address using the command "RCPT TO: <recipient email id>". The response again will be code 250 followed by message.
RCPT TO: praveen@gmail.com
250 2.1.5 Ok
This can be repeated multiple times to allow multiple recipients.
4) Once you are ready to type in the message, enter the command "DATA". Response will be code 354 followed by message.
DATA
354 End data with <CR><LF>.<CR><LF>
The email body will contain your email message and optionally email headers (which should be added at the beginning of the message). A few commonly used message headers are Subject,From,To,Cc
A message header should be of the following syntax:
<HEADER NAME>: <HEADER VALUE>
After the headers, add your message then put a period ( . ) on a new line and press enter to finish the message.
Let us compose our message now.
Subject: Happy New Year!!!
From: safeer@safeer.in
To: praveen@gmail.com
Happy New Year
.
250 2.0.0 Ok: queued as C53E7265CB0
The response from mail server says the message is accepted for delivery.
Remember that the delivery of the message is not dependant on the From/To/Cc headers within the message body. MAIL FROM & RCPT TO parameters decides the delivery. The headers in message is as such delivered to the recipients, and it is the duty of the mail client of the recipient to interpret and present the message headers to the user.
5) If after entering RCPT TO or MAIL FROM you feel that you provided wrong information and want to start over without terminating the existing connection, issue the command RSET ( stands for reset ).
4) We are done. Say goodbye to server.
QUIT
221 2.0.0 Bye
Connection closed by foreign host.
Second line above is the response from server while the third line is the output of telnet command terminating.
For more information on smtp protocol, refer to SMTP RFC at IETF
Friday, December 17, 2010
Configuring Dovecot as a POP3 or IMAP server
Dovecot can be used to retrieve mail using pop3 or imap protocols. The minimal configuration that will get you started is pretty simple and straight forward.
First install the package, for RHEL based distros, it is dovecot.
yum install dovecot
The main configuration file for dovecot is /etc/dovecot.conf ( location changes based on you installation, file name remains as dovecot.conf )
## Dovecot supports pop3,pop3s,imap and imaps protocols.
## Enable whichever you require.
protocols = imap pop3
## If you are using conventional unix style mboxes under
## /var/spool/mail/<username> for storing mail
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u
That is it, you can start using dovecot sevice. Edit and save the file and restart service.
sudo /usr/sbin/service dovecot restart
To test if dovecot is working, use instructions from following tutorial
Testing your POP3 server with telnet
First install the package, for RHEL based distros, it is dovecot.
yum install dovecot
The main configuration file for dovecot is /etc/dovecot.conf ( location changes based on you installation, file name remains as dovecot.conf )
## Dovecot supports pop3,pop3s,imap and imaps protocols.
## Enable whichever you require.
protocols = imap pop3
## If you are using conventional unix style mboxes under
## /var/spool/mail/<username> for storing mail
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u
That is it, you can start using dovecot sevice. Edit and save the file and restart service.
sudo /usr/sbin/service dovecot restart
To test if dovecot is working, use instructions from following tutorial
Testing your POP3 server with telnet
Sunday, November 7, 2010
Managing ISO files in Linux
ISO (International organizations for standardization) format is the archive file format for optical discs. The name is derived from the file system format for optical discs, known as ISO 9660 File System. This format is also known as CDFS (Compact Disc File System). ISO files are used to either create the image of an optical disc, or to write data to it.
Here are a few tricks to create and manage ISO files.
Creating an ISO image out of a CD ROM mounted in your machine.
We can use the dd (Disc Dump) command to take the copy of an optical disc. For this first you have to insert the disc in the drive, then find out the device name of your CD-ROM.
Once the CD is mounted, you can find your CD drive in this way:
safeer@penguinpower:~$ mount|grep -i iso
/dev/sr0 on /media/UBUNTU_10 type iso9660(ro,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500)
Here my CD device is /dev/sr0. In most of the systems where you have a single CD drive, this will be symlinked to /dev/cdrom, so you can even use that in place of /dev/sr0 ( or whatever your device is).
safeer@penguinpower:~$ ls -l /dev/cdrom
lrwxrwxrwx 1 root root 3 2010-11-06 10:23 /dev/cdrom -> sr0
Now that we know our CD device name, let us create the ISO image of the mounted disc.
safeer@penguinpower:~$ dd if=/dev/sr0 of=/home/safeer/ISO/ubuntu10.iso
1365028+0 records in
1365028+0 records out
698894336 bytes (699 MB) copied, 267.224 s, 2.6 MB/s
Where "/dev/sr0" is my CD device and "/home/safeer/ISO/ubuntu10.iso" is the name of the iso image that will be created from the CD.
Mounting an ISO file as if you are mounting a CD-ROM.
ISO file can be mounted in a UNIX file system just like inserting a CD to your CD drive. We make use of the loop device system for this purpose. Loop device is a pseudo file system available in Linux/UNIX that makes a file accessible as a block device.
First, create a mount point
safeer@penguinpower:~$ sudo mkdir /mnt/iso
Then mount the ISO file as loop device
safeer@penguinpower:~$ sudo mount -o loop -t iso9660 /home/safeer/ISO/ubuntu10.iso /mnt/iso/
safeer@penguinpower:~$ mount |grep iso
/dev/loop0 on /mnt/iso type iso9660 (rw)
Now you can browse the contents of iso /home/safeer/ISO/ubuntu10.iso via the directory /mnt/iso/.
To unmount the device:
safeer@penguinpower:~$ sudo umount /mnt/iso
Creating an ISO file from a directory.
You can use mkisofs command to create an iso. In my system mkisofs is a symlink to the program genisoimage. You can use either command for this purpose.
Here I will create an iso image of all softwares that I downloaded.
safeer@penguinpower:~$ mkisofs -o software.iso /home/safeer/Downloads/
I: -input-charset not specified, using utf-8 (detected in locale settings)
Using VPNC_000.RPM;1 for /vpnc-0.5.3-8.fc13.src.rpm (vpnc-0.5.3-6.fc11.x86_64.rpm)
Using VPNC_001.RPM;1 for /vpnc-0.5.3-6.fc11.x86_64.rpm (vpnc-0.5.3-8.fc13.x86_64.rpm)
1.03% done, estimate finish Sun Nov 7 18:28:59 2010
2.06% done, estimate finish Sun Nov 7 18:28:59 2010
................................
................................
98.68% done, estimate finish Sun Nov 7 18:29:33 2010
99.71% done, estimate finish Sun Nov 7 18:29:34 2010
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 4914
Path table size(bytes): 36
Max brk space used 1b000
486421 extents written (950 MB)
Let us check the iso image by mounting it.
safeer@penguinpower:~$ sudo mount -t iso9660 -o loop software.iso /mnt
safeer@penguinpower:~$ cd /mnt/
safeer@penguinpower:/mnt$ ls
a0654873.tor google_c.deb skype_de.deb torrentd.tor vpnc_000.rpm vpnc_0_5.deb vpnc_con.rpm
adberdr9.deb opera_10.deb skype_ub.deb virtualb.deb vpnc_001.rpm vpnc_0_5.rpm vpnc_scr.rpm
The problem with using the default settings for mkisofs is that it truncates the filenames to be compatible with DOS file system. A few options that will help us create better image is shown below.
safeer@penguinpower:~$ mkisofs -r -R -J -l -o software.iso /home/safeer/Downloads/
I: -input-charset not specified, using utf-8 (detected in locale settings)
1.03% done, estimate finish Sun Nov 7 18:56:33 2010
....................................................
99.71% done, estimate finish Sun Nov 7 18:57:00 2010
Total translation table size: 0
Total rockridge attributes bytes: 5152
Total directory bytes: 11248
Path table size(bytes): 36
Max brk space used 1c000
486433 extents written (950 MB)
Checkout the man pages for more details on mkisofs
Here are a few tricks to create and manage ISO files.
Creating an ISO image out of a CD ROM mounted in your machine.
We can use the dd (Disc Dump) command to take the copy of an optical disc. For this first you have to insert the disc in the drive, then find out the device name of your CD-ROM.
Once the CD is mounted, you can find your CD drive in this way:
safeer@penguinpower:~$ mount|grep -i iso
/dev/sr0 on /media/UBUNTU_10 type iso9660(ro,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500)
Here my CD device is /dev/sr0. In most of the systems where you have a single CD drive, this will be symlinked to /dev/cdrom, so you can even use that in place of /dev/sr0 ( or whatever your device is).
safeer@penguinpower:~$ ls -l /dev/cdrom
lrwxrwxrwx 1 root root 3 2010-11-06 10:23 /dev/cdrom -> sr0
Now that we know our CD device name, let us create the ISO image of the mounted disc.
safeer@penguinpower:~$ dd if=/dev/sr0 of=/home/safeer/ISO/ubuntu10.iso
1365028+0 records in
1365028+0 records out
698894336 bytes (699 MB) copied, 267.224 s, 2.6 MB/s
Where "/dev/sr0" is my CD device and "/home/safeer/ISO/ubuntu10.iso" is the name of the iso image that will be created from the CD.
Mounting an ISO file as if you are mounting a CD-ROM.
ISO file can be mounted in a UNIX file system just like inserting a CD to your CD drive. We make use of the loop device system for this purpose. Loop device is a pseudo file system available in Linux/UNIX that makes a file accessible as a block device.
First, create a mount point
safeer@penguinpower:~$ sudo mkdir /mnt/iso
Then mount the ISO file as loop device
safeer@penguinpower:~$ sudo mount -o loop -t iso9660 /home/safeer/ISO/ubuntu10.iso /mnt/iso/
safeer@penguinpower:~$ mount |grep iso
/dev/loop0 on /mnt/iso type iso9660 (rw)
Now you can browse the contents of iso /home/safeer/ISO/ubuntu10.iso via the directory /mnt/iso/.
To unmount the device:
safeer@penguinpower:~$ sudo umount /mnt/iso
Creating an ISO file from a directory.
You can use mkisofs command to create an iso. In my system mkisofs is a symlink to the program genisoimage. You can use either command for this purpose.
Here I will create an iso image of all softwares that I downloaded.
safeer@penguinpower:~$ mkisofs -o software.iso /home/safeer/Downloads/
I: -input-charset not specified, using utf-8 (detected in locale settings)
Using VPNC_000.RPM;1 for /vpnc-0.5.3-8.fc13.src.rpm (vpnc-0.5.3-6.fc11.x86_64.rpm)
Using VPNC_001.RPM;1 for /vpnc-0.5.3-6.fc11.x86_64.rpm (vpnc-0.5.3-8.fc13.x86_64.rpm)
1.03% done, estimate finish Sun Nov 7 18:28:59 2010
2.06% done, estimate finish Sun Nov 7 18:28:59 2010
................................
................................
98.68% done, estimate finish Sun Nov 7 18:29:33 2010
99.71% done, estimate finish Sun Nov 7 18:29:34 2010
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 4914
Path table size(bytes): 36
Max brk space used 1b000
486421 extents written (950 MB)
Let us check the iso image by mounting it.
safeer@penguinpower:~$ sudo mount -t iso9660 -o loop software.iso /mnt
safeer@penguinpower:~$ cd /mnt/
safeer@penguinpower:/mnt$ ls
a0654873.tor google_c.deb skype_de.deb torrentd.tor vpnc_000.rpm vpnc_0_5.deb vpnc_con.rpm
adberdr9.deb opera_10.deb skype_ub.deb virtualb.deb vpnc_001.rpm vpnc_0_5.rpm vpnc_scr.rpm
The problem with using the default settings for mkisofs is that it truncates the filenames to be compatible with DOS file system. A few options that will help us create better image is shown below.
safeer@penguinpower:~$ mkisofs -r -R -J -l -o software.iso /home/safeer/Downloads/
I: -input-charset not specified, using utf-8 (detected in locale settings)
1.03% done, estimate finish Sun Nov 7 18:56:33 2010
....................................................
99.71% done, estimate finish Sun Nov 7 18:57:00 2010
Total translation table size: 0
Total rockridge attributes bytes: 5152
Total directory bytes: 11248
Path table size(bytes): 36
Max brk space used 1c000
486433 extents written (950 MB)
Checkout the man pages for more details on mkisofs
Labels:
File System,
ISO,
Linux
Subscribe to:
Posts (Atom)