mkisofsコマンドの使い方

#mkisofsコマンド
メモ書きです。
ISOファイルを作るLinuxコマンド

雑すぎるので非公開にしたいんだけどやり方がわからない

##基本的な使い方
manページより引用
> genisoimage [options] [-o filename] pathspec [pathspec ...]

```bash
man mkisofs
```
でgenisoimageのmanページが表示されたので、代替されているのか？という疑問。
調べてみた。

##genisoimageとmkisofsの違い
https://askubuntu.com/questions/557910/difference-between-mkisofs-and-genisoimage
>Looking at the genisoimage man page, and the mkisofs man page, There is really no difference. `genisoimage` is a carbon copy of `mkisofs`.
>`genisoimage` is part of cdrkit, while `mkisofs` is part of cdrtools.

違いはないそうです。全く同じコマンドと考えてよさそう。
genisoimage <-- cdrkitの一部
mkisofs <-- cdrtoolsの一部

## オプション
とりあえず以下のオプションの使い方をこの記事ではメモする。
（試行錯誤中なので取り消し線が入っている。取り消し線が入っている項目は、含めても含めなくても影響がなかった）

- -Dオプション(8階層以上はいりそう)

- -Rオプション(最強？)
- -lオプション
- ~~-Nオプション~~
- ~~-Lオプション~~
- -oオプション（必須）

```bash
# mkisofs -D -R -l -N -L -o filename.iso pathspec
```
でとりあえず使える感じらしい。

## -Dオプション
`-disable-deep-relocation`と同じ意味
(ハイフン一つだと一文字一文字コマンドとして認識されるみたいな話じゃなかったっけ。-文字-文字みたいな感じで挟んでいるから一つの塊として認識されているのだろうか。後日調べる）
--> https://askubuntu.com/questions/813303/whats-the-difference-between-one-hyphen-and-two-hyphens-in-a-command/813432
基本的にハイフン1つがショートネーム、ハイフン2つがロングネームという規則ですが、守ってないパターンもあるらしい。これはそれ。

manより引用
>Do not use deep directory relocation, and instead just pack them
              in the way we see them.
              If ISO9660:1999 has not been selected, this violates the ISO9660
              standard, but it happens to work on many systems.  Use with cau-
              tion.

deep directory relocationを使わないオプション。
ディレクトリ構造がそのままISOイメージなるのかな。（後日もう少し調べます）

## -Rオプション
`-rock`オプションと同じ
manより引用
>Generate SUSP and RR records using the Rock  Ridge  protocol  to
              further describe the files on the ISO9660 filesystem.

SUSPとRRレコードを生成する。
the Rock Ridge プロトコルを使う。
ISO9660ファイルシステムにおけるファイルを詳細に説明するためのオプション。

~~日本語でおｋ~~

## -lオプション
`-full-iso9660-filenames`と同じ
manより引用
>Allow  full  31-character filenames.  Normally the ISO9660 file-
              name will be in an 8.3 format which is compatible  with  MS-DOS,
              even  though  the  ISO9660 standard allows filenames of up to 31
              characters.  If you use this option, the disc may  be  difficult
              to  use on a MS-DOS system, but will work on most other systems.
              Use with caution.

31文字をフルで使うファイル名を許可するオプション。
ISO9660のファイルネームは通常、MS-DOSと互換性のある8.3 formatの制限を受ける（意訳）。
このオプション使えばその制約がなくなるけど、MS-DOSシステムでは使えなくなるかもとのこと。

8.3formatはまあ文字数が少ないことらしい。
8文字+拡張子3文字
https://www.computerhope.com/jargon/num/8-3-format.htm

-lはlongの略かな。

## -N
`-omit-version-number`と同じ
manより引用
>Omit version numbers from ISO9660 filenames.
              This  violates  the ISO9660 standard, but no one really uses the
              version numbers anyway.  Use with caution.

ISO9660ファイル名からバージョン番号を除外する。
ISO9660のstandardに違反するけど、バージョン番号使っている人なんて全然いないらしい。
注意して使う。

## -Lオプション
manより引用
> Outdated option; use `-allow-leading-dots` instead.

時代遅れらしい。
というわけで、`-allow-leading-dots`について書く。

## -allow-leading-dots
`-ldots`と同じ意味
manより引用
>Allow  ISO9660  filenames  to  begin  with a period.  Usually, a
              leading dot is replaced with an underscore in order to  maintain
              MS-DOS compatibility.
              This  violates  the  ISO9660 standard, but it happens to work on
              many systems.  Use with caution.

ISO9660ファイル名がピリオドから始まることを許容する。
普通は、先頭の(leadingっていうんですね)ドットは、MS-DOSとの互換性を保つために、アンダースコア(_)に置換されてしまうらしい。（このオプションを指定で置換されなくなるということか）
LinuxのためのISOファイル作成したいなら必須オプションですね。

## -oオプション
-o filename
ファイル名を引数？にする
manより引用
>Specify the output file for the the  ISO9660  filesystem  image.
              This  can  be  a  disk  file, a tape drive, or it can correspond
              directly to the device name of the optical disc writer.  If  not
              specified,  stdout  is used.  Note that the output can also be a
              block device for a regular disk partition,  in  which  case  the
              ISO9660 filesystem can be mounted normally to verify that it was
              generated correctly.

ISO9660ファイルシステムイメージの出力ファイルを指定する。
以下になり得る

* ディスクファイル
* テープドライブ
* 光学ディスクライターのデバイス名

指定なしだと、stdoutが使われる。
stdoutとは、標準出力のことっぽい。standard output
--> https://www.computerhope.com/jargon/s/stdout.htm

後半よくわからないのでGoogle翻訳貼っておきます。
>出力は、通常のディスクパーティション用のブロックデバイス。この場合、ISO9660ファイルシステムは正常にマウントされ、正しく生成されたことを確認できます。

## 終わり
とりあえずメモです。
もう少し調べて追記します。

## manのdescriptionを一応見る
>mkisofs is effectively a pre-mastering program to generate an ISO9660/JOLIET/HFS hybrid filesystem.
mkisofs is capable of generating the System Use Sharing Protocol records (SUSP) specified by the Rock Ridge Interchange Protocol. This is used to further describe the files in the iso9660 filesystem to a unix host, and provides information such as longer filenames, uid/gid, posix permissions, symbolic links, block and character devices.
>
If Joliet or HFS hybrid command line options are specified, mkisofs will create additional filesystem meta data for Joliet or HFS. The file content in this case refers to the same data blocks on the media. It will generate a pure ISO9660 filesystem unless the Joliet or HFS hybrid command line options are given.
>
mkisofs can generate a true (or shared) HFS hybrid filesystem. The same files are seen as HFS files when accessed from a Macintosh and as ISO9660 files when accessed from other machines. HFS stands for Hierarchical File System and is the native file system used on Macintosh computers.
>
As an alternative, mkisofs can generate the Apple Extensions to ISO9660 for each file. These extensions provide each file with CREATOR, TYPE and certain Finder Flags when accessed from a Macintosh. See the HFS MACINTOSH FILE FORMATS section below.
>
mkisofs takes a snapshot of a given directory tree, and generates a binary image which will correspond to an ISO9660 or HFS filesystem when written to a block device.
>
Each file written to the iso9660 filesystem must have a filename in the 8.3 format (8 characters, period, 3 characters, all upper case), even if Rock Ridge is in use. This filename is used on systems that are not able to make use of the Rock Ridge extensions (such as MS-DOS), and each filename in each directory must be different from the other filenames in the same directory. mkisofs generally tries to form correct names by forcing the unix filename to upper case and truncating as required, but often times this yields unsatisfactory results when there are cases where the truncated names are not all unique. mkisofs assigns weightings to each filename, and if two names that are otherwise the same are found the name with the lower priority is renamed to have a 3 digit number as an extension (where the number is guaranteed to be unique). An example of this would be the files foo.bar and foo.bar.~1~ - the file foo.bar.~1~ would be written as FOO000.BAR;1 and the file foo.bar would be written as FOO.BAR;1
>
When used with various HFS options, mkisofs will attempt to recognise files stored in a number of Apple/Unix file formats and will copy the data and resource forks as well as any relevant finder information. See the HFS MACINTOSH FILE FORMATS section below for more about formats mkisofs supports.
>
Note that mkisofs is not designed to communicate with the writer directly. Most writers have proprietary command sets which vary from one manufacturer to another, and you need a specialized tool to actually burn the disk.
>
The cdrecord utility is a utility capable of burning an actual disc. The latest version of cdrecord is available from ftp://ftp.berlios.de/pub/cdrecord
>
Also you should know that most cd writers are very particular about timing. Once you start to burn a disc, you cannot let their buffer empty before you are done, or you will end up with a corrupt disc. Thus it is critical that you be able to maintain an uninterrupted data stream to the writer for the entire time that the disc is being written.
>
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.
>
If the option -graft-points has been specified, it is possible to graft the paths at points other than the root directory, and it is possible to graft files or directories onto the cdrom image with names different than what they have in the source filesystem. This is easiest to illustrate with a couple of examples. Let's start by assuming that a local file ../old.lis exists, and you wish to include it in the cdrom image.
>
foo/bar/=../old.lis
>
will include the file old.lis in the cdrom image at /foo/bar/old.lis, while
>
foo/bar/xxx=../old.lis
>
will include the file old.lis in the cdrom image at /foo/bar/xxx. The same sort of syntax can be used with directories as well. mkisofs will create any directories required such that the graft points exist on the cdrom image - the directories do not need to appear in one of the paths. By default, any directories that are created on the fly like this will have permissions 0555 and appear to be owned by the person running mkisofs. If you wish other permissions or owners of the intermediate directories, see -uid, -gid, -dir-mode, -file-mode and -new-dir-mode.
>
mkisofs will also run on Win9X/NT4 machines when compiled with Cygnus' cygwin (available from http://sourceware.cygnus.com/cygwin/). Therefore most references in this man page to Unix can be replaced with Win32.