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

Tuesday, April 13, 2010

Setting up serial console

[ From: http://tx.downloads.xensource.com/downloads/docs/user/ ]

2.5.2 Serial Console (optional)

Serial console access allows you to manage, monitor, and interact with your system over a serial console. This can allow access from another nearby system via a null-modem (``LapLink'') cable or remotely via a serial concentrator.

You system's BIOS, bootloader (GRUB), Xen, Linux, and login access must each be individually configured for serial console access. It is not strictly necessary to have each component fully functional, but it can be quite useful.

For general information on serial console configuration under Linux, refer to the ``Remote Serial Console HOWTO'' at The Linux Documentation Project: http://www.tldp.org

2.5.2.1 Serial Console BIOS configuration

Enabling system serial console output neither enables nor disables serial capabilities in GRUB, Xen, or Linux, but may make remote management of your system more convenient by displaying POST and other boot messages over serial port and allowing remote BIOS configuration.

Refer to your hardware vendor's documentation for capabilities and procedures to enable BIOS serial redirection.

2.5.2.2 Serial Console GRUB configuration

Enabling GRUB serial console output neither enables nor disables Xen or Linux serial capabilities, but may made remote management of your system more convenient by displaying GRUB prompts, menus, and actions over serial port and allowing remote GRUB management.

Adding the following two lines to your GRUB configuration file, typically either /boot/grub/menu.lst or /boot/grub/grub.conf depending on your distro, will enable GRUB serial output.

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console

Note that when both the serial port and the local monitor and keyboard are enabled, the text ``Press any key to continue'' will appear at both. Pressing a key on one device will cause GRUB to display to that device. The other device will see no output. If no key is pressed before the timeout period expires, the system will boot to the default GRUB boot entry.

Please refer to the GRUB documentation for further information.

2.5.2.3 Serial Console Xen configuration

Enabling Xen serial console output neither enables nor disables Linux kernel output or logging in to Linux over serial port. It does however allow you to monitor and log the Xen boot process via serial console and can be very useful in debugging.

In order to configure Xen serial console output, it is necessary to add a boot option to your GRUB config; e.g. replace the previous example kernel line with:

   kernel /boot/xen.gz dom0_mem=131072 com1=115200,8n1

This configures Xen to output on COM1 at 115,200 baud, 8 data bits, 1 stop bit and no parity. Modify these parameters for your environment.

One can also configure XenLinux to share the serial console; to achieve this append ``console=ttyS0'' to your module line.

2.5.2.4 Serial Console Linux configuration

Enabling Linux serial console output at boot neither enables nor disables logging in to Linux over serial port. It does however allow you to monitor and log the Linux boot process via serial console and can be very useful in debugging.

To enable Linux output at boot time, add the parameter console=ttyS0 (or ttyS1, ttyS2, etc.) to your kernel GRUB line. Under Xen, this might be:

  module /vmlinuz-2.6-xen0 ro root=/dev/VolGroup00/LogVol00 \
console=ttyS0, 115200
to enable output over ttyS0 at 115200 baud.

2.5.2.5 Serial Console Login configuration

Logging in to Linux via serial console, under Xen or otherwise, requires specifying a login prompt be started on the serial port. To permit root logins over serial console, the serial port must be added to /etc/securetty.

To automatically start a login prompt over the serial port, add the line:

c:2345:respawn:/sbin/mingetty ttyS0
to /etc/inittab. Run init q to force a reload of your inttab and start getty.

To enable root logins, add ttyS0 to /etc/securetty if not already present.

Your distribution may use an alternate getty; options include getty, mgetty and agetty. Consult your distribution's documentation for further information.

Thursday, April 8, 2010

How to delete a file with name beginning with hyphen?

$ rm -f -----BEGIN
rm: unrecognized option `-----BEGIN'
Try `rm --help' for more information.

Methods:
1. rm -f ./----BEGIN

2. rm -f /home/viyer/----BEGIN

3. rm -- ----BEGIN

Ref: http://unstableme.blogspot.com/2010/01/unix-delete-file-with-hyphen-at.html

Friday, January 23, 2009

Ubuntu: How to create a bootable USB drive from ISO file

I no longer trust CDs, it's time we phase out CDs and put it in the category we created for floppies.

So, if you have a Ubuntu iso file (if not, get it from here) how do you get it installed using your flash drive?

Step 1: Get UNetBootin
  • add the following lines in /etc/apt/sources.list
    http://ppa.launchpad.net/gezakovacs/ubuntu hardy main
    deb-src http://ppa.launchpad.net/gezakovacs/ubuntu hardy main
  • sudo apt-get update
  • sudo apt-get install unetbootin
  • if you run into dependency issues, run 'sudo apt-get -f install'
  • if you are installing from windows/mac, download the corresponding version of unetbootin from here.
Step 2: Launch UNetBootin
  • click on the Diskimage radio button, and add path to the iso file
  • select Type as 'USB Drive' from the drop down menu, and add the Drive letter in the next drop down.
  • for linux users, you have to check the 'Show all drives' checkbox and select the appropriate one (do a 'mount -l' to confirm)
  • it will now extract the files to the USB and make necessary configurations to make it bootable
  • select 'reboot now' option to install on the same machine, or unplug the USB and boot with it on another machine

Friday, September 19, 2008

Ubuntu: Sound stops working until reboot

I've often faced this problem that the sound suddenly stops working, and after a reboot things are fine as before. By sound I mean Audacious, that's what I normally use.

It was irritating to reboot just to get my headphones working!!

The error it reports is: "Cannot connect to output".
The output drop-down field in Preferences->Audio shows '"Pulseaudio Output Plugin" and changing it to "Alsa output" solved the problem.

But why it changed? What was the default output before?
Does it happen with other players? other flavors of linux?

I'll update this as and when I get the answers :P

Sunday, August 17, 2008

Ubuntu@Laptop: turning off internal speakers on connecting headphones

In most cases, Ubuntu has already configured everything.. just one check-box needs to be checked.

Open System->Preferences->Volume Control

There should be a tab named "Switches".
(If its not present, Goto Edit->Preferences and check "Headphone jack sense")

Goto the "Switches" Tab, and check the box in front of "Headphone Jack sense".
Thats it!!

If by default the options mentioned here are not there, then look for answers in the ubuntu forums.

Wednesday, August 13, 2008

Excellent introductary presentation on algorithms

Ubuntu@Laptop: Wireless Button LED does not work

I have a HP Compaq nc6220 laptop (really a dabba!!)

I installed ubuntu 8.04 on it, and since there's a rule that not everything should be working - my wireless button was dysfunctional!

Doing a 'sudo lshw -C network' after pressing the wireless button showed that the button is actually toggling the radio, its just not making the LED glow.

i.e. after pressing it once, the command output will have the string -
wireless=radio off

and after pressing it again, it will contain -
wireless=unassociated

Solution -
Find the driver module for the wireless card, in my case it was ipw2200.

Remove the module:
sudo modprobe -r ipw2200

And insert it again with the led option:
sudo modprobe ipw2200 led=1

This makes the LED blink when the radio is turned on.

Note: This setting is lost on reboot, so add these two commands in /etc/rc.local