Introduction

よくあるパターンで、インターネットに繋がらないとか、環境を汚したくないとかそういうの。
インストール時に使用したDVDからパッケージをインストールするから、全く同一の環境が作れるはず、というもの。

How to?

手順は

  1. DVD をマウント
  2. DVDをリポジトリとして参照するよう設定
  3. dnf でインストール

となります。

以下、root で作業します。

1. DVD をマウント

適当なディレクトリにマウントします。
**/media** でいい気がします。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# mount /dev/cdrom /media
mount: /media: WARNING: device write-protected, mounted read-only.

# ls -la /media/
total 53
dr-xr-xr-x. 7 root root 2048 Oct 9 2020 .
dr-xr-xr-x. 17 root root 224 Apr 25 07:05 ..
dr-xr-xr-x. 4 root root 2048 Oct 9 2020 AppStream
dr-xr-xr-x. 4 root root 2048 Oct 9 2020 BaseOS
-r--r--r--. 1 root root 60 Oct 9 2020 .discinfo
dr-xr-xr-x. 3 root root 2048 Oct 9 2020 EFI
-r--r--r--. 1 root root 8266 Oct 9 2020 EULA
-r--r--r--. 1 root root 1455 Oct 9 2020 extra_files.json
-r--r--r--. 1 root root 18092 Oct 9 2020 GPL
dr-xr-xr-x. 3 root root 2048 Oct 9 2020 images
dr-xr-xr-x. 2 root root 2048 Oct 9 2020 isolinux
-r--r--r--. 1 root root 103 Oct 9 2020 media.repo
-r--r--r--. 1 root root 1669 Oct 9 2020 RPM-GPG-KEY-redhat-beta
-r--r--r--. 1 root root 5134 Oct 9 2020 RPM-GPG-KEY-redhat-release
-r--r--r--. 1 root root 1796 Oct 9 2020 TRANS.TBL
-r--r--r--. 1 root root 1560 Oct 9 2020 .treeinfo

2. DVDをリポジトリとして参照するよう設定

vi でリポジトリを追加します。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# vi /etc/yum.repos.d/InstallMedia.repo

[InstallMedia-BaseOS]
name=Red Hat Enterprise Linux 8 - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[InstallMedia-AppStream]
name=Red Hat Enterprise Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

3. dnf でインストール

まずキャッシュをクリアします。

1
2
3
4
5
6
7
# dnf clean all
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

0 files removed

続いて、好きなパッケージをインストール。
ここでは、 openjdk をインストールしてみます。
まずは、パッケージを検索。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# dnf search openjdk
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Red Hat Enterprise Linux 8 - BaseOS 68 MB/s | 2.3 MB 00:00
Red Hat Enterprise Linux 8 - AppStream 153 MB/s | 6.3 MB 00:00
Last metadata expiration check: 0:00:01 ago on Sun 25 Apr 2021 12:07:00 PM EDT.
=========================================== Name & Summary Matched: openjdk ============================================
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK 8 accessibility connector
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos 8
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 8
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in single archive
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle 8
java-11-openjdk.x86_64 : OpenJDK Runtime Environment 11
java-11-openjdk-demo.x86_64 : OpenJDK Demos 11
java-11-openjdk-devel.x86_64 : OpenJDK Development Environment 11
java-11-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in a single archive
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-11-openjdk-src.x86_64 : OpenJDK Source Bundle 11
java-11-openjdk-static-libs.x86_64 : OpenJDK libraries for static linking 11
=============================================== Summary Matched: openjdk ===============================================
icedtea-web.noarch : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation

パッケージが見つかりました。
インストールを実行します。
途中の warning がローカルのDVDマウント先である /media を指しているのが分かります。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# dnf install java-1.8.0-openjdk -y
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:01:23 ago on Sun 25 Apr 2021 12:07:45 PM EDT.
Dependencies resolved.
======================================================================================================================== Package Arch Version Repository Size
========================================================================================================================Installing:
java-1.8.0-openjdk x86_64 1:1.8.0.265.b01-4.el8 InstallMedia-AppStream 326 k
Installing dependencies:
copy-jdk-configs noarch 3.7-4.el8 InstallMedia-AppStream 27 k
java-1.8.0-openjdk-headless x86_64 1:1.8.0.265.b01-4.el8 InstallMedia-AppStream 34 M
javapackages-filesystem noarch 5.3.0-1.module+el8+2447+6f56d9a6 InstallMedia-AppStream 30 k
lksctp-tools x86_64 1.0.18-3.el8 InstallMedia-BaseOS 100 k
ttmkfdir x86_64 3.0.9-54.el8 InstallMedia-AppStream 62 k
tzdata-java noarch 2020a-1.el8 InstallMedia-AppStream 189 k
xorg-x11-fonts-Type1 noarch 7.5-19.el8 InstallMedia-AppStream 522 k
Enabling module streams:
javapackages-runtime 201801

Transaction Summary
========================================================================================================================Install 8 Packages

Total size: 35 M
Installed size: 118 M
Downloading Packages:
warning: /media/BaseOS/Packages/lksctp-tools-1.0.18-3.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Red Hat Enterprise Linux 8 - BaseOS 401 kB/s | 5.0 kB 00:00
Importing GPG key 0xFD431D51:
Userid : "Red Hat, Inc. (release key 2) <security@redhat.com>"
Fingerprint: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Key imported successfully
Importing GPG key 0xD4082792:
Userid : "Red Hat, Inc. (auxiliary key) <security@redhat.com>"
Fingerprint: 6A6A A7C9 7C88 90AE C6AE BFE2 F76F 66C3 D408 2792
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: copy-jdk-configs-3.7-4.el8.noarch 1/1
Running scriptlet: java-1.8.0-openjdk-headless-1:1.8.0.265.b01-4.el8.x86_64 1/1
Preparing : 1/1
Installing : tzdata-java-2020a-1.el8.noarch 1/8
Installing : ttmkfdir-3.0.9-54.el8.x86_64 2/8
Installing : xorg-x11-fonts-Type1-7.5-19.el8.noarch 3/8
Running scriptlet: xorg-x11-fonts-Type1-7.5-19.el8.noarch 3/8
Installing : javapackages-filesystem-5.3.0-1.module+el8+2447+6f56d9a6.noarch 4/8
Installing : copy-jdk-configs-3.7-4.el8.noarch 5/8
Installing : lksctp-tools-1.0.18-3.el8.x86_64 6/8
Running scriptlet: lksctp-tools-1.0.18-3.el8.x86_64 6/8
Installing : java-1.8.0-openjdk-headless-1:1.8.0.265.b01-4.el8.x86_64 7/8
Running scriptlet: java-1.8.0-openjdk-headless-1:1.8.0.265.b01-4.el8.x86_64 7/8
Installing : java-1.8.0-openjdk-1:1.8.0.265.b01-4.el8.x86_64 8/8
Running scriptlet: java-1.8.0-openjdk-1:1.8.0.265.b01-4.el8.x86_64 8/8
Running scriptlet: copy-jdk-configs-3.7-4.el8.noarch 8/8
Running scriptlet: java-1.8.0-openjdk-1:1.8.0.265.b01-4.el8.x86_64 8/8
Verifying : lksctp-tools-1.0.18-3.el8.x86_64 1/8
Verifying : copy-jdk-configs-3.7-4.el8.noarch 2/8
Verifying : java-1.8.0-openjdk-1:1.8.0.265.b01-4.el8.x86_64 3/8
Verifying : java-1.8.0-openjdk-headless-1:1.8.0.265.b01-4.el8.x86_64 4/8
Verifying : javapackages-filesystem-5.3.0-1.module+el8+2447+6f56d9a6.noarch 5/8
Verifying : ttmkfdir-3.0.9-54.el8.x86_64 6/8
Verifying : tzdata-java-2020a-1.el8.noarch 7/8
Verifying : xorg-x11-fonts-Type1-7.5-19.el8.noarch 8/8
Installed products updated.

Installed:
copy-jdk-configs-3.7-4.el8.noarch java-1.8.0-openjdk-1:1.8.0.265.b01-4.el8.x86_64 java-1.8.0-openjdk-headless-1:1.8.0.265.b01-4.el8.x86_64 javapackages-filesystem-5.3.0-1.module+el8+2447+6f56d9a6.noarch
lksctp-tools-1.0.18-3.el8.x86_64 ttmkfdir-3.0.9-54.el8.x86_64 tzdata-java-2020a-1.el8.noarch xorg-x11-fonts-Type1-7.5-19.el8.noarch

Complete!