CentOS is an Enterprise-class Linux Distribution and they have created some nice tools to be able to create a PXE installation environment, here is how I did it.
Setting up Anonymous FTP
Fist we need an FTP server and unRAID has the standard vsftpd build in, we'll use that.
But there are some steps to take to make it compatible with the CentOS installer.
By default the only user allowd is 'root' so first we must change that.
- First we need a directory where our 'Anonymous' FTP users go when they connect, run: mkdir -p /mnt/user/SERVER/FTP_ROOT/
- Create a anonymous ftp user, run: useradd ftp -m
- If you get an error that the user already exists, create a homefolder for it: mkdir /home/ftp
- Copy the unRAID default vsftpd.conf file to your flash drive, run: cp /etc/vsftpd.conf /boot/config/(I like editing in Windows, but if you are really determent you can do it in vi)
- Open the file \\tower\flash\config\vsftpd.conf in your favorite text editor (like Windows notepad, but I prefer Notepad2)
- Edit it, so it looks like this:
- Now save it back to its drive and run the command: cp /boot/config/vsftpd.conf /etc/
- Also add this line to your 'go' script (\\tower\flash\config\go)
- Now restart the FTP server, run the command: /etc/rc.d/rc.inetd restart
- You should be able to connect to your server using an FTP client, for Windows I recommend the free application FileZilla. Just fill in your server name or IP adress and hit connect.
- If you already put files in this directory you can make them visible by setting them 'World readable', do: chmod -R -c 755 /mnt/user/SERVER/FTP_ROOT/
# vsftpd.conf for unRAID
#
write_enable=NO
connect_from_port_20=YES
#
# anonymous logins
anonymous_enable=YES
anon_root=/mnt/user/SERVER/FTP_ROOT
anon_world_readable_only=YES
#
# Allow local users to log in.
local_enable=YES
local_umask=077
local_root=/mnt/
check_shell=NO
#
# All file ownership will be 'root'
guest_enable=NO
anon_upload_enable=NO
anon_other_write_enable=NO
anon_mkdir_write_enable=NO
#
# Logging to syslog
syslog_enable=YES
log_ftp_protocol=NO
xferlog_enable=NO
#
# Misc.
dirmessage_enable=NO
ls_recurse_enable=YES
Getting the files
I will be downloading the 6.0 distribution since that is the current build at this moment.
- Create a directory structure for your files: mkdir -p /mnt/user/SERVER/FTP_ROOT/CentOS/6.0/os/i386/
Optionally you can also create a /os/x86_64/ directory if you need the 64bit version - Find a mirror nearby from the CentOS public mirror list, find one that has RSYNC support, copy the link to the RSYNC link to you clipboard.
- Now run the command: rsync -avSHP rsync://mirror.near.you/centos/6.0/os/i386/ /mnt/user/SERVER/FTP_ROOT/CentOS/6.0/os/i386/ Make sure you replace the red part with the link you have in your clipboard. For the x64 edition change the link and the path accordingly.
- Now let rsync download all the required files, no worry's; if the connection drops during transmission it will pickup where it left of. Depending on your connection this may take a while, the download is about 4.37GB
- Now we need to copy 2 of the files from here to our 'PXE images' directory, first create a directory, run: mkdir -p /mnt/user/SERVER/tftpboot/images/CentOS/i386/6.0/
- Then copy over the files: cp /mnt/user/SERVER/FTP_ROOT/CentOS/6.0/os/i386/images/pxeboot/* /mnt/user/SERVER/tftpboot/images/CentOS/i386/6.0/ If it say's "cp: cannot stat `/mnt/user/SERV....etc" it means your download is not completed yet and the directory is empty. you might wanna try this step later or download the files from an FTP server (also in the mirror list)
- Make them 'world readable' by running: chmod -R -c 755 /mnt/user/SERVER/FTP_ROOT/
Modify your PXE config file
Now we have downloaded the files (or your download is still running in the background) we can modify our PXE menu to be able to boot to the CentOS installer.
- Open the default file with your favorite text editor If you have followed my post about PXE on unRAID it is in \\TOWER\server\tftpboot\pxelinux.cfg\
- Add these lines to it: LABEL CentOS 6 x86 Manual MENU LABEL Install CentOS 6 x86 manually from FTP KERNEL images/CentOS/i386/6.0/vmlinuz APPEND initrd=images/CentOS/i386/6.0/initrd.img ramdisk_size=100000 ks=ftp://x.x.x.x/CentOS/6.0/os/i386/config/manual.cfg Make sure you replace the x.x.x.x with the IP or hostname of your FTP server.
- You can now start the installation via PXE, only you need to select all the options manually (Local media or URL, location of kickstart script, etc) we don't want that, so let's creator some kickstart scripts.
Creating CentOS kickstart scripts
Now you may have noticed I refer to a ftp://x.x.x.x/CentOS/6.0/os/i386/config/manual.cfg file, and if you have try'd to start the CentOS installation you might have noticed the installation asks for the correct location, so lets create some.
- Create a folder structure to hold your CentOS kickstart configuration files, run: mkdir /mnt/user/SERVER/FTP_ROOT/CentOS/6.0/os/i386/config/
- Open your favorite editor and create a new file with the following contents, this will create our 'manual' installation, it just sets the FTP path, the keyboard layout and assigns a DHCP address to the fist ethernet adapter it finds. For more information about kickstart scripts just do a google search for "kickstart centos" or "kickstart anaconda" and you will find a massive amount of websites and tutorials or take a look at the CentOS wiki. # Kickstart file for a manual FTP install. install url --url ftp://x.x.x.x/CentOS/6.0/os/i386/ lang en_US.UTF-8 keyboard us # Start the network driver and assign the client a dynamic IP network --device eth0 --bootproto dhcp Make sure you replace the x.x.x.x with the IP or hostname of your FTP server
- Save the file to your server in \\tower\SERVER\FTP_ROOT\CentOS\6.0\os\i386\config\ and name it: manual.cfg
- Make sure the files in the FTP directory are 'world readable' run chmod -R -c 755 /mnt/user/SERVER/FTP_ROOT/ once more.
- Test the installation, you should now get a step-by-step installation of CentOS that downloads all the files of the FTP server when it needs to.
As I said, there are very elaborate sites about using kickstart scripts. This is a very nice one I found by 'Security Nut' aka Damian Tommasino it's a basically installing a complete (bare server) OS completely automatic!
I've modify'd it a bit to suit my needs, but you can always try the original.
WARNING! If you uncomment the red section it will wipe your hard disk!
# Kickstart file for a basic FTP install.
install
url --url ftp://x.x.x.x/CentOS/6.0/os/i386/
lang en_US.UTF-8
keyboard us
# Start the network driver and assign the client a dynamic IP
network --device eth0 --bootproto dhcp
# Set the root password
rootpw --iscrypted
# Enable the firewall and open port 22 for SSH remote administration
firewall --enabled --port=22:tcp
# Setup security and SELinux levels
authconfig --enableshadow --enablemd5
selinux --permissive
# Set the timezone
timezone --utc Europe/Amsterdam
# Create the bootloader in the MBR with drive hda being the drive to install it on
bootloader --location=mbr --driveorder=hda
# Wipe all partitions and build them with the info below
# ***hda may be different on your machine depending on the type of drives you use***
#clearpart --drives=hda --all --initlabel
#part /boot --fstype ext3 --size=100
#part / --fstype ext3 --size=5000
#part swap --size=2000
#part /home --fstype ext3 --size=100 --grow
# Install the Base and Core software package groups for a minimal install, plus OpenSSH server & client
%packages
@Core
@Base
openssh-clients
openssh-server
No comments:
Post a Comment