[备忘录] 在VMware上安装CentOS 4.x(现在才)
简述
-
- VMWare(ESXi 6)のゲストOSとして、CentOS 4.9をインストール
CentOS-4.8-i386-binDVD.isoを使用
操作步骤
虚拟机客户
-
- 获取CentOS 4.8的安装ISO (安装4.8后,稍后升级到4.9)
-
- 创建虚拟机
网络适配器选择E1000
光盘驱动器选择IDE1.0
从ISO启动并进行安装
防火墙选择[自定义],使ssh通行
CentOS 4.9:中文翻译为 “CentOS 4.9″。
请登录并进行设置。
-
- 升级 – 在vault.centos.org上可以获取。
sed -i ‘s/mirrorlist=h /#mirrorlist=h/g’ /etc/yum.repos.d/CentOS-Base.repo
sed -i ‘s/#baseurl=http:\/\/mirror.centos.org\/centos\/$releasever/baseurl=http:\/\/vault.centos.org\/4.9/g’ /etc/yum.repos.d/CentOS-Base.repo
yum update -y
reboot
用户添加等
adduser 新用户名
passwd 新用户名
visudo
在/etc/sudoers-visudo进行编辑
…
# 用户特权规定
root ALL=(ALL) ALL
新用户名 ALL=(ALL) ALL
# 取消注释以允许wheel组中的人运行所有命令
…
准备构建从SRPM文件。
-
- sudo vi /etc/yum.repos.d/srpm.repo
-
- 创建SRPM的仓库设置
创建/etc/yum.repos.d/srpm.repo文件
[os-srpm-centos]
名称=CentOS OS $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/os/SRPMS/
启用=1
优先级=1
[updates-srpm-centos]
名称=CentOS UPDATES $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/updates/SRPMS/
启用=1
优先级=1
[extras-srpm-centos]
名称=CentOS EXTRAS $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/extras/SRPMS/
启用=1
优先级=1
[centosplus-srpm-centos]
名称=CentOS CENTOSPLUS $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/centosplus/SRPMS/
启用=0
优先级=1
[contrib-srpm-centos]
名称=CentOS CONTRIB $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/contrib/SRPMS/
启用=0
优先级=1
[fasttrack-srpm-centos]
名称=CentOS FASTTRACK $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/fasttrack/SRPMS/
启用=0
优先级=1
[cr-srpm-centos]
名称=CentOS CR $releasever – $basearch – 来自centos的源码
基URL=http://vault.centos.org/4.9/cr/SRPMS/
启用=0
优先级=1
构建相关工具
sudo yum groupinstall “Development Tools”
sudo yum install yum-utils
EPEL (Extra Packages for Enterprise Linux) – EPEL (企业级 Linux 额外软件包)
- http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
wget http://download.fedoraproject.org/pub/epel/4/i386/epel-release-4-10.noarch.rpm
rpm -ivh ./epel-release-4-10.noarch.rpm
# デフォルトでは使わない
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo
# アップデート
yum --enablerepo=epel -y update epel-release
yum install –enablerepo=epel htop
(例) htop
[root@localhost ~]# yum install htop ##通常のレポだとない
Setting up Install Process
Setting up repositories
not using ftp, http[s], or file for repos, skipping - Invalid release
...
Reading repository metadata in from local files
Parsing package install arguments
No Match for argument: htop
Nothing to do
[root@localhost ~]# yum install --enablerepo=epel htop ##EPELのレポから取得
Setting up Install Process
Setting up repositories
not using ftp, http[s], or file for repos, skipping - Invalid release
...
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for htop to pack into transaction set.
htop-0.8.3-1.el4.i386.rpm 100% |=========================| 5.1 kB 00:00
---> Package htop.i386 0:0.8.3-1.el4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
htop i386 0.8.3-1.el4 epel 62 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 62 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): htop-0.8.3-1.el4.i 100% |=========================| 62 kB 00:00
warning: rpmts_HdrFromFdno: V3 DSA signature: NOKEY, key ID 217521f6
Public key for htop-0.8.3-1.el4.i386.rpm is not installed
Retrieving GPG key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Importing GPG key 0x217521F6 "Fedora EPEL <epel@fedoraproject.org>"
Is this ok [y/N]: y
Key imported successfully
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: htop ######################### [1/1]
Installed: htop.i386 0:0.8.3-1.el4
Complete!
[root@localhost ~]
VMWare工具
在将内核升级至最新版本(2.6.9-103)后进行操作。
-
- 插入VMTools
解压文件
cd /tmp
sudo mount -o ro /media/cdrecorder
tar zxf /media/cdrecorder/VMwareTools-10.0.6-3560309.tar.gz
sudo umount /media/cdrecorder
cd vmware-tools-distrib
sudo ./vmware-install.pl
会有一些问题,除了下面这个以外,全部都按下[Enter]键选择默认值。
您想启用VMware自动内核模块吗?
[no] yes
sudo reboot
从主机上可以查看到VM Guest的IP地址,也可以选择关机等操作。
wget的构建
cd
mkdir -p dev/wget
cd dev/wget
# ソースのダウンロード
yumdownloader --source wget
# => CentOS 4.9:: wget-1.10.2-1.el4_8.1.src.rpm
#ビルドに必要なパッケージ
sudo yum-builddep ./wget-1.10.2-1.el4_8.1.src.rpm
#
# ソース解凍、ビルド
echo '%_topdir %(echo $HOME)/dev/wget/rpmbuild' > ~/.rpmmacros
mkdir -p ./rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
rpm -i ./wget-1.10.2-1.el4_8.1.src.rpm
cd rpmbuild/SPECS/
rpmbuild -bb --target=`uname -m` ./wget.spec
##
cd ../RPMS/`uname -m`
ls -la
构建内核
cd
mkdir -p dev/kernel
cd dev/kernel
# ソースのダウンロード
yumdownloader --source kernel
# => CentOS 4.9:: kernel-2.6.9-103.EL.src.rpm
sudo yum-builddep ./kernel-2.6.9-103.EL.src.rpm
#
# ソース解凍、ビルド
echo '%_topdir %(echo $HOME)/dev/kernel/rpmbuild' > ~/.rpmmacros
mkdir -p ./rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
rpm -i ./kernel-2.6.9-103.EL.src.rpm
cd rpmbuild/SPECS/
rpmbuild -bb --target=`uname -m` kernel-2.6.spec
##
cd ../RPMS/`uname -m`
ls -la
其他
VMtools 安装日志
[mt08@centos4 vmware-tools-distrib]$ sudo ./vmware-install.pl
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things:
#1) Respect the privacy of others.
#2) Think before you type.
Password:
Creating a new VMware Tools installer database using the tar4 format.
Installing VMware Tools.
In which directory do you want to install the binary files?
[/usr/bin]
What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
[/etc/rc.d]
What is the directory that contains the init scripts?
[/etc/rc.d/init.d]
In which directory do you want to install the daemon files?
[/usr/sbin]
In which directory do you want to install the library files?
[/usr/lib/vmware-tools]
The path "/usr/lib/vmware-tools" does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes]
In which directory do you want to install the common agent library files?
[/usr/lib]
In which directory do you want to install the common agent transient files?
[/var/lib]
In which directory do you want to install the documentation files?
[/usr/share/doc/vmware-tools]
The path "/usr/share/doc/vmware-tools" does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want? [yes]
The installation of VMware Tools 10.0.6 build-3560309 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command: "/usr/bin/vmware-uninstall-tools.pl".
Before running VMware Tools for the first time, you need to configure it by
invoking the following command: "/usr/bin/vmware-config-tools.pl". Do you want
this program to invoke the command for you now? [yes]
Initializing...
Making sure services for VMware Tools are stopped.
Stopping VMware Tools services in the virtual machine:
Guest operating system daemon: [ OK ]
VMware User Agent (vmware-user): [ OK ]
Unmounting HGFS shares: [ OK ]
Guest filesystem driver: [ OK ]
The VMware FileSystem Sync Driver (vmsync) allows external third-party backup
software that is integrated with vSphere to create backups of the virtual
machine. Do you wish to enable this feature? [no]
Found a compatible pre-built module for vmci. Installing it...
Found a compatible pre-built module for vsock. Installing it...
You are running Linux version 2.6.9. The driver for the VMXNET 3 virtual
network card is only available for 2.6.10 and later kernels.
[ Press Enter key to continue ]
The VMware pvscsi module is only supported on kernel version 2.6.32 and newer,
or rhel5 distributions.
Found a compatible pre-built module for vmmemctl. Installing it...
The VMware Host-Guest Filesystem allows for shared folders between the host OS
and the guest OS in a Fusion or Workstation virtual environment. Do you wish
to enable this feature? [no]
Found a compatible pre-built module for vmxnet. Installing it...
The vmblock enables dragging or copying files between host and guest in a
Fusion or Workstation virtual environment. Do you wish to enable this feature?
[no]
VMware automatic kernel modules enables automatic building and installation of
VMware kernel modules at boot that are not already present. This feature can
be enabled/disabled by re-running vmware-config-tools.pl.
Would you like to enable VMware automatic kernel modules?
[no] yes
Do you want to enable Guest Authentication (vgauth)? Enabling vgauth is needed
if you want to enable Common Agent (caf). [yes]
No X install found.
Creating a new initrd boot image for the kernel.
Generating the key and certificate files.
Successfully generated the key and certificate files.
Checking acpi hot plug [ OK ]
Starting VMware Tools services in the virtual machine:
Switching to guest configuration: [ OK ]
VMware Automatic Kmods: [ OK ]
Guest memory manager: [ OK ]
VM communication interface: [ OK ]
VM communication interface socket family: [ OK ]
Guest operating system daemon: [ OK ]
VGAuthService: [ OK ]
The configuration of VMware Tools 10.0.6 build-3560309 for Linux for this
running kernel completed successfully.
You must restart your X session before any mouse or graphics changes take
effect.
You can now run VMware Tools by invoking "/usr/bin/vmware-toolbox-cmd" from the
command line.
To enable advanced X features (e.g., guest resolution fit, drag and drop, and
file and text copy/paste), you will need to do one (or more) of the following:
1. Manually start /usr/bin/vmware-user
2. Log out and log back into your desktop session; and,
3. Restart your X session.
Enjoy,
--the VMware team
[mt08@centos4 vmware-tools-distrib]$