Monday, July 7, 2008

Some Caveats Regarding BIOS and Boot Loader

1. The default boot loader is GRUB, and the first part of it is installed in the MBR of the default drive. Normally, the BIOS should automatically start the boot loader, with a message similar to:

Booting Red Hat Enterprise Linux Server (2.6.18-8.el5) in 5 seconds...

2. For an older PC, unless it's located within the first 1024 cylinders of the hard disk, the BIOS can't find your boot loader that is why the /boot partition installed is normally a primary partition.

3. The workaround for this problem is using logical block addressing, which is also recognized as LBA mode.
LBA mode
reads "logical" values for the cylinder, head, and sector, which allows the BIOS to "see" a larger disk drive.

For multiple hard drives:
Here is the caveat:
a. For IDE (PATA) hard drives, the /boot directory must be on a hard drive attached to the primary IDE controller.
b. For all SCSI hard drives, the /boot directory must be located on a hard drive with SCSI ID 0 or ID 1.
c. For a mix of hard drives, the /boot directory must be located on either the first IDE drive or a SCSI drive with ID 0.


The Fundamentals of the Boot Process


Many people ignore learning about this process, including me as well. When I started learning Linux at the first time, I did not care that this boot process is very important especially for troubleshooting Linux server; in case, the grub is corrupt or forgotten password. Normally, the shortcut will be erasing or formatting the whole hard disk and start installing all over again.

Steps of Boot Process:

1. If your CentOS or RHEL is properly installed, the BIOS points to the GRUB boot loader.
Most of the time, GRUB boot loader is located in the appropriate master boot record (MBR).
2. Then the next step is GRUB points to and initializes the Linux kernel.
3. Starting init as the first Linux process.

4. The init process then initializes the system and moves into appropriate runlevels.
5. When Linux boots into a specific runlevel, it starts a series of services.

6. The good news is we can customize this process.



Installing and Configuring Chrooted VSFTPD in CentOS 5.0 or RHEL 5.0

Setting vsftpd is not hard but not easy either, if you want to make it secure. Here is some of my notes:

1. Install vsftpd
# yum install vsftpd
2. Start the service
# /etc/init.d/vsftpd start or # service vsftpd start
3. Edit the vsftpd.conf
# vim /etc/vsftpd/vsftpd.conf
4. Uncomment the following directives:
chroot_local_user=YES - to chroot local user
passwd_chroot_enable=YES - prompt the password for the local user
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list - users in this list will be non-chrooted so be careful

Creating Local Repo for RHEL 5.0 or CentOS 5.0

Dependencies is very troublesome when we use rpm to install packages. Sometimes, it becomes never ending loop until we give up. Packages like dovecot, httpd and so forth are the best installed using yum commands, while installing local repo itself is quite tricky job.
In this post, I try to explain as short and brief as I can:

1. Copy the whole content of the DVD or CDs that you have to folder /var/ftp/pub. In this case we are going to create repo using ftp.
Do this command to copy:
# mount /mnt/cdrom /media/CentOS
# cp -af /media/CentOS/* /var/ftp/pub


2. After you've done copying all of those files (please, note to answer yes when it asked about replacing some files), install createrepo .rpm
# rpm -ivh /var/ftp/pub/createrepo*.rpm

3. After you install createrepo then run this command
# createrepo -v /var/ftp/pub

4. To enable useful yum commands, please, check my previous post like:
yum -y groupinstall "MySQL Database" and so forth, you have to run the following command
# cp /var/ftp/pub/Server/repodata/comps*.xml /tmp
# createrepo -g /tmp/comps*.xml /var/ftp/pub


5. Done and remember to reboot the server.

6. On your client machine please, create a repo file (for example: server1.repo)

7. Here is the content of server1.repo

# Main server
[base]
name=Server1 Server Repository
# This could be anything
baseurl=ftp://192.168.0.91/pub/Server # This is the IP address of our ftp server
enabled=1
gpgcheck=0
# Just make it zero if you haven't or don't want to import the GPG key

8. Copy the file server1.repo to your client machine folder under /etc/yum.repos.d/
if you did right the following is the output after you run: yum grouplist

Loading "security" plugin
Loading "rhnplugin" plugin
Setting up Group Process
Installed Groups:
Office/Productivity
MySQL Database
Editors
System Tools
Text-based Internet
Legacy Network Server
DNS Name Server
GNOME Desktop Environment
FTP Server
Network Servers
Windows File Server
X Window System
Web Server

................................................
................................................

Using FTP in the Safe Way

a. Using ssh to do port forwarding.
b. Using the following command means that:
c. You are connecting to computer benjamin using ssh, with account username using local port 1234 to connect to port 21 (ftp) at computer abigail.

benjamin$ ssh -l username -g -L1234:abigail:21 benjamin

d. You’ll be asked by the password of username.
e. Then, you need to open another terminal to do ftp session to abigail using the following command

benjamin$ ftp benjamin 1234

Note:
You seem like opening ftp session to your own computer (benjamin); however, what happens is that you are opening a session to port 1234 on benjamin (your computer) which then using its ssh program now forwarding on to abigail. But this time, this forwarded connection is encrypted.

Saturday, March 8, 2008

Using scp To Safely Transfer File

scp is safer compared to rcp, as it encrypts the whole file. However, it will cause a considerable load on the server.
Scp functions pretty much like cp command used for copying files.

Here is the format for scp command:

$ scp user@source.hostname:source_filename user@destination.hostname:dest_dir/dest_filename

Most of the time, there’s no need to put the hostname if you’re copying the local file.

$ scp source_filename user@destination.hostname:dest_dir/dest_filename

There is also no need to put user@, if the source and the destination is the same machine.

Some more examples:

You are logged into abigail and transferring a file from benjamin to abigail. You’re in your home directory in abigail, the file.dat is the filename.

abigail$ scp username@benjamin.hostname:file.dat .

Transferring file.dat in your current directory on benjamin to abigail in the data directory and not changing the name of the file.

benjamin$ scp file.dat username@abigail.hostname:data/


The following is the same of above but changing the file.dat name at the destination directory

benjamin$ scp file.dat username@abigail.hostname:data/


You’ll be asked for your password, like you’re logging in to the remote machine. The tranfer will run right after the correct password keyed-in.



Thursday, March 6, 2008

Some Useful Yum Commands

The yum utility keeps downloaded data files and packages for reuse. You may copy packages from the repository cache directories under /var/cache/yum/, and use them elsewhere if you wish. If you remove a package from the cache, you do not affect the copy of the software installed on your system.

To install the package tsclient, enter the command:
su -c 'yum install tsclient'

To install the package group MySQL Database, enter the command:
su -c 'yum groupinstall "MySQL Database"'

To remove the tsclient package from your system, use the command
su -c 'yum remove tsclient'

To remove all of the packages in the package group MySQL Database, enter the command:

su -c 'yum groupremove "MySQL Database"'