Thursday, August 12, 2010

Chapter2 - rpm and yum

Commands to be aware of:

yum
  • yum list [all|installed|available|updates] [regex]
  • yum info pkgname
  • yum provides filename (lists the rpms that contain that file. 'yum provides filename | grep installed -B3' is more useful)
  • yum install pkgname | yum localinstall pkgname.rpm | yum groupinstall group
  • yum search
createrepo
  • createrepo -v /dir
  • createrepo -v --update /dir
  • Creates the following files in /dir/repodata/
    • repomd.xml - md5 checksum of other files. client cache is updated when this file changes
    • primary.xml.gz - list of all rpms, and files provided by rpms
    • filelists.xml.gz - list of all files provided by rpms, used by 'yum provides'
    • other.xml.gz - other meta info of packages
rpm
  • install-upgrade-remove
  • rpm -ivh pkg.rpm: installs. -v verbose, -h prints hash progress bar
  • rpm -Uvh pkg.rpm: upgrades pkg.rpm if it exists, installs if it doesn't exist
  • rpm -Fvh pkg.rpm: upgrades pkg.rpm if it exists, skips if it doesn't exist
  • rpm -i --replacepkgs: install same package again
  • rpm -i --oldpackage: downgrade package
  • rpm -e pkg: removes pkg
  • query
  • rpm -qa: list all packages
  • rpm -ql pkg: list all files of installed pkg
  • rpm -qc pkg: list all config files of installed pkg
  • rpm -qd pkg: list all doc files of installed pkg
  • rpm -qi pkg: pkg info
  • rpm -qf filename: name the package that installed this file
  • rpm -q --changelog pkg: print changelog
  • rpm -q --scripts pkg: print pre and post scripts
  • rpm -qa --last: print installation time
  • rpm -qap pkg.rpm: list all files of pkg.rpm
  • rpm -qcp | -qdp pkg.rpm
  • verify
  • rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  • rpm -V pkg: verifies package (of any modifications to its files)
  • rpm -Va : verify all pkg
  • rpm -Vp pkg.rpm
  • rpm --checksig pkg.rpm

Wednesday, August 11, 2010

Chapter1 - Installation and Virtualization

Installation:
  • In the training rooms, they set up a DHCP server, that also hosts a kickstart file
  • For practice, I've installed RHEL 5.4 on my desktop using the regular DVD boot
  • The kickstart file for this install is stored in /root/anaconda-ks.cfg
  • A kickstart file contains 3 sections:
    • Commands: The response for all questions asked in the installation
    • Packages: List of pkgs to be installed
    • Scripts: pre and post scripts to be run before and after the installation
Virtualization:
Install Xen hypervisor:
$ yum -y install kernel-xen xen virt-manager
Reboot, select the Xen kernel in Grub menu


Start services:
$ service xend start
$ service libvirtd start


Make sure the services start on boot:
$ chkconfig xend on
$ chkconfig libvirtd on


Create LV for VM:
$ lvcreate -L 10G -n vserver sys
$ virt-install --paravirt --ram 1024 --disk vol=/dev/sys/vserver --location /mnt/iso
OR
$ virt-install --paravirt --ram 1024 --disk vol=/dev/sys/vserver --location ftp://ftplocation/image -x ks=kickstart_file

Graphical tool - virt-manager
$ yum - y install virt-manager

Create Yum repository from ISO file

The Linux flavor used here is RHEL5.

1. Mount the ISO image to /mnt/iso/
$ mkdir /mnt/iso
$ mount -o ro,loop /path/to/rhel-server-5.4-x86_64-dvd.iso /mnt/iso


or add this line to /etc/fstab
/path/to/rhel-server-5.4-x86_64-dvd.iso /mnt/iso iso9660 ro,loop 0 0
$ mount -a


2. Bootstrap - install createrepo
$ cd /mnt/iso/Server (it may be in some other folder)
$ rpm -Uvh createrepo*


3. Trouble with creating a repo of this mounted directory:
$ createrepo /mnt/iso/
Directory /mnt/iso/. must be writable.


4. Solution: Create another directory. Add a symlink to the mounted directories that contains the RPMs. Convert this new directory as the repo
$ mkdir /var/repo
$ ln -s /mnt/iso/Server /var/repo/rpms
$ ln -s /mnt/iso/VT /var/repo/rpms-vt

$ createrepo /var/repo

3040/3040 - rpms/zsh-html-4.2.6-3.el5.x86_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata


5. Create repo conf file
$ vi /etc/yum.repos.d/myrepo.repo
[rhel-myrepo]
name=myrepo
baseurl=file:///var/myrepo
enabled=1
gpgcheck=0


6. Test the new repo
$ yum list installed