Difference between revisions of "ISO Images"
(→Burn ISO (image) to a CD) |
(→Burn ISO (image) to a CD) |
||
Line 51: | Line 51: | ||
$ wodim dev=/dev/sr0 --devices | $ wodim dev=/dev/sr0 --devices | ||
$ wodim dev=/dev/sr0 -scanbus | $ wodim dev=/dev/sr0 -scanbus | ||
− | $ wodim -v -dao dev=/dev/sr0 -dummy isoimagename.iso | + | $ wodim -v -dao dev=/dev/sr0 -dummy isoimagename.iso # test first |
+ | $ wodim -v -dao dev=/dev/sr0 isoimagename.iso | ||
+ | |||
+ | Note: You can set "<code>cdrom= /dev/sr0</code>" in <code>/etc/wodim.conf</code> and then you do not have to add "<code>dev=/dev/sr0</code>" to your <tt>cdrecord</tt> or <tt>wodim</tt> commands. E.g., | ||
+ | $ wodim -checkdrive | ||
+ | |||
+ | Another way to find your CD/DVD device: | ||
+ | $ sudo lshw | awk '/\*-cd/,/con/' | sed -e 's/^[ \t]*//' | ||
+ | If you see "<code>status=nodisc</code>", you either do not have a CD/DVD in the drive or your system does not recognize it. | ||
==Burn ISO (image) to a DVD== | ==Burn ISO (image) to a DVD== |
Revision as of 18:37, 11 July 2014
This article will explain how to make ISO images in a Linux environment and various other things you can do with/to ISO images. Everything will be done from the CLI (or command line).
Contents
- 1 Discover UDB device name
- 2 Make a bootable USB stick from an ISO image
- 3 ISO from CD/DVD
- 4 ISO from files on Hard Drive (HDD)
- 5 Burn ISO (image) to a CD
- 6 Burn ISO (image) to a DVD
- 7 Misc DVD burning examples
- 8 Format DVD+RW media
- 9 Mount an ISO image in Linux
- 10 isotools
- 11 Encrypt CDs/DVDs
- 12 devs
- 13 See also
- 14 External links
Discover UDB device name
You can use any one of the following commands if you need to figure out the device name (or mount point) of your USB stick:
$ grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short) $ udevadm monitor --udev $ dmesg -T|grep -i usb $ lsinput # part of the "input-utils" package
Make a bootable USB stick from an ISO image
$ sudo dd if=filename.iso of=/dev/usbdevice bs=4M; sync
NOTE: There is never a trailing number on the end of your /dev/sdx
USB device.
ISO from CD/DVD
To make an ISO from your CD/DVD, place the media in your drive but do not mount it. If it "automounts", unmount it (eg, umount /dev/cdrom).
- For a DVD:
dd if=/dev/dvd of=dvd.iso
- For a CD:
dd if=/dev/cdrom of=cd.iso
- For a CD (as SCSI):
dd if=/dev/scd0 of=cd.iso
also,
cat /dev/cdrecorder >> /home/username/isoimagename.iso
ISO from files on Hard Drive (HDD)
To make an ISO from files on an HDD, create a directory which holds the files you place in your ISO image. Then use the mkisofs command.
- Example commands:
mkisofs -o /tmp/cd.iso /tmp/directory/
This results in a file called cd.iso
in folder /tmp
which contains all the files and directories in /tmp/directory/
.
mkisofs -o isoimagename.iso -J -r /home/username/directory_for_iso
where -J
means use "Joliet" (i.e., generate Joliet directory records in addition to regular iso9660 file names. This is primarily useful when the discs are to be used on Windows-NT or Windows-95 machines). The -r
is for the directory and file permissions, user/group IDs, etc.
Burn ISO (image) to a CD
Once you have built your .iso
, you can burn this image to a CD using:
$ cdrecord -v speed=8 dev=ATA:1,1,0 isoimagename.iso
where the dev
parameters can be found by issuing the following as root:
$ cdrecord -scanbus
you can also simulate/test a burn first to make sure everything is good by:
$ cdrecord dev=0,0 -v -dummy isoimagename.iso
Note: You should use 'dev=/dev/hdX
' with v2.6 and later kernels.
For example, if your CD drive is on /dev/hdc
:
$ cdrecord -v blank=fast -multi -tao -data speed=16 dev=/dev/hdc isoimagename.iso
If you do not have cdrecord on your system, you could use wodim instead:
$ wodim dev=/dev/sr0 --devices $ wodim dev=/dev/sr0 -scanbus $ wodim -v -dao dev=/dev/sr0 -dummy isoimagename.iso # test first $ wodim -v -dao dev=/dev/sr0 isoimagename.iso
Note: You can set "cdrom= /dev/sr0
" in /etc/wodim.conf
and then you do not have to add "dev=/dev/sr0
" to your cdrecord or wodim commands. E.g.,
$ wodim -checkdrive
Another way to find your CD/DVD device:
$ sudo lshw | awk '/\*-cd/,/con/' | sed -e 's/^[ \t]*//'
If you see "status=nodisc
", you either do not have a CD/DVD in the drive or your system does not recognize it.
Burn ISO (image) to a DVD
growisofs -dvd-compat -Z /dev/hda=foo.iso -speed=16
E.g.,
sudo growisofs -dvd-compat -Z /dev/dvd=linuxmint-15-cinnamon-dvd-64bit.iso -speed=16
Misc DVD burning examples
- Blank (zero-over) a rewritable DVD (note: not required before burning, but erases sensitive data):
growisofs -Z /dev/dvd=/dev/zero
- Burn a data DVD:
growisofs -dvd-compat -speed=2 -Z /dev/dvd -R -J -pad /path/to/file1 /path/to/file2
- Burn data file to DVD:
growisofs -Z /dev/dvd -R -J /path/to/file
- Burn a data backup DVD using more mkisofs commands (note: works on DVD+R and double layer DVD+R DL):
- Example 1 (note: may not be DOS-compatible because of long file name support, possible leading dot, or multi-dot filenames):
growisofs -speed=8 -Z /dev/dvd -R -J -allow-multidot -allow-leading-dots -l -pad -graft-points "/home/user1=/home/user1"
- Example 2 (note: write a DVD which MS Windows can read - but not MS-DOS due to the "-l" option and long filenames):
growisofs -dvd-compat speed=2 -Z /dev/dvd -R -J -pad -graft-points "/DirectoryNameA=/home/user1/DirectoryNameA" "/SubDirectoryNameC=/home/user1/DirectoryNameB/SubDirectoryNameC"
Format DVD+RW media
In this example, we will use the dvd+rw-format
utility.
- Syntax:
- usage: /usr/bin/dvd+rw-format [-force[=full]] [-lead-out|-blank[=full]] [-ssa[=none|default|max]] /dev/dvd
- Format: To format a DVD+RW disc, type the following command (replace the device name with yours):
dvd+rw-format -force=full /dev/hdd
It can take several minutes. Here is the output of the command:
* DVD±RW/-RAM format utility by <appro@fy.chalmers.se>, version 6.1. * 4.7GB DVD+RW media detected. * formatting
- Make the UDF filesystem: Once the disc is formatted, you can create the UDF filesystem on the disc:
mkudffs --lvid="dvdrw-backup" --udfrev=0x0150 /dev/hdd
You can add your own options but it's a good thing to use UDF revision 1.50 since it can avoid compatibility problems with several operating systems. Of course, you should change the volume ID. Here is an example of the output of mkudffs
:
start=0, blocks=16, type=RESERVED start=16, blocks=3, type=VRS start=19, blocks=237, type=USPACE start=256, blocks=1, type=ANCHOR start=257, blocks=16, type=PVDS start=273, blocks=1, type=LVID start=274, blocks=2294573, type=PSPACE start=2294847, blocks=1, type=ANCHOR start=2294848, blocks=239, type=USPACE start=2295087, blocks=16, type=RVDS start=2295103, blocks=1, type=ANCHOR
- Mount the disc and copy the files: The media is now formatted as UDF. Now mount it in read-write (
rw
) mode. First, create a mount point:
mkdir -p /mnt/dvdrw mount -t udf -o rw,noatime /dev/hdd /mnt/dvdrw
- Copy files: You can now write your files in
/mnt/dvdrd
as you would for any mounted partition of your hard disk. (Note: Be careful not to go over to maximum amount of space available on a DVD {4.7 GB for a simple layer disc}).
For example, if you want to use Partimage to save a partition to the disc, you can type this sort of command:
partimage -z1 save /dev/hda1 /mnt/dvdrw/myimage.pi
- Use du to check the size of a directory:
du -sh /boot 100M /boot
- Umount the disc: Remember to unmount the disc when you are done and run sync to force the data to be physically written:
umount /mnt/dvdrw sync
Mount an ISO image in Linux
It is possible to mount an ISO image in Linux just like any device or file system. This is a convenient way of backing up your CDs and DVDs onto your hard drive and be able to read all of the files on these discs. It is also a good way to check your ISO images before burning them to disc.
- Step 1: Create a mount point for the ISO:
mkdir /mnt/iso
- Step 2: Now mount the ISO in the mount point with the following command:
mount myiso.iso /mnt/iso -t iso9660 -o ro,loop=/dev/loop0
where myiso.iso
is your ISO file.
You can also place the above mount command in your /etc/fstab
file for automatic mounting upon boot up (and as a "permanent" mount).
If you wish to mount more than one ISO image, you can use a different device (e.g. /dev/loop1
). By default you have 8 loop devices (loop0 - loop7
). You can extend this number up to 255. To do this, you will need to edit your /usr/src/linux/drivers/block/loop.c
file and change the following:
#define MAX_LOOP 8
to
#define MAX_LOOP 255
and then rebuild the module. (see here: Linux Loop Devices for details.)
Automount ISO images as user
The above section showed how to mount an ISO as root. However, if you wish to allow users to mount images, you will need to change the procedure a bit.
- Step 1: Create a soft link to a generic ISO file
Let's say you have an ISO called foo.iso
. Create a soft link to this file:
ln -s foo.iso /home/bob/images/my.iso
- Step 2: Add the following to your
/etc/fstab
file:
/home/bob/images/my.iso /mnt/iso auto ro,loop=/dev/loop0,user 0 0
- Step 3: Mount the ISO as user
mount /mnt/iso
That's it!
isotools
Jörg Schilling, author of cdrtools (with mkisofs and cdda2wav) and K3b, has created a utility-pack called isotools. It ships with the following utilities:
- isodebug
- isodump
- isoinfo
- isovfy
As an example, if you have an ISO called foo.iso
, you can view its contents (i.e. files) with this command:
isoinfo -i foo.iso -f -R -J | less
Encrypt CDs/DVDs
mkisofs -r backup | aespipe -e aes256 > backup.iso modprobe aes # as root modprobe cryptoloop # as root
- Mount the ISO (see above):
mount -t iso9660 backup.iso /mnt/iso -o loop=/dev/loop0,encryption=aes256
- Mount the burnt CD/DVD:
mount -t iso9660 /dev/cdrom /mnt/iso -o loop=/dev/loop0,encryption=aes256
See: http://loop-aes.sourceforge.net/
devs
In "dev=ATA:x,y,z
", x
is 'channel', y
is 0
for 'master' and 1
for 'slave', z
seems to always be zero (not sure why).
Thus,
devs | |||
---|---|---|---|
IDE Port | Master/slave | Device | cdrecord |
1 | master | /dev/hda |
"dev=ATA:0,0,0 "
|
1 | slave | /dev/hdb |
"dev=ATA:0,1,0 "
|
2 | master | /dev/hdc |
"dev=ATA:1,0,0 "
|
2 | slave | /dev/hdd |
"dev=ATA:1,1,0 "
|
3 | master | /dev/hde |
etc. |
3 | slave | /dev/hdf |
|
4 | master | /dev/hdg |
|
4 | slave | /dev/hdh |