Lubuntu代替ISOスタンドアロンインストーラーにパッケージを追加する

はじめに



preseedを使用してLubuntu 14.04の自動インストール用のスタンドアロンインストールメディアを作成する際、元の代替ディストリビューションにないパッケージをインストールメディアに追加する必要があるという事実に直面しました。 独自のスタンドアロンディストリビューションを作成するためにさまざまな方法を試しましたが、次のようになりました。





その結果、彼はUbuntuコミュニティで説明されている方法に落ち着きました。



私がやったことについて話したい。



準備する



ディストリビューションを補完するには、パッケージを追加する元の代替ディストリビューションが必要です。 UbuntuまたはLubuntuを実行しているコンピューターで、これを実行します。



ディレクトリ構造の作成とファイルのコピー



このディストリビューションで作業するディレクトリを作成します。



mkdir -p /opt/cd-image
      
      





配布キットをダウンロードします。



 wget http://cdimages.ubuntu.com/lubuntu/releases/trusty/release/lubuntu-14.04.1-alternate-i386.iso
      
      





ダウンロードしたiso-imageを解凍します。



 mkdir /mnt/iso mount -o loop lubuntu-14.04.1-alternate-i386.iso /mnt/iso cp -rT /mnt/iso /opt/cd-image umount /mnt/iso
      
      





ディストリビューションに追加するパッケージのディレクトリを作成します。



 mkdir -p /opt/cd-image/pool/extras
      
      





ディレクトリ構造全体
 tree -d -L 3 /opt /opt ├── apt-ftparchive ├── build │ └── ubuntu-keyring-2012.05.19 │ ├── debian │ └── keyrings ├── cd-image │ ├── boot │ │ └── grub │ ├── dists │ │ └── trusty │ ├── doc │ │ └── install │ ├── install │ │ └── netboot │ ├── isolinux │ ├── pics │ ├── pool │ │ ├── extras │ │ ├── main │ │ └── universe │ └── preseed └── indices
      
      





暗号化キーの準備



公開鍵と秘密鍵のペアがない場合は、 gpgを使用して作成する必要があります。 キーは、「XXX Signing Key」という形式のコメントに設定することが好ましい。



gpg --gen-key
 gpg --gen-key gpg (GnuPG) 1.4.16; Copyright (C) 2013 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? 1 RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) Requested keysize is 2048 bits Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) y You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>" Real name: Alexandr Petrenko Email address: *********@gmail.com Comment: My Signing Key You selected this USER-ID: "Alexandr Petrenko (My Signing Key) <*********@gmail.com>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o You need a Passphrase to protect your secret key.
      
      







秘密鍵を使用してリポジトリのリリースファイルに署名します次の手順では、fakerootパッケージが必要です。システムにない場合はインストールします。



ここで、キーをubuntu-keyringパッケージに追加する必要があります
 mkdir /opt/build cd /opt/build #       apt-get source ubuntu-keyring #     cd ubuntu-keyring-2012.05.19/keyrings/ gpg --import < ubuntu-archive-keyring.gpg #   ,  "Signing Key"  ,  gpg --list-keys "Signing Key" pub 1024D/437D05B5 2004-09-12 uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com> sub 2048g/79164387 2004-09-12 pub 1024D/FBB75451 2004-12-30 uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com> pub 2048R/YOURKEYID 2015-01-28 uid My Signing Key <*********@gmail.com> sub 2048R/KEYID 2015-01-28 #      gpg --export FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg #       ubuntu-keyring-2012.05.19       cd .. dpkg-buildpackage -rfakeroot -m"  <your.email@your.host>" -kYOURKEYID #         cd .. cp ubuntu-keyring*deb /opt/cd-image/pool/main/u/ubuntu-keyring
      
      







ファイルをリポジトリにコピーする



/ opt / cd-image / pool / extrasディレクトリにいくつかのパッケージを手動で簡単に追加できます。



インストーラーカーネルモジュールを更新する必要がある場合は、次のように実行できます。



 cd /opt/cd-image/pool/main/l/linux/ wget -r -nd --no-parent --accept '*-modules-3.13.0-24*i386.udeb' ftp://security.ubuntu.com/ubuntu/pool/main/l/linux/
      
      





ここで、3.13.0-24 * i386の代わりに、ブートに使用するカーネルの目的のバージョンとモジュールのアーキテクチャを指定できます。



参照コンピューター上の現在のOSにインストールされているすべてのパッケージをダウンロードするには、これを実行できます



台本
 #!/bin/bash dpkg --get-selections | while read line do package=`expr "$line" : '\(.*\)install'` echo $package apt-get download $package done for i in *; do mv $i ${i/'1%3a'/''}; done
      
      







そして、aptキャッシュからリポジトリにダウンロードしたパッケージを追加します。



apt-ftparchiveを使用してスタンドアロンのローカルリポジトリを作成する



apt-ftparchiveユーティリティは 、apt-utilsパッケージに含まれています。

すべての設定は、Lubuntu 14.04 Trustyおよびi386アーキテクチャ用です。 ディストリビューションのバージョンまたはアーキテクチャが異なる場合は、構成ファイルとスクリプトの適切な値を調整する必要があります。



apt-ftparchiveのリポジトリの説明



/ opt / apt-ftparchiveディレクトリに次の構成ファイルを作成する必要があります。



ポケットメインおよびユニバースの設定:



apt-ftparchive-deb.conf
 Dir { ArchiveDir "/opt/cd-image/"; }; TreeDefault { Directory "pool/"; }; BinDirectory "pool/main" { Packages "dists/trusty/main/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.main"; ExtraOverride "/opt/indices/override.trusty.extra.main"; }; BinDirectory "pool/universe" { Packages "dists/trusty/universe/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.universe"; }; Default { Packages { Extensions ".deb"; Compress ". gzip"; }; }; Contents { Compress "gzip"; };
      
      







メインポケットとユニバースポケットにあるdebian-installerインストーラーモジュールの設定:
apt-ftparchive-udeb.conf
 Dir { ArchiveDir "/opt/cd-image/"; }; TreeDefault { Directory "pool/"; }; BinDirectory "pool/main" { Packages "dists/trusty/main/debian-installer/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.main.debian-installer"; }; BinDirectory "pool/universe" { Packages "dists/trusty/universe/debian-installer/binary-i386/Packages"; BinOverride "/opt/indices/override.trusty.universe.debian-installer"; }; Default { Packages { Extensions ".udeb"; Compress ". gzip"; }; }; Contents { Compress "gzip"; };
      
      







エクストラポケットの設定:
apt-ftparchive-extras.conf
 Dir { ArchiveDir "/opt/cd-image/"; }; TreeDefault { Directory "pool/"; }; BinDirectory "pool/extras" { Packages "dists/trusty/extras/binary-i386/Packages"; }; Default { Packages { Extensions ".deb"; Compress ". gzip"; }; }; Contents { Compress "gzip"; };
      
      







リポジトリリリースファイルを作成するための設定:



release.conf
 APT::FTPArchive::Release::Origin "Ubuntu"; APT::FTPArchive::Release::Label "Ubuntu"; APT::FTPArchive::Release::Suite "trusty"; APT::FTPArchive::Release::Version "14.04"; APT::FTPArchive::Release::Codename "trusty"; APT::FTPArchive::Release::Architectures "i386"; APT::FTPArchive::Release::Components "main restricted extras"; APT::FTPArchive::Release::Description "Ubuntu 14.04 LTS";
      
      







インデックスの読み込み



get-indices.bash
 #!/bin/bash cd /opt/indices/ DIST=trusty for SUFFIX in extra.main main main.debian-installer universe universe.debian-installer; do wget http://archive.ubuntu.com/ubuntu/indices/override.$DIST.$SUFFIX done
      
      







パッケージとリリースリポジトリファイルの作成



apt-ftparchiveユーティリティによるリポジトリのパッケージとリリースファイルの作成を開始し、設定を考慮に入れたスクリプト。その後、リリースファイルに署名し、ファイルのチェックサムをmd5sum.txtに書き込みます。



make-iso-repo.bash
 BUILD=/opt/cd-image APTCONF=/opt/apt-ftparchive/release.conf DISTNAME=trusty pushd $BUILD apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-deb.conf apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-udeb.conf apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-extras.conf apt-ftparchive -c $APTCONF release $BUILD/dists/$DISTNAME > $BUILD/dists/$DISTNAME/Release gpg --default-key "YOURKEYID" --output $BUILD/dists/$DISTNAME/Release.gpg -ba $BUILD/dists/$DISTNAME/Release find . -type f -print0 | xargs -0 md5sum > md5sum.txt
      
      







ISOイメージを作成して使用する



ISOイメージの作成



make-iso-image.bash
 IMAGE=custom.iso BUILD=/opt/cd-image/ mkisofs -r -V "Custom Ubuntu Install CD" \ -cache-inodes \ --iso-level 3 -J -l -b isolinux/isolinux.bin \ -c isolinux/boot.cat -no-emul-boot \ -boot-load-size 4 -boot-info-table \ -o $IMAGE $BUILD
      
      







ISOイメージからの起動



これで、作成したISOイメージを使用してブートし、イメージをCD / DVD-ROMに、またはリムーバブルメディアから書き込むことができます。



起動可能なUSBドライブの作成



起動するには、FAT32でディスクをフォーマットする必要があります。 ディスクにブートローダー、たとえばgrub2をインストールします。



 sudo grub-install --no-floppy --root-directory=/media/multiboot /dev/sdb
      
      







/ media / multibootは、起動可能なUSBドライブのマウントされたパーティションへのパスです。 / dev / sdb-ブートディスクデバイス。



その後、ブートローダーを構成します。 おおよそのgrub2設定:



/media/multiboot/boot/grub/grub.cfg
 #   set timeout=10 #     set default=0 #   insmod ext2 insmod loopback insmod iso9660 insmod fat insmod part_msdos menuentry "Boot from first hard disk" { set root=(hd1) chainloader +1 } set iso="/custom.iso" menuentry "Custom.iso" { linux /vmlinuz debconf/priority=high shared/ask_device=manual shared/enter_device=/dev/disk/by-label/DISKLABEL iso-scan/filename=$iso auto-install/enable=true debian-installer/language=ru debian-installer/locale=ru_RU.UTF-8 debian-installer/country=RU preseed/file=/cdrom/preseed/custom.seed DEBCONF_DEBUG=5 -- initrd /initrd.gz }
      
      







また、 vmlinuzとinitrdをUSBドライブのルートに追加する必要があります。



udeb.listファイルで 、カーネルに必要なモジュールのバージョンと、配布キットに配置する必要のあるモジュールを見つけることができます(上記を参照)。



作成されたディスクから起動し、OSのインストールを開始します。






All Articles