JAVA Runtime Environment (JRE) 是經常使用的工具,但是受限於版權的因素,Debian Linux 並沒有把 Oracle 的 Java Runtime Environment 包進來,而 JRE 又經常因為安全性的因素更新。在這種情況下,我們只能手動更新 JRE,否則將會有漏洞而導致系統安全發生。底下將介紹如何安裝 JRE。
1. 下載
請至 Oracle 官方網站下載 JRE,其網址如下:
http://java.com/zh_TW/download/
依本文章為例,我們所下載的 JRE 是 jre-7u60-linux-x64.tar.gz。
2. 解壓縮
我們將 JRE 解壓縮至 /usr/local/java 目錄下,請以 root 權限先建立 /usr/local/java 目錄,指令如下:
#mkdir -p /usr/local/java
接著再將 jre-7u60-linux-x64.tar.gz 解壓縮至 /usr/local/java 目錄,指令如下:
#tar xfva jre-7u60-linux-x64.tar.gz -C /usr/local/java
此時會出現一個目錄,其完整路徑為 /usr/local/java/jre1.7.0_60。
接著請建立一個 /usr/local/java/cur 連結至 /usr/local/java/jre1.7.0_60 目錄:
ln -s /usr/local/java/jre1.7.0_60 /usr/local/java/cur
3. 安裝
請以 root 權限執行底下指令:
#update-alternatives --install /usr/bin/java java /usr/local/java/cur/bin/java 1
#update-alternatives --set java /usr/local/java/cur/bin/java
4. 設定環境
請在 ~/.bashrc 目錄下加入底下幾行:
JAVA="/usr/local/java"
JAVAbin="/usr/local/java/cur/bin"
CLASSPATH="/usr/share/java"
export JAVA_HOME="/usr/local/java/cur"
export PATH=$PATH:$JAVAbin
5. 安裝 firefox plugin
在安裝 firefox plugin 前,必須先關閉 firefox,接著以一般使用者權限至 ~/.mozilla/plugins 目錄下執行底下指令:
~/.mozilla/plugins $ ln -sf /usr/local/java/cur/lib/amd64/libnpjp2.so .
6. 測試 JRE 是否安裝成功 ?
以 firefox 連線至官方網頁測試即可,網址在:
https://www.java.com/en/download/installed.jsp
2014年6月24日 星期二
2014年6月19日 星期四
進階 Linux 作業系統期末上機考
1. 建立一個 deb_mirror.img,其大小為 4GB,此檔案必須可以支援中文 Debian 以及英文 Debian 之安裝。
2. 在 linux.img 中設定編譯 linaro qemu 環境,設定指令如下:
./configure --enable-tcg-interpreter --enable-gcov --enable-tpm
要設定到如底下所示
pixman system
SDL support yes
GTK support yes
curses support yes
curl support yes
mingw32 support no
Audio drivers oss
Block whitelist (rw)
Block whitelist (ro)
VirtFS support yes
VNC support yes
VNC TLS support yes
VNC SASL support yes
VNC JPEG support yes
VNC PNG support yes
VNC WS support yes
xen support no
brlapi support no
bluez support yes
Documentation yes
GUEST_BASE yes
PIE yes
vde support yes
Linux AIO support yes
ATTR/XATTR support yes
Install blobs yes
KVM support yes
RDMA support yes
TCG interpreter yes
fdt support yes
preadv support yes
fdatasync yes
madvise yes
posix_madvise yes
sigev_thread_id yes
uuid support yes
libcap-ng support yes
vhost-net support yes
vhost-scsi support yes
Trace backend nop
Trace output file trace-<pid>
spice support yes (0.12.6/0.12.4)
rbd support yes
xfsctl support yes
nss used yes
libusb yes
usb net redir yes
GLX support yes
libiscsi support yes
build guest agent yes
QGA VSS support no
seccomp support yes
coroutine backend ucontext
coroutine pool yes
GlusterFS support no
virtio-blk-data-plane yes
gcov gcov
gcov enabled yes
TPM support yes
libssh2 support yes
TPM passthrough yes
QOM debugging yes
vhdx yes
2. 在 linux.img 中設定編譯 linaro qemu 環境,設定指令如下:
./configure --enable-tcg-interpreter --enable-gcov --enable-tpm
要設定到如底下所示
pixman system
SDL support yes
GTK support yes
curses support yes
curl support yes
mingw32 support no
Audio drivers oss
Block whitelist (rw)
Block whitelist (ro)
VirtFS support yes
VNC support yes
VNC TLS support yes
VNC SASL support yes
VNC JPEG support yes
VNC PNG support yes
VNC WS support yes
xen support no
brlapi support no
bluez support yes
Documentation yes
GUEST_BASE yes
PIE yes
vde support yes
Linux AIO support yes
ATTR/XATTR support yes
Install blobs yes
KVM support yes
RDMA support yes
TCG interpreter yes
fdt support yes
preadv support yes
fdatasync yes
madvise yes
posix_madvise yes
sigev_thread_id yes
uuid support yes
libcap-ng support yes
vhost-net support yes
vhost-scsi support yes
Trace backend nop
Trace output file trace-<pid>
spice support yes (0.12.6/0.12.4)
rbd support yes
xfsctl support yes
nss used yes
libusb yes
usb net redir yes
GLX support yes
libiscsi support yes
build guest agent yes
QGA VSS support no
seccomp support yes
coroutine backend ucontext
coroutine pool yes
GlusterFS support no
virtio-blk-data-plane yes
gcov gcov
gcov enabled yes
TPM support yes
libssh2 support yes
TPM passthrough yes
QOM debugging yes
vhdx yes
2014年6月18日 星期三
自行編譯「完整版 Linaro Qemu」
Linaro Qemu 是 Linaro 基金會所支援的 Qemu,它較官方的 Qemu 支援更多 ARM 硬體,因此十分適合用在嵌入式系統開發上面。qemu linaro 有一項特異功能是使用 usb redir net 以使用網路傳遞 usb 通訊協定, 但是 debian wheezy 的函式庫過於老舊以致於無法將 qemu linaro 的這項功能啟動,在此介紹如何自行外加新版的函式庫以啟動此功能。
假設在 qemu linaro 目錄下執行 ./configure 出現:
ERROR: pixman not present. Your options:
(1) Preferred: Install the pixman devel package (any recent
distro should have packages as Xorg needs pixman too).
(2) Fetch the pixman submodule, using:
git submodule update --init pixman
其解決方式如下:
apt-get install libpixman-1-dev
若是 ./configure 出現問題:
ERROR: DTC not present. Your options:
(1) Preferred: Install the DTC devel package
(2) Fetch the DTC submodule, using:
git submodule update --init dtc
其解決方式為:
apt-get install libfdt-dev
之後有可能出現的錯誤訊息是:
GTK support no
的訊息,我們可以檢視 configure 檔案,裡面有底下段落:
##########################################
# GTK probe
if test "$gtk" != "no"; then
gtkpackage="gtk+-$gtkabi"
if test "$gtkabi" = "3.0" ; then
gtkversion="3.0.0"
vtepackage="vte-2.90"
vteversion="0.32.0"
else
gtkversion="2.18.0"
vtepackage="vte"
vteversion="0.24.0"
.. (中略)
elif ! $pkg_config --exists "$vtepackage >= $vteversion"; then
if test "$gtk" = "yes" ; then
error_exit "libvte not found (required for gtk support)"
.. (下略)
我們可以看到上面有一行:
error_exit "libvte not found (required for gtk support)"
此訊息表示 libvte-dev 之類名稱的套件沒有安裝,我們可以利用 aptitude 安裝 libvte-dev 套件,再執行 ./configure 看看。
seccomp support no
這表示我們沒有安裝 libseccomp-dev 套件,但是此套件目前在 Wheezy 底下並沒有出現,必須設定 Debian backports 才可以安裝,設定方式請在 /etc/apt/sources.list 中加入底下內容:
#Wheezy Backports
deb http://ftp.tw.debian.org/debian wheezy-backports main
接著執行 apt-get update; apt-get install libseccomp-dev 即可安裝。安裝完畢後我們再執行
./configure
其狀態如下:
seccomp support yes
1. 下載必要函式庫
apt-get install
libnss3-dev
libudev-dev
libpng12-dev
libghc6-zlib-dev
libogg-dev
libglobus-openssl-dev
libxrandr-dev
libxfixes-dev
libjpeg8-dev
libsasl2-dev
libiscsi-dev
librbd-dev
xfslibs-dev
libbrlapi-dev
libbluetooth-dev
libxen-dev
spice - http://spice-space.org/download.html
http://www.spice-space.org/download/releases/spice-0.12.5.tar.bz2
http://www.spice-space.org/download/releases/spice-protocol-0.12.7.tar.bz2
http://www.spice-space.org/download/usbredir/usbredir-0.7.tar.bz2
https://alioth.debian.org/frs/download.php/3842/pcsc-lite-1.8.7.tar.bz2
#https://alioth.debian.org/frs/download.php/3757/pcsc-lite-1.8.6.tar.bz2
http://jaist.dl.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.19/libusb-1.0.19.tar.bz2
但是在編 spice 時會說 pixman 版本太舊,因此我們還要自行安裝新版 pixman。
pixman - http://cgit.freedesktop.org/pixman/
http://cgit.freedesktop.org/pixman/snapshot/pixman-0.28.2.tar.gz
libcacard - http://spice-space.org/download/libcacard/
http://spice-space.org/download/libcacard/libcacard-0.1.2.tar.bz2
2. 安裝
pcsc-lite-1.8.7 安裝步驟:
tar xfva pcsc-lite-1.8.7.tar.bz2
cd pcsc-lite-1.8.7
./configure
make
# make install
libcacard 安裝步驟:
tar xfva libcacard-0.1.2.tar.bz2
./configure
錯誤訊息:
checking for NSS... no
configure: error: Package requirements (nss) were not met:
No package 'nss' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables NSS_CFLAGS
and NSS_LIBS to avoid the need to call pkg-config.
請安裝
libnss3-dev
即可。
make -j N
make install
libusb-1.0.18 安裝步驟:
tar xfva libusb-1.0.18.tar.bz2
cd libusb-1.0.18
./configure
make -j N
#make install
usbredir-0.7 安裝步驟:
tar xfva usbredir-0.7.tar.bz2
cd usbredir-0.7
./configure
make -j N
#make install
spice-protocol-0.12.7 安裝
tar xfva spice-protocol-0.12.7.tar.bz2
cd spice-protocol-0.12.7
./configure
make -j N
#make install
#cp /usr/local/share/pkgconfig/spice-protocol.pc /usr/lib/pkgconfig/
pixman 安裝步驟:
tar xfva pixman-0.28.2.tar.gz
cd pixman-0.28.2
./autogen
./configure
make -j N
# make install
celt 安裝步驟:
請注意 SPICE 只接受 CELT 0.51 版,因此不要安裝比此新的版本:
wget http://downloads.us.xiph.org/releases/celt/celt-0.5.1.3.tar.gz
tar xfv celt-0.5.1.3.tar.gz
cd celt-0.5.1.3
./configure
make -j N
#make install
cd /usr/local/lib/pkgconfig
/usr/local/lib/pkgconfig# ln -s celt.pc celt051.pc
spice
spice 安裝步驟:
tar xfva spice-0.12.5.tar.bz2
cd spice-0.12.5
./configure --enable-smartcard
但是執行此指令不一定能順利執行,大多數的情況下會有錯誤,我們要一一處理,例如:
錯誤訊息:
checking for CELT051... no
configure: error: Package requirements (celt051 >= 0.5.1.1) were not met:
No package 'celt051' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables CELT051_CFLAGS
and CELT051_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
如果遇上以上錯誤訊息的話請先安裝先前所提到的 celt 0.51 套件:
錯誤訊息:
checking for pyparsing python module... not found
configure: error: pyparsing python module is required to compile this package
請安裝底下套件:
python-pyparsing
即可。
錯誤訊息:
checking sasl/sasl.h usability... no
checking sasl/sasl.h presence... no
checking for sasl/sasl.h... no
checking for sasl_client_init in -lsasl2... no
checking for sasl_client_init in -lsasl... no
configure: error: Missing required Cyrus SASL development package
請安裝底下套件:
libsasl2-dev
即可
錯誤訊息:
checking for SMARTCARD... no
configure: error: Package requirements (libcacard >= 0.1.2) were not met:
No package 'libcacard' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SMARTCARD_CFLAGS
and SMARTCARD_LIBS to avoid the need to call pkg-config.
請依先前步驟安裝 libcacard 0.1.2 即可。
qemu
tar xfva qemu-linaro-1.7.0-2014.01.tar.gz
cd qemu-linaro-1.7.0-2014.01
./configure
time make -j 4
su
# make install
安裝完畢後可以執行底下指令來看看 qemu-linaro 版是否能正確執行:
qemu-system-arm -version
如果出現底下錯誤訊息的話,表示動態連結函式庫沒設定好:
qemu-system-arm: error while loading shared libraries: libspice-server.so.1: cannot open shared object file: No such file or directory
請以 root 權限執行:
# ldconfig
再回到一般使用者權限即可執行:
$ qemu-system-arm -version
QEMU emulator version 1.7.0 (qemu-linaro 2014.01), Copyright (c) 2003-2008 Fabrice Bellard
假設在 qemu linaro 目錄下執行 ./configure 出現:
ERROR: pixman not present. Your options:
(1) Preferred: Install the pixman devel package (any recent
distro should have packages as Xorg needs pixman too).
(2) Fetch the pixman submodule, using:
git submodule update --init pixman
其解決方式如下:
apt-get install libpixman-1-dev
若是 ./configure 出現問題:
ERROR: DTC not present. Your options:
(1) Preferred: Install the DTC devel package
(2) Fetch the DTC submodule, using:
git submodule update --init dtc
其解決方式為:
apt-get install libfdt-dev
之後有可能出現的錯誤訊息是:
GTK support no
的訊息,我們可以檢視 configure 檔案,裡面有底下段落:
##########################################
# GTK probe
if test "$gtk" != "no"; then
gtkpackage="gtk+-$gtkabi"
if test "$gtkabi" = "3.0" ; then
gtkversion="3.0.0"
vtepackage="vte-2.90"
vteversion="0.32.0"
else
gtkversion="2.18.0"
vtepackage="vte"
vteversion="0.24.0"
.. (中略)
elif ! $pkg_config --exists "$vtepackage >= $vteversion"; then
if test "$gtk" = "yes" ; then
error_exit "libvte not found (required for gtk support)"
.. (下略)
我們可以看到上面有一行:
error_exit "libvte not found (required for gtk support)"
此訊息表示 libvte-dev 之類名稱的套件沒有安裝,我們可以利用 aptitude 安裝 libvte-dev 套件,再執行 ./configure 看看。
seccomp support no
這表示我們沒有安裝 libseccomp-dev 套件,但是此套件目前在 Wheezy 底下並沒有出現,必須設定 Debian backports 才可以安裝,設定方式請在 /etc/apt/sources.list 中加入底下內容:
#Wheezy Backports
deb http://ftp.tw.debian.org/debian wheezy-backports main
接著執行 apt-get update; apt-get install libseccomp-dev 即可安裝。安裝完畢後我們再執行
./configure
其狀態如下:
seccomp support yes
1. 下載必要函式庫
apt-get install
libnss3-dev
libudev-dev
libpng12-dev
libghc6-zlib-dev
libogg-dev
libglobus-openssl-dev
libxrandr-dev
libxfixes-dev
libjpeg8-dev
libsasl2-dev
libiscsi-dev
librbd-dev
xfslibs-dev
libbrlapi-dev
libbluetooth-dev
libxen-dev
spice - http://spice-space.org/download.html
http://www.spice-space.org/download/releases/spice-0.12.5.tar.bz2
http://www.spice-space.org/download/releases/spice-protocol-0.12.7.tar.bz2
http://www.spice-space.org/download/usbredir/usbredir-0.7.tar.bz2
https://alioth.debian.org/frs/download.php/3842/pcsc-lite-1.8.7.tar.bz2
#https://alioth.debian.org/frs/download.php/3757/pcsc-lite-1.8.6.tar.bz2
http://jaist.dl.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.19/libusb-1.0.19.tar.bz2
但是在編 spice 時會說 pixman 版本太舊,因此我們還要自行安裝新版 pixman。
pixman - http://cgit.freedesktop.org/pixman/
http://cgit.freedesktop.org/pixman/snapshot/pixman-0.28.2.tar.gz
libcacard - http://spice-space.org/download/libcacard/
http://spice-space.org/download/libcacard/libcacard-0.1.2.tar.bz2
2. 安裝
pcsc-lite-1.8.7 安裝步驟:
tar xfva pcsc-lite-1.8.7.tar.bz2
cd pcsc-lite-1.8.7
./configure
make
# make install
libcacard 安裝步驟:
tar xfva libcacard-0.1.2.tar.bz2
./configure
錯誤訊息:
checking for NSS... no
configure: error: Package requirements (nss) were not met:
No package 'nss' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables NSS_CFLAGS
and NSS_LIBS to avoid the need to call pkg-config.
請安裝
libnss3-dev
即可。
make -j N
make install
libusb-1.0.18 安裝步驟:
tar xfva libusb-1.0.18.tar.bz2
cd libusb-1.0.18
./configure
make -j N
#make install
usbredir-0.7 安裝步驟:
tar xfva usbredir-0.7.tar.bz2
cd usbredir-0.7
./configure
make -j N
#make install
spice-protocol-0.12.7 安裝
tar xfva spice-protocol-0.12.7.tar.bz2
cd spice-protocol-0.12.7
./configure
make -j N
#make install
#cp /usr/local/share/pkgconfig/spice-protocol.pc /usr/lib/pkgconfig/
pixman 安裝步驟:
tar xfva pixman-0.28.2.tar.gz
cd pixman-0.28.2
./autogen
./configure
make -j N
# make install
celt 安裝步驟:
請注意 SPICE 只接受 CELT 0.51 版,因此不要安裝比此新的版本:
wget http://downloads.us.xiph.org/releases/celt/celt-0.5.1.3.tar.gz
tar xfv celt-0.5.1.3.tar.gz
cd celt-0.5.1.3
./configure
make -j N
#make install
cd /usr/local/lib/pkgconfig
/usr/local/lib/pkgconfig# ln -s celt.pc celt051.pc
spice
spice 安裝步驟:
tar xfva spice-0.12.5.tar.bz2
cd spice-0.12.5
./configure --enable-smartcard
但是執行此指令不一定能順利執行,大多數的情況下會有錯誤,我們要一一處理,例如:
錯誤訊息:
checking for CELT051... no
configure: error: Package requirements (celt051 >= 0.5.1.1) were not met:
No package 'celt051' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables CELT051_CFLAGS
and CELT051_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
如果遇上以上錯誤訊息的話請先安裝先前所提到的 celt 0.51 套件:
錯誤訊息:
checking for pyparsing python module... not found
configure: error: pyparsing python module is required to compile this package
請安裝底下套件:
python-pyparsing
即可。
錯誤訊息:
checking sasl/sasl.h usability... no
checking sasl/sasl.h presence... no
checking for sasl/sasl.h... no
checking for sasl_client_init in -lsasl2... no
checking for sasl_client_init in -lsasl... no
configure: error: Missing required Cyrus SASL development package
請安裝底下套件:
libsasl2-dev
即可
錯誤訊息:
checking for SMARTCARD... no
configure: error: Package requirements (libcacard >= 0.1.2) were not met:
No package 'libcacard' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SMARTCARD_CFLAGS
and SMARTCARD_LIBS to avoid the need to call pkg-config.
請依先前步驟安裝 libcacard 0.1.2 即可。
qemu
tar xfva qemu-linaro-1.7.0-2014.01.tar.gz
cd qemu-linaro-1.7.0-2014.01
./configure
time make -j 4
su
# make install
安裝完畢後可以執行底下指令來看看 qemu-linaro 版是否能正確執行:
qemu-system-arm -version
如果出現底下錯誤訊息的話,表示動態連結函式庫沒設定好:
qemu-system-arm: error while loading shared libraries: libspice-server.so.1: cannot open shared object file: No such file or directory
請以 root 權限執行:
# ldconfig
再回到一般使用者權限即可執行:
$ qemu-system-arm -version
QEMU emulator version 1.7.0 (qemu-linaro 2014.01), Copyright (c) 2003-2008 Fabrice Bellard
2014年5月29日 星期四
將實體機的 Debian 鏡像站分享給 pxeserver
2019/10/14 修改
PXE Server 雖然有 deb_mirror.img 來作為網路安裝下載之檔案儲存空間,但畢竟不是一個完整的 Debian 鏡像站,為了解決這個問題,讓 PXE Server 能成為虛擬教室真正的 Debian 鏡像站,我們要將實體機的 /home/ftp/debian 及 /home/ftp/emdebian 目錄以 NFS 方式分享給 PXE Server,而 PXE Server 可以掛載此兩個目錄,並成為虛擬教室中真正的鏡像站主機。
作法:
1. 本機(實體機器)端開啟 NFS 服務
首先請以 root 權限安裝 nfs-kernel-server 套件,接著修改
/etc/exports 檔案,加上二行:
/home/ftp/debian 192.168.10.254(ro,sync,no_subtree_check)
/home/ftp/emdebian 192.168.10.254(ro,sync,no_subtree_check)
作完後執行
/etc/init.d/nfs-kernel-server restart
然後執行 showmount -e localhost 來觀看輸出,如底下所示:
root@aspire:~# showmount -e localhost
Export list for localhost:
/home/ftp/emdebian 192.168.10.254
/home/ftp/debian 192.168.10.254
2. PXE Server 掛載 NFS 目錄
2.1 確認有看到實體機分享出來的鏡像站目錄
showmount -e 192.168.10.1
^^^^^^^^^^^^ -> 此 IP 為 PXE Server 所看到實體主機之 IP
看到輸出如下所示:
Export list for 192.168.10.1:
/home/ftp/emdebian 192.168.10.254
/home/ftp/debian 192.168.10.254
2.2 建置 ftp 伺服器
2.3 在 pxe 伺服器底下輸入:
# showmount -e 192.168.10.1
Export list for 192.168.10.1:
/srv/ftp 192.168.10.0/24
接著手動掛載試試看:
# mkdir -p /home/ftp/debian
# mount -t nfs 192.168.10.1:/home/ftp/debian /home/ftp/debian
看看能不能把遠端的 ftp 站掛在 pxe 伺服器的 /home/ftp 目錄。確定可以的話我們把設定寫入
/etc/fstab
接著請修改 /etc/passwd 檔案,將
ftp:x:107:65534::/srv/ftp:/usr/sbin/nologin
改成
ftp:x:107:65534::/home/ftp:/usr/sbin/nologin
然後用瀏覽器開 ftp://192.168.10.254,看看能不能看到 debian 目錄。
# vi /etc/fstab
新增一行:
192.168.10.1:/home/ftp/debian /home/ftp/debian nfs defaults 0 0
然後可以執行:
# mount -a
來確認掛載沒有問題。
3. 測試虛擬機之鏡像站設定
請在實體機上修改 /etc/apt/sources.list 檔,將其中的鏡像站設定改為:
deb ftp://192.168.10.254/debian/ stretch main contrib non-free
然後再執行
# apt-get update
看看能不能自 ftp://192.168.10.254 下載資料。
請參考網頁
PXE Server 雖然有 deb_mirror.img 來作為網路安裝下載之檔案儲存空間,但畢竟不是一個完整的 Debian 鏡像站,為了解決這個問題,讓 PXE Server 能成為虛擬教室真正的 Debian 鏡像站,我們要將實體機的 /home/ftp/debian 及 /home/ftp/emdebian 目錄以 NFS 方式分享給 PXE Server,而 PXE Server 可以掛載此兩個目錄,並成為虛擬教室中真正的鏡像站主機。
作法:
1. 本機(實體機器)端開啟 NFS 服務
首先請以 root 權限安裝 nfs-kernel-server 套件,接著修改
/etc/exports 檔案,加上二行:
/home/ftp/debian 192.168.10.254(ro,sync,no_subtree_check)
/home/ftp/emdebian 192.168.10.254(ro,sync,no_subtree_check)
作完後執行
/etc/init.d/nfs-kernel-server restart
然後執行 showmount -e localhost 來觀看輸出,如底下所示:
root@aspire:~# showmount -e localhost
Export list for localhost:
/home/ftp/emdebian 192.168.10.254
/home/ftp/debian 192.168.10.254
2. PXE Server 掛載 NFS 目錄
2.1 確認有看到實體機分享出來的鏡像站目錄
showmount -e 192.168.10.1
^^^^^^^^^^^^ -> 此 IP 為 PXE Server 所看到實體主機之 IP
看到輸出如下所示:
Export list for 192.168.10.1:
/home/ftp/emdebian 192.168.10.254
/home/ftp/debian 192.168.10.254
2.2 建置 ftp 伺服器
2.3 在 pxe 伺服器底下輸入:
# showmount -e 192.168.10.1
Export list for 192.168.10.1:
/srv/ftp 192.168.10.0/24
接著手動掛載試試看:
# mkdir -p /home/ftp/debian
# mount -t nfs 192.168.10.1:/home/ftp/debian /home/ftp/debian
看看能不能把遠端的 ftp 站掛在 pxe 伺服器的 /home/ftp 目錄。確定可以的話我們把設定寫入
/etc/fstab
接著請修改 /etc/passwd 檔案,將
ftp:x:107:65534::/srv/ftp:/usr/sbin/nologin
改成
ftp:x:107:65534::/home/ftp:/usr/sbin/nologin
然後用瀏覽器開 ftp://192.168.10.254,看看能不能看到 debian 目錄。
# vi /etc/fstab
新增一行:
192.168.10.1:/home/ftp/debian /home/ftp/debian nfs defaults 0 0
然後可以執行:
# mount -a
來確認掛載沒有問題。
3. 測試虛擬機之鏡像站設定
請在實體機上修改 /etc/apt/sources.list 檔,將其中的鏡像站設定改為:
deb ftp://192.168.10.254/debian/ stretch main contrib non-free
然後再執行
# apt-get update
看看能不能自 ftp://192.168.10.254 下載資料。
請參考網頁
備份 Embedebian 鏡像站
目的:備份 Embedebian 鏡像站
Embedebian 是提供 Debain 的嵌入式版本套件,特別是 ARM 的 Cross Compile 環境,在建置嵌入式系統開發時需要 Embedebian 所提供的套件才能編譯原始碼 (如 Linux 核心、bootloader) 或是進行其它工作。
一般來說我們都是直接自 Embedebian 網站上下載套件,其方式是先在 /etc/apt/sources.list 設定底下這兩行:
deb http://ftp.tw.debian.org/debian/ squeeze main
deb http://www.emdebian.org/debian/ squeeze main
加完之後執行
apt-get update
更新套件狀態,
然後先安裝 emdebian-archive-keyring 套件以免出現套件驗證錯誤,再安裝底下套件:
g++-4.4-arm-linux-gnueabi
cpp-4.4-arm-linux-gnueabi
gcc-4.4-arm-linux-gnueabi
接下來可以試著編譯 arm 底下的程式。請先建一個 hello.c 之檔案,內容如下:
#include <stdio.h>
void main(void)
{
printf("Hello World\n");
}
然後使用 gcc 來編譯:
gcc hello.c -o hello
接著可以用 file 來觀看其屬性:
file hello
我們可以看到此檔為 x86-64 之可執行檔,如底下所示:
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xe899e4c904b6efa70bd90c9a293d37109e111e59, not stripped
接下來可以使用 arm-linux-gnueabi-gcc-4.4 來編譯此檔使其成為 ARM 之可執行檔,這個過程也就是所謂的 Cross Compile
arm-linux-gnueabi-gcc-4.4 hello.c -o hello_arm
然後使用 file 來觀看其輸出:
file hello_arm
如底下所示,是 ARM 平台的可執行檔:
hello_arm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x1c0380de88d986d10d6fb8ef5fa9492f4bd410dd, not stripped
----------------------------------------------------------------------
請執行 getemdebian.sh 來下載 www.emdebian.org/debian 目錄,其內容如下:
debmirror \
--arch=armel,i386,amd64 \
--dist=squeeze,wheezy \
--host=www.emdebian.org \
--root="debian" \
--diff=none -p \
--nosource \
--method=http \
--section main,contrib,non-free,main/debian-installer,main/installer-armel,main/i18n,main/source \
--ignore-release-gpg /home/ftp/emdebian/ ;
date
建立好 emdebian 鏡像之後,我們可以把 /etc/apt/sources.list 改成:
deb http://ftp.tw.debian.org/debian/ squeeze main
#deb http://www.emdebian.org/debian/ squeeze main
deb ftp://localhost/emdebian/ squeeze main
完成此流程後,我們就可以把 ARM cross compiler 放在自建鏡像站的 emdebian 目錄下,「理論上」無需再透過網路上網下載檔案,但是記得隨時更新套件狀態,以免有漏洞未更新造成系統安全問題。
Embedebian 是提供 Debain 的嵌入式版本套件,特別是 ARM 的 Cross Compile 環境,在建置嵌入式系統開發時需要 Embedebian 所提供的套件才能編譯原始碼 (如 Linux 核心、bootloader) 或是進行其它工作。
一般來說我們都是直接自 Embedebian 網站上下載套件,其方式是先在 /etc/apt/sources.list 設定底下這兩行:
deb http://ftp.tw.debian.org/debian/ squeeze main
deb http://www.emdebian.org/debian/ squeeze main
加完之後執行
apt-get update
更新套件狀態,
然後先安裝 emdebian-archive-keyring 套件以免出現套件驗證錯誤,再安裝底下套件:
g++-4.4-arm-linux-gnueabi
cpp-4.4-arm-linux-gnueabi
gcc-4.4-arm-linux-gnueabi
接下來可以試著編譯 arm 底下的程式。請先建一個 hello.c 之檔案,內容如下:
#include <stdio.h>
void main(void)
{
printf("Hello World\n");
}
然後使用 gcc 來編譯:
gcc hello.c -o hello
接著可以用 file 來觀看其屬性:
file hello
我們可以看到此檔為 x86-64 之可執行檔,如底下所示:
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xe899e4c904b6efa70bd90c9a293d37109e111e59, not stripped
接下來可以使用 arm-linux-gnueabi-gcc-4.4 來編譯此檔使其成為 ARM 之可執行檔,這個過程也就是所謂的 Cross Compile
arm-linux-gnueabi-gcc-4.4 hello.c -o hello_arm
然後使用 file 來觀看其輸出:
file hello_arm
如底下所示,是 ARM 平台的可執行檔:
hello_arm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x1c0380de88d986d10d6fb8ef5fa9492f4bd410dd, not stripped
----------------------------------------------------------------------
請執行 getemdebian.sh 來下載 www.emdebian.org/debian 目錄,其內容如下:
debmirror \
--arch=armel,i386,amd64 \
--dist=squeeze,wheezy \
--host=www.emdebian.org \
--root="debian" \
--diff=none -p \
--nosource \
--method=http \
--section main,contrib,non-free,main/debian-installer,main/installer-armel,main/i18n,main/source \
--ignore-release-gpg /home/ftp/emdebian/ ;
date
建立好 emdebian 鏡像之後,我們可以把 /etc/apt/sources.list 改成:
deb http://ftp.tw.debian.org/debian/ squeeze main
#deb http://www.emdebian.org/debian/ squeeze main
deb ftp://localhost/emdebian/ squeeze main
完成此流程後,我們就可以把 ARM cross compiler 放在自建鏡像站的 emdebian 目錄下,「理論上」無需再透過網路上網下載檔案,但是記得隨時更新套件狀態,以免有漏洞未更新造成系統安全問題。
2014年5月22日 星期四
自建 Debian 鏡像站
2019/10/14 修改
目的:自建 Debian 鏡像站 (MIRROR)
在安裝 Debian Linux 的過程中,常常需要使用網路進行遠端連線來下載套件 (packages), 如果網路連線有問題的話,我們經常無法進行套件下載或更新的操作。這對執行專案是項極大的困擾,為了不讓網路干擾我們進行下載,因此必須自行建立 Debian 鏡像站。
Debian 支援相當多硬體架構,因此官方鏡像站需要相當多的容量才可以儲存所有套件,我們的計畫僅需要底下架構:
X86_64 (amd64)
i386 (i386)
EABI ARM (armel)
Hard Float ABI ARM (armhf)
ARM64 (arm64)
其它架構的檔案無需下載,以節省硬碟空間。要自建 Debian 鏡像站的流程如下:
1. 建立 ftp 伺服器
2. 下載 Debian 套件
3. 啟動服務
4. 設定 /etc/apt/sources.list
------------------------------
如果我們希望所下載的 Debian 鏡像站可以提供給 pxeserver 使用的話,還必須
利用 NFS 的方式將 Debian 鏡像站的目錄分享給 pxeserver。
=========================================
1. 建立 ftp 伺服器
請以 root 權限執行:
# apt-get install proftpd-basic
安裝完畢後,請修改 /etc/proftpd/proftpd.conf 這個檔案,將底下部份移除行首之 #
(註解),移除完之結果如底下所述:
---------
<Anonymous ~ftp>
User ftp
Group nogroup
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Cosmetic changes, all files belongs to ftp user
DirFakeUser on ftp
DirFakeGroup on ftp
RequireValidShell off
# Limit the maximum number of anonymous logins
MaxClients 70
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Directory *>
<Limit WRITE>
DenyAll
</Limit>
</Directory>
# Uncomment this if you're brave.
# <Directory incoming>
# # Umask 022 is a good standard umask to prevent new files and dirs
# # (second parm) from being group and world writable.
# Umask 022 022
# <Limit READ WRITE>
# DenyAll
# </Limit>
# <Limit STOR>
# AllowAll
# </Limit>
# </Directory>
</Anonymous>
--------
接著請修改 /etc/passwd 將 ftp 的家目錄由 /srv/ftp 改至 /home/ftp
修改完成後,請執行 proftpd-basic 服務,指令如下:
# /etc/init.d/proftpd restart
[ ok ] Stopping ftp server: proftpd.
[ ok ] Starting ftp server: proftpd.
啟動完畢後,我們可以使用 iceweasel 或是 gftp 來驗證自己的 ftp 站是否已完成架設。
=========================================
2. 下載 Debian 套件
由於 Debian 套件所佔之容量極為龐大,要下載 Debian 套件前請先確定自己的 /home/ftp 目錄是否有至少 150 GB 的容量,以免硬碟容量不足。
接下來請安裝 debmirror 套件,以便下載 Debian 鏡像站,接著請撰寫底下 script:
#HOST=ftp.tw.debian.org
HOST=debian.nctu.edu.tw
#HOST=opensource.nchc.org.tw
#HOST=ftp.twaren.net
debmirror \
--arch=i386,amd64,armel,armhf \
--dist=buster,buster-updates,buster-backports \
--di-arch=i386,amd64,armel \
--di-dist=stable \
--host=$HOST \
--root=":debian" \
--diff=none -p \
--nosource \
--method=rsync \
--section main,contrib,non-free \
--i18n \
--ignore-release-gpg /home/ftp/debian/ ;
此 script 請放在 /home/ftp 目錄下,執行:
# sh getdeb.sh
接著此 script 就會自動進行 Debian 套件下載的工作,我們也可以使用 crontab
讓此工作定期 (每日凌晨 2 點) 執行。
4. 設定 /etc/apt/sources.list
請修改 /etc/apt/sources.list
加上以下兩行:
deb file:/home/ftp/debian/ buster main contrib non-free
deb ftp://127.0.0.1/debian buster main contrib non-free
deb ftp://localhost/debian buster main contrib non-free
其中第一行是指在本機端下載套件時,可以不經由 ftp 傳輸協定,直接使用檔案複製的方式來進行套件下載。
第二行則是透過 ftp 傳輸協定,自 127.0.0.1 下載套件,請注意 lo 介面要打開,否則沒有 ftp://localhost 或 ftp://127.0.0.1。因此我們新的 /etc/apt/sources.list 可以只保留底下這幾行:
deb file:/home/ftp/debian/ buster main contrib non-free
deb ftp://127.0.0.1/debian buster main contrib non-free
#deb ftp://localhost/debian buster main contrib non-free
deb http://security.debian.org/ stable/updates main contrib
修改完畢後,可以在本機端使用
apt-get update
apt-get upgrade
apt-get install 套件
來進行安裝測試,以確認自己所架設之 Debian 鏡像站可以正常運轉。
目的:自建 Debian 鏡像站 (MIRROR)
在安裝 Debian Linux 的過程中,常常需要使用網路進行遠端連線來下載套件 (packages), 如果網路連線有問題的話,我們經常無法進行套件下載或更新的操作。這對執行專案是項極大的困擾,為了不讓網路干擾我們進行下載,因此必須自行建立 Debian 鏡像站。
Debian 支援相當多硬體架構,因此官方鏡像站需要相當多的容量才可以儲存所有套件,我們的計畫僅需要底下架構:
X86_64 (amd64)
i386 (i386)
EABI ARM (armel)
Hard Float ABI ARM (armhf)
ARM64 (arm64)
其它架構的檔案無需下載,以節省硬碟空間。要自建 Debian 鏡像站的流程如下:
1. 建立 ftp 伺服器
2. 下載 Debian 套件
3. 啟動服務
4. 設定 /etc/apt/sources.list
------------------------------
如果我們希望所下載的 Debian 鏡像站可以提供給 pxeserver 使用的話,還必須
利用 NFS 的方式將 Debian 鏡像站的目錄分享給 pxeserver。
=========================================
1. 建立 ftp 伺服器
請以 root 權限執行:
# apt-get install proftpd-basic
安裝完畢後,請修改 /etc/proftpd/proftpd.conf 這個檔案,將底下部份移除行首之 #
(註解),移除完之結果如底下所述:
---------
<Anonymous ~ftp>
User ftp
Group nogroup
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Cosmetic changes, all files belongs to ftp user
DirFakeUser on ftp
DirFakeGroup on ftp
RequireValidShell off
# Limit the maximum number of anonymous logins
MaxClients 70
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Directory *>
<Limit WRITE>
DenyAll
</Limit>
</Directory>
# Uncomment this if you're brave.
# <Directory incoming>
# # Umask 022 is a good standard umask to prevent new files and dirs
# # (second parm) from being group and world writable.
# Umask 022 022
# <Limit READ WRITE>
# DenyAll
# </Limit>
# <Limit STOR>
# AllowAll
# </Limit>
# </Directory>
</Anonymous>
--------
接著請修改 /etc/passwd 將 ftp 的家目錄由 /srv/ftp 改至 /home/ftp
修改完成後,請執行 proftpd-basic 服務,指令如下:
# /etc/init.d/proftpd restart
[ ok ] Stopping ftp server: proftpd.
[ ok ] Starting ftp server: proftpd.
啟動完畢後,我們可以使用 iceweasel 或是 gftp 來驗證自己的 ftp 站是否已完成架設。
=========================================
2. 下載 Debian 套件
由於 Debian 套件所佔之容量極為龐大,要下載 Debian 套件前請先確定自己的 /home/ftp 目錄是否有至少 150 GB 的容量,以免硬碟容量不足。
接下來請安裝 debmirror 套件,以便下載 Debian 鏡像站,接著請撰寫底下 script:
#HOST=ftp.tw.debian.org
HOST=debian.nctu.edu.tw
#HOST=opensource.nchc.org.tw
#HOST=ftp.twaren.net
debmirror \
--arch=i386,amd64,armel,armhf \
--dist=buster,buster-updates,buster-backports \
--di-arch=i386,amd64,armel \
--di-dist=stable \
--host=$HOST \
--root=":debian" \
--diff=none -p \
--nosource \
--method=rsync \
--section main,contrib,non-free \
--i18n \
--ignore-release-gpg /home/ftp/debian/ ;
此 script 請放在 /home/ftp 目錄下,執行:
# sh getdeb.sh
接著此 script 就會自動進行 Debian 套件下載的工作,我們也可以使用 crontab
讓此工作定期 (每日凌晨 2 點) 執行。
4. 設定 /etc/apt/sources.list
請修改 /etc/apt/sources.list
加上以下兩行:
deb file:/home/ftp/debian/ buster main contrib non-free
deb ftp://127.0.0.1/debian buster main contrib non-free
deb ftp://localhost/debian buster main contrib non-free
其中第一行是指在本機端下載套件時,可以不經由 ftp 傳輸協定,直接使用檔案複製的方式來進行套件下載。
第二行則是透過 ftp 傳輸協定,自 127.0.0.1 下載套件,請注意 lo 介面要打開,否則沒有 ftp://localhost 或 ftp://127.0.0.1。因此我們新的 /etc/apt/sources.list 可以只保留底下這幾行:
deb file:/home/ftp/debian/ buster main contrib non-free
deb ftp://127.0.0.1/debian buster main contrib non-free
#deb ftp://localhost/debian buster main contrib non-free
deb http://security.debian.org/ stable/updates main contrib
修改完畢後,可以在本機端使用
apt-get update
apt-get upgrade
apt-get install 套件
來進行安裝測試,以確認自己所架設之 Debian 鏡像站可以正常運轉。
2014年5月8日 星期四
建立 deb_mirror.img
目的:將 deb_mirror.img 建立成一個小型的 debian repository
思維模式:
PXE Server 負責提供一個可以讓同網域網段之電腦利用網路開機、取得 IP 以及安裝 Debian Linux 的功能,其中 deb_mirror.img 負責存放網路安裝 (net install) 時必須使用的套件 (package),也就是安裝時所必要的 .deb 檔案。因此我們建立 deb_mirror.img,將其分割、格式化,並掛載至 /mnt 目錄以利下載套件用。
建立 deb_mirror.img 流程:
a. dd if=/dev/zero of=deb_mirror.img bs=1G count=2
b. # fdisk deb_mirror.img
將其建立一個分割區。
c. 將 deb_mirror.img 格式化
# losetup /dev/loop0 deb_mirror.img
# losetup -o $[2048*512] /dev/loop1 /dev/loop0
# mkfs.ext4 /dev/loop1
d. 將 /dev/loop1 掛載至 /mnt 目錄
mount /dev/loop1 /mnt
掛載完畢後可以執行
df -h /mnt 來觀察是否有正確掛載,其輸出如下所示:
檔案系統 容量 已用 可用 已用% 掛載點
/dev/loop1 2.0G 3.0M 1.9G 1% /mnt
複製 deb_mirror.img 流程:
一開始我們的想法很單純,將 Debian 安裝光碟第一片複製到 deb_mirror.img 中「理論上」即可提供安裝流程所需要的檔案。因此我們需要將 debian 第一片安裝光碟中之檔案複製到 /mnt (目前已掛載 deb_mirror.img) 目錄下,首先要下載第一片安裝光碟,並掛載至 /cdrom 目錄,其操作如下:
1. 下載 debian 第一片安裝光碟
wget ftp://ftp.twaren.net/pub/Debian/debian-cd/current/amd64/iso-cd/debian-7.5.0-amd64-CD-1.iso
(校內請至 120.117.72.71 之 iso 目錄下載)
2. 掛載 debian-7.5.0-amd64-CD-1.iso 至 /cdrom 目錄
首先檢查是否有 /cdrom 目錄,若沒有的話請執行:
# mkdir /cdrom
建立完此目錄後將 debian-7.5.0-amd64-CD-1.iso 掛載至此目錄,指令如:
mount -o loop debian-7.5.0-amd64-CD-1.iso /cdrom
3. 檢視 /cdrom 目錄之內容:
請切換至 /crom 目錄,指令如下:
cd /cdrom
接著執行 ls -l,其輸出如下:
-r--r--r-- 1 root root 27 4月 26 21:38 autorun.inf
dr-xr-xr-x 1 root root 2048 4月 26 21:38 boot
dr-xr-xr-x 1 root root 2048 4月 26 21:38 css
lr-xr-xr-x 1 root root 1 4月 26 21:37 debian -> .
dr-xr-xr-x 1 root root 2048 4月 26 21:38 dists
dr-xr-xr-x 1 root root 4096 4月 26 21:37 doc
dr-xr-xr-x 1 root root 2048 4月 26 21:38 efi
dr-xr-xr-x 1 root root 2048 4月 26 21:38 firmware
-r--r--r-- 1 root root 159629 4月 24 15:42 g2ldr
-r--r--r-- 1 root root 8192 4月 24 15:42 g2ldr.mbr
dr-xr-xr-x 1 root root 2048 4月 26 21:37 install
dr-xr-xr-x 1 root root 2048 4月 26 21:38 install.amd
dr-xr-xr-x 1 root root 4096 4月 26 21:38 isolinux
-r--r--r-- 1 root root 212666 4月 26 21:51 md5sum.txt
dr-xr-xr-x 1 root root 2048 4月 26 21:38 pics
dr-xr-xr-x 1 root root 2048 4月 26 21:38 pool
-r--r--r-- 1 root root 9262 4月 26 21:51 README.html
-r--r--r-- 1 root root 176551 4月 11 09:52 README.mirrors.html
-r--r--r-- 1 root root 87800 4月 11 09:52 README.mirrors.txt
-r--r--r-- 1 root root 425 4月 26 21:38 README.source
-r--r--r-- 1 root root 5827 4月 26 21:51 README.txt
-r--r--r-- 1 root root 366350 4月 24 15:42 setup.exe
dr-xr-xr-x 1 root root 2048 4月 26 21:38 tools
-r--r--r-- 1 root root 256 4月 26 21:38 win32-loader.ini
/cdrom 目錄有許多目錄及檔案,我們可以執行 du -sh * 來觀看每個檔案/目錄的容量,如底下所示:
512 autorun.inf
1.9M boot
8.0K css
0 debian
3.3M dists
33M doc
416K efi
2.0K firmware
156K g2ldr
8.0K g2ldr.mbr
2.0K install
33M install.amd
303K isolinux
208K md5sum.txt
29K pics
562M pool
9.5K README.html
173K README.mirrors.html
86K README.mirrors.txt
512 README.source
6.0K README.txt
358K setup.exe
76K tools
512 win32-loader.ini
其中 pool 目錄所佔容量最大,共有 562 MB,這個目錄相當「可疑」,很有可能是我們在安裝時所會用到的 .deb 檔案,因此值得切換進去觀察裡面內容。經過一番觀察,此目錄的確存放 .deb 檔案,因此可以將此目錄複製到 /mnt 目錄,指令如下:
cp -av /cdrom/pool /mnt
執行 buildlinux.sh 之鏡像站選擇/下載套件 出錯時之處理流程:
請在 buildlinux 之虛擬機器按 Ctrl+Alt+F 切換至全螢幕,然後按 Alt+F4 至第四個虛端終端機來看錯誤訊息,此時我們會看到系統是因為少了那些檔案而導致安裝流程出錯。根據其錯誤訊息,我們要建立
/mnt/dists/jessie
/mnt/dists/sid
/mnt/dists/squeeze
/mnt/dists/wheezy
四個目錄,再建立底下連結:
root@wyvern:/mnt/dists# ln -s wheezy stable
root@wyvern:/mnt/dists# ln -s jessie testing
root@wyvern:/mnt/dists# ln -s squeeze oldstable
root@wyvern:/mnt/dists# ln -s sid unstable
然後再複製每個目錄所缺少的檔案,目前缺少 Release 檔案。
複製完畢後請至 PXE 伺服器重新掛載 /var/www/debian 目錄
mount -o ro,remount /var/www/debian
並檢查 /var/www 底下是否有 dists 目錄以及剛剛複製的檔案。
然後請再回到 buildlinux 底下,切換至全營幕並重新執行安裝流程,此時我們會發現出現新的錯誤訊息,這表示剛剛 buildlinux 已經有抓到我們複製的檔案,並前往下一步,由於檔案仍然有缺,因此出現新的錯誤訊息。
因此我們繼續複製缺少的檔案:
/mnt/dists# mkdir -p wheezy/main/binary-amd64/
cd wheezy/main/binary-amd64/
wget ftp://ftp.debian.org/debian/dists/wheezy/main/binary-amd64/Release
複製完畢後請再回到 PXE 伺服器,重新掛載 /var/www/debian 目錄。掛載完畢後請再檢查 /var/www/debian/dists/wheezy/main/binary-amd64/Release 這個檔案是否存在,然後切換至 buildlinux 繼續安裝流程。
現在出現的錯訊息是
dists/wheezy/Release is unsigned.
這表示 Release 這個檔案沒有數位簽章,也就是說我們沒有複製 Release.gpg 這個檔案,請複製
ftp://ftp.debian.org/debian/dists/wheezy/Release.gpg
指令如下:
/mnt/dists/wheezy# wget ftp://ftp.debian.org/debian/dists/wheezy/Release.gpg
另一個錯誤訊息是
relolver (libc6-udeb): package doesn't exist (ignored)
這表示 libc6-udeb 這個套件找不到,請至 packages.debian.org 來找
我們可以找到此套件的位置是:
http://ftp.debian.org/debian/pool/main/e/eglibc/libc6-udeb_2.13-38+deb7u1_amd64.udeb
因此我們要在自己的鏡像站的同一個目錄存這個檔案,請切換至
/mnt/pool/main/e/eglibc 目錄,如果沒有此目錄的話,請自己建一個
接著下載此檔:
/mnt/pool/main/e/eglibc# wget http://ftp.debian.org/debian/pool/main/e/eglibc/libc6-udeb_2.13-38+deb7u1_amd64.udeb
作完後請記得至 PXE 伺服器重新掛載 /var/www/debian
之後再切換至 buildlinux 來繼續安裝流程
----------------------------------------------------------------------------
PXE 伺服器設定:
此時我們可以啟動 PXE 伺服器,並將 /dev/sdb1 以 ro 的權限來掛載至
/var/www/debian 目錄,指令如下:
# mount -o ro /dev/sdb1 /var/www/debian
(請注意上述指令在 PXE 伺服器中執行)
掛載完畢後可以執行 df -h /var/www/debian 來觀看其輸出,如底下所示:
檔案系統 容量 已用 可用 已用% 掛載點
/dev/sdb1 2.0G 600M 1.3G 32% /var/www/debian
我們可以看到 /var/www/debian 目前已用 600M 的空間,正好是之前複製光碟片的容量。
----------------------------------------------------------------------------
建立 linux client 主機:
請執行 buildlinux.sh 看看能否進入安裝畫面,並正常安裝。我們在輸入鏡像站時以自定鏡像站 192.168.10.254 來作為安裝鏡像站,結果發現出錯。因此要回到 /mnt 檔案複製處繼續修改。
思維模式:
PXE Server 負責提供一個可以讓同網域網段之電腦利用網路開機、取得 IP 以及安裝 Debian Linux 的功能,其中 deb_mirror.img 負責存放網路安裝 (net install) 時必須使用的套件 (package),也就是安裝時所必要的 .deb 檔案。因此我們建立 deb_mirror.img,將其分割、格式化,並掛載至 /mnt 目錄以利下載套件用。
建立 deb_mirror.img 流程:
a. dd if=/dev/zero of=deb_mirror.img bs=1G count=2
b. # fdisk deb_mirror.img
將其建立一個分割區。
c. 將 deb_mirror.img 格式化
# losetup /dev/loop0 deb_mirror.img
# losetup -o $[2048*512] /dev/loop1 /dev/loop0
# mkfs.ext4 /dev/loop1
d. 將 /dev/loop1 掛載至 /mnt 目錄
mount /dev/loop1 /mnt
掛載完畢後可以執行
df -h /mnt 來觀察是否有正確掛載,其輸出如下所示:
檔案系統 容量 已用 可用 已用% 掛載點
/dev/loop1 2.0G 3.0M 1.9G 1% /mnt
複製 deb_mirror.img 流程:
一開始我們的想法很單純,將 Debian 安裝光碟第一片複製到 deb_mirror.img 中「理論上」即可提供安裝流程所需要的檔案。因此我們需要將 debian 第一片安裝光碟中之檔案複製到 /mnt (目前已掛載 deb_mirror.img) 目錄下,首先要下載第一片安裝光碟,並掛載至 /cdrom 目錄,其操作如下:
1. 下載 debian 第一片安裝光碟
wget ftp://ftp.twaren.net/pub/Debian/debian-cd/current/amd64/iso-cd/debian-7.5.0-amd64-CD-1.iso
(校內請至 120.117.72.71 之 iso 目錄下載)
2. 掛載 debian-7.5.0-amd64-CD-1.iso 至 /cdrom 目錄
首先檢查是否有 /cdrom 目錄,若沒有的話請執行:
# mkdir /cdrom
建立完此目錄後將 debian-7.5.0-amd64-CD-1.iso 掛載至此目錄,指令如:
mount -o loop debian-7.5.0-amd64-CD-1.iso /cdrom
3. 檢視 /cdrom 目錄之內容:
請切換至 /crom 目錄,指令如下:
cd /cdrom
接著執行 ls -l,其輸出如下:
-r--r--r-- 1 root root 27 4月 26 21:38 autorun.inf
dr-xr-xr-x 1 root root 2048 4月 26 21:38 boot
dr-xr-xr-x 1 root root 2048 4月 26 21:38 css
lr-xr-xr-x 1 root root 1 4月 26 21:37 debian -> .
dr-xr-xr-x 1 root root 2048 4月 26 21:38 dists
dr-xr-xr-x 1 root root 4096 4月 26 21:37 doc
dr-xr-xr-x 1 root root 2048 4月 26 21:38 efi
dr-xr-xr-x 1 root root 2048 4月 26 21:38 firmware
-r--r--r-- 1 root root 159629 4月 24 15:42 g2ldr
-r--r--r-- 1 root root 8192 4月 24 15:42 g2ldr.mbr
dr-xr-xr-x 1 root root 2048 4月 26 21:37 install
dr-xr-xr-x 1 root root 2048 4月 26 21:38 install.amd
dr-xr-xr-x 1 root root 4096 4月 26 21:38 isolinux
-r--r--r-- 1 root root 212666 4月 26 21:51 md5sum.txt
dr-xr-xr-x 1 root root 2048 4月 26 21:38 pics
dr-xr-xr-x 1 root root 2048 4月 26 21:38 pool
-r--r--r-- 1 root root 9262 4月 26 21:51 README.html
-r--r--r-- 1 root root 176551 4月 11 09:52 README.mirrors.html
-r--r--r-- 1 root root 87800 4月 11 09:52 README.mirrors.txt
-r--r--r-- 1 root root 425 4月 26 21:38 README.source
-r--r--r-- 1 root root 5827 4月 26 21:51 README.txt
-r--r--r-- 1 root root 366350 4月 24 15:42 setup.exe
dr-xr-xr-x 1 root root 2048 4月 26 21:38 tools
-r--r--r-- 1 root root 256 4月 26 21:38 win32-loader.ini
/cdrom 目錄有許多目錄及檔案,我們可以執行 du -sh * 來觀看每個檔案/目錄的容量,如底下所示:
512 autorun.inf
1.9M boot
8.0K css
0 debian
3.3M dists
33M doc
416K efi
2.0K firmware
156K g2ldr
8.0K g2ldr.mbr
2.0K install
33M install.amd
303K isolinux
208K md5sum.txt
29K pics
562M pool
9.5K README.html
173K README.mirrors.html
86K README.mirrors.txt
512 README.source
6.0K README.txt
358K setup.exe
76K tools
512 win32-loader.ini
其中 pool 目錄所佔容量最大,共有 562 MB,這個目錄相當「可疑」,很有可能是我們在安裝時所會用到的 .deb 檔案,因此值得切換進去觀察裡面內容。經過一番觀察,此目錄的確存放 .deb 檔案,因此可以將此目錄複製到 /mnt 目錄,指令如下:
cp -av /cdrom/pool /mnt
執行 buildlinux.sh 之鏡像站選擇/下載套件 出錯時之處理流程:
請在 buildlinux 之虛擬機器按 Ctrl+Alt+F 切換至全螢幕,然後按 Alt+F4 至第四個虛端終端機來看錯誤訊息,此時我們會看到系統是因為少了那些檔案而導致安裝流程出錯。根據其錯誤訊息,我們要建立
/mnt/dists/jessie
/mnt/dists/sid
/mnt/dists/squeeze
/mnt/dists/wheezy
四個目錄,再建立底下連結:
root@wyvern:/mnt/dists# ln -s wheezy stable
root@wyvern:/mnt/dists# ln -s jessie testing
root@wyvern:/mnt/dists# ln -s squeeze oldstable
root@wyvern:/mnt/dists# ln -s sid unstable
然後再複製每個目錄所缺少的檔案,目前缺少 Release 檔案。
複製完畢後請至 PXE 伺服器重新掛載 /var/www/debian 目錄
mount -o ro,remount /var/www/debian
並檢查 /var/www 底下是否有 dists 目錄以及剛剛複製的檔案。
然後請再回到 buildlinux 底下,切換至全營幕並重新執行安裝流程,此時我們會發現出現新的錯誤訊息,這表示剛剛 buildlinux 已經有抓到我們複製的檔案,並前往下一步,由於檔案仍然有缺,因此出現新的錯誤訊息。
因此我們繼續複製缺少的檔案:
/mnt/dists# mkdir -p wheezy/main/binary-amd64/
cd wheezy/main/binary-amd64/
wget ftp://ftp.debian.org/debian/dists/wheezy/main/binary-amd64/Release
複製完畢後請再回到 PXE 伺服器,重新掛載 /var/www/debian 目錄。掛載完畢後請再檢查 /var/www/debian/dists/wheezy/main/binary-amd64/Release 這個檔案是否存在,然後切換至 buildlinux 繼續安裝流程。
現在出現的錯訊息是
dists/wheezy/Release is unsigned.
這表示 Release 這個檔案沒有數位簽章,也就是說我們沒有複製 Release.gpg 這個檔案,請複製
ftp://ftp.debian.org/debian/dists/wheezy/Release.gpg
指令如下:
/mnt/dists/wheezy# wget ftp://ftp.debian.org/debian/dists/wheezy/Release.gpg
另一個錯誤訊息是
relolver (libc6-udeb): package doesn't exist (ignored)
這表示 libc6-udeb 這個套件找不到,請至 packages.debian.org 來找
我們可以找到此套件的位置是:
http://ftp.debian.org/debian/pool/main/e/eglibc/libc6-udeb_2.13-38+deb7u1_amd64.udeb
因此我們要在自己的鏡像站的同一個目錄存這個檔案,請切換至
/mnt/pool/main/e/eglibc 目錄,如果沒有此目錄的話,請自己建一個
接著下載此檔:
/mnt/pool/main/e/eglibc# wget http://ftp.debian.org/debian/pool/main/e/eglibc/libc6-udeb_2.13-38+deb7u1_amd64.udeb
作完後請記得至 PXE 伺服器重新掛載 /var/www/debian
之後再切換至 buildlinux 來繼續安裝流程
----------------------------------------------------------------------------
PXE 伺服器設定:
此時我們可以啟動 PXE 伺服器,並將 /dev/sdb1 以 ro 的權限來掛載至
/var/www/debian 目錄,指令如下:
# mount -o ro /dev/sdb1 /var/www/debian
(請注意上述指令在 PXE 伺服器中執行)
掛載完畢後可以執行 df -h /var/www/debian 來觀看其輸出,如底下所示:
檔案系統 容量 已用 可用 已用% 掛載點
/dev/sdb1 2.0G 600M 1.3G 32% /var/www/debian
我們可以看到 /var/www/debian 目前已用 600M 的空間,正好是之前複製光碟片的容量。
----------------------------------------------------------------------------
建立 linux client 主機:
請執行 buildlinux.sh 看看能否進入安裝畫面,並正常安裝。我們在輸入鏡像站時以自定鏡像站 192.168.10.254 來作為安裝鏡像站,結果發現出錯。因此要回到 /mnt 檔案複製處繼續修改。
訂閱:
文章 (Atom)