Sunday, June 9, 2013

YUM repository setup on ISO based - RHEL -5

Initially I created mkdir /var/repo/
mount -o loop /var/rhel5.iso /var/repo
cd /var/repo
createrepo .
and then ran createrepo on it. But would get the following error:
Directory must be writable.
To resolve that create a soft link
mkdir /var/repo/Server --> This is the path where I will dump my all RPM's from Server directory
ln -s /var/repo/Server/ /var/repo/Server
createrepo /var/repo/Server

Now......... Add following to the file

 cat /etc/yum.repos.d/iso.repo

[My ISO Repository]
name=test
baseurl=file:///var/repo/Server
enabled=1
gpgcheck=0

Now... Lets test:

[root@smtreeprd02 ~]# rpm -qa | grep -i telnet
telnet-0.17-38.el5
[root@smtreeprd02 ~]# yum remove telnet-0.17-38.el5
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Remove Process
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package telnet.i386 1:0.17-38.el5 set to be erased
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Removing:
 telnet                  i386       1:0.17-38.el5    installed          96 k

Transaction Summary
=============================================================================
Install      0 Package(s)
Update       0 Package(s)
Remove       1 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Removing  : telnet                       ######################### [1/1]

Removed: telnet.i386 1:0.17-38.el5
Complete!
[root@smtreeprd02 ~]#
[root@smtreeprd02 ~]# yum install telnet-0.17-38.el5
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
My ISO Repository         100% |=========================|  951 B    00:00
ftp://192.168.60.143/var/ftp/Server/repodata/repomd.xml: [Errno 4] IOError: [Errno ftp error] 550 Failed to change directory.
Trying other mirror.
Error: Cannot open/read repomd.xml file for repository: Server
[root@smtreeprd02 ~]# cd /etc/yum.repos.d/
[root@smtreeprd02 yum.repos.d]# ls
iso.repo  rhel-debuginfo.repo
[root@smtreeprd02 yum.repos.d]# rm rhel-debuginfo.repo
rm: remove regular file `rhel-debuginfo.repo'? y
[root@smtreeprd02 yum.repos.d]# cd
[root@smtreeprd02 ~]# yum install telnet-0.17-38.el5
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 600 kB    00:00
################################################## 2113/2113
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for telnet to pack into transaction set.
telnet-0.17-38.el5.i386.r 100% |=========================| 7.7 kB    00:00
---> Package telnet.i386 1:0.17-38.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 telnet                  i386       1:0.17-38.el5    My ISO Repository   56 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 56 k
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 37017186

Public key for telnet-0.17-38.el5.i386.rpm is not installed
[root@smtreeprd02 ~]# vi /etc/yum.repos.d/iso.repo
[root@smtreeprd02 ~]# yum install telnet-0.17-38.el5
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package telnet.i386 1:0.17-38.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 telnet                  i386       1:0.17-38.el5    My ISO Repository   56 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 56 k
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
warning: telnet-0.17-38.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: telnet                       ######################### [1/1]

Installed: telnet.i386 1:0.17-38.el5
Complete!




Friday, June 7, 2013

mount DVD in RHEL 5

I was not able to find this on internet and on forums. But I knew I had one Linux box where I had done full installation and DVD would get mounted there. Hence ran ls -l /dev/dvd and found that it is soft linked to hdc. So did the following:

[root@smtreeprd05 ~]# ln -s /dev/hdc /dev/dvd
[root@smtreeprd05 ~]# ls -l /dev/dvd
lrwxrwxrwx 1 root root 8 Jun  4 01:22 /dev/dvd -> /dev/hdc
[root@smtreeprd05 ~]# mount /dev/dvd /mnt/
mount: block device /dev/dvd is write-protected, mounting read-only
[root@smtreeprd05 ~]# cd /mnt/
[root@smtreeprd05 mnt]# ls
Cluster         README-en.html  README-or.html         RELEASE-NOTES-de.html  RELEASE-NOTES-ml.html     RPM-GPG-KEY-fedora
ClusterStorage  README-es.html  README-pa.html         RELEASE-NOTES-en       RELEASE-NOTES-mr.html     RPM-GPG-KEY-fedora-test
EULA            README-fr.html  README-pt_BR.html      RELEASE-NOTES-en.html  RELEASE-NOTES-or.html     RPM-GPG-KEY-redhat-auxiliary
eula.en_US      README-gu.html  README-ru.html         RELEASE-NOTES-es.html  RELEASE-NOTES-pa.html     RPM-GPG-KEY-redhat-beta
GPL             README-hi.html  README-si.html         RELEASE-NOTES-fr.html  RELEASE-NOTES-pt_BR.html  RPM-GPG-KEY-redhat-former
images          README-it.html  README-ta.html         RELEASE-NOTES-gu.html  RELEASE-NOTES-ru.html     RPM-GPG-KEY-redhat-release
isolinux        README-ja.html  README-te.html         RELEASE-NOTES-hi.html  RELEASE-NOTES-si.html     Server
README-as.html  README-kn.html  README-zh_CN.html      RELEASE-NOTES-it.html  RELEASE-NOTES-ta.html     TRANS.TBL
README-bn.html  README-ko.html  README-zh_TW.html      RELEASE-NOTES-ja.html  RELEASE-NOTES-te.html     VT
README-de.html  README-ml.html  RELEASE-NOTES-as.html  RELEASE-NOTES-kn.html  RELEASE-NOTES-zh_CN.html
README-en       README-mr.html  RELEASE-NOTES-bn.html  RELEASE-NOTES-ko.html  RELEASE-NOTES-zh_TW.html

Thanks.

Monday, June 3, 2013

mount: special device /dev/dvd does not exist

[root@localhost ~]# mount /dev/dvd /mnt/
mount: special device /dev/dvd does not exist

tried the following command and it worked!
ln -sf /dev/hdc /dev/dvd

[root@localhost ~]# mount /dev/dvd /mnt/
mount: block device /dev/dvd is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
Cluster         README-or.html         RELEASE-NOTES-ml.html
ClusterStorage  README-pa.html         RELEASE-NOTES-mr.html
EULA            README-pt_BR.html      RELEASE-NOTES-or.html
eula.en_US      README-ru.html         RELEASE-NOTES-pa.html
GPL             README-si.html         RELEASE-NOTES-p

OUTPUT truncated.........................

Sunday, June 2, 2013

RHEL 5 Kickstart setup and installation

Below is the short process of how to setup the Kickstart server and create a Kickstart file for automated installation with HTTP style.

Set up web server Apache which is default on RHEL-5.
Create an iso with the dd command as shown below
mount the DVD

# mount /dev/dvd /mnt
# dd if=/dev/dvd of=/var/rhel5.iso
# mkdir /var/www/html/kick
# cd /var/www/html/kick
dump your DVD mounted files and directories with following way:

#  rsync -rv /mnt/* .

copy the anaconda.ks.cfg file from /root and modify as per your requirement. Here is the basic one just to get the things going - So this is simply just for reference - in case you forget OR set up the Kickstart after a while :-) in that case you may really need some notes to refer.

Example ks.cfg file:

# Kickstart file automatically generated by anaconda.

install
url --url http://192.168.60.130/kick
key --skip
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8
keyboard us
xconfig
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$mgirnE1C$tK92VwNASset7OLfUSznD/
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone America/Phoenix
bootloader --location=mbr --append="rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100
part / --fstype ext3 --size=3000 --grow --maxsize=4000
part /home --fstype ext3 --size=1000 --grow
part swap --size=1000 --grow --maxsize=2000

%packages
@ admin-tools
@ text-internet
@ gnome-desktop
@ dialup
@ smb-server
@ base-x
@ web-server
@ printing
@ server-cfg
grub
e2fsprogs
kernel

%post

boot your client with bootable CD or with iso

linux ks=http://192.168.140.22/kick/ks.cfg



Thanks.







Sunday, May 26, 2013

RHEL 5 parted command step by step.

To test this we used RHEL 5 n vmware.
1. Add a new SCSI type hard disk
2. vm machine will save it and process for you
3. after may be one minute run fdisk -l as root and see if you can see the disk you created

Disk /dev/sdb: 1073 MB, 1073741824 bytes
81 heads, 26 sectors/track, 995 cylinders
Units = cylinders of 2106 * 512 = 1078272 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         186      195312+  83  Linux
Partition 1 has different physical/logical endings:
     phys=(24, 80, 26) logical=(185, 39, 2)

Now run the command:

[root@smtreeprd04 ~]# parted /dev/sdb
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
Got following error:
(parted) mkpart
Error: Unable to open /dev/sdb - unrecognised disk label.

Lets label the disk:

(parted) mklabel msdos
(parted) mkpart
Partition type?  primary/extended? primary
File system type?  [ext2]?
Start? 1 200
(parted) p

Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type     File system  Flags
 1      0.51kB  200MB  200MB  primary

Now exit the parted utility and format the partition with mkfs

[root@smtreeprd04 ~]# mke2fs /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
48960 inodes, 195312 blocks
9765 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
24 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

create a directory for mount  point

mkdir /sdb1

[root@smtreeprd04 ~]# mount /dev/sdb1 /sdb1/

[root@smtreeprd04 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             5.7G  2.3G  3.2G  43% /
/dev/sda1              99M  9.9M   84M  11% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/sda7             965M   18M  898M   2% /home
/dev/sda6             1.5G   35M  1.4G   3% /opt
/dev/sda2             9.5G  5.4G  3.7G  60% /var
/dev/sdb1             185M  1.6M  174M   1% /sdb1

Thanks.



Friday, May 24, 2013

one liner for file system size in GB sorted.

This command will generate the output to check the file systems in GB larger on the top.
cd to the directory you want this command to run on.

 du -sh * | egrep '([0-9][G])' | sed 's/[0-9][K,M]//g' | sort -rn

I ran this and found that, this works but with one glitch. It is going to return the file names too with size if the file names have "G" exactly in the name. To overcome this run following for loop in the directory which sub-directories file size you want to count.

for i in `ls -l  | grep "^d" | awk '{print  $9}'`  ; do du -sh $i ; done | egrep '([0-9][G])' | sort -rn

Thanks

Tuesday, May 21, 2013

How to connect vsftpd via browser or Windows Explorer on Centos 6.4.

Here are the steps...

Install the vsftpd-2.2.2-11.el6_3.1.x86_64 rpm. This will create the /var/ftp/pub directory
upload your stuff here.

Make changes to the /etc/vsftpd/vsftpd.conf file as per your requirement. I added a few as follows:

banner_file=/etc/vsftpd/issue
local_enable=YES
xferlog_std_format=NO etc...


Add entry in the iptables:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT

restart the vsftpd daemon:

[root@smacentos6 mnt]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]


Open the windows explorer or browser - It did not work.

Solution: load the following modules:

[root@smartcentos6 ~]# modprobe ip_nat_ftp
[root@smartcentos6 ~]# modprobe  ip_conntrack_ftp

restart the vsftpd daemon:

[root@smacentos6 mnt]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

Again restart the
see the screenshot:



Thanks,
-Raj