Showing posts with label Installations in Linux. Show all posts
Showing posts with label Installations in Linux. Show all posts

hacking-rpms-with-rpmrebuild

rpmrebuild is good tool to perform reverse engineer the files installed on an older Fedora system back into its original RPM package. Rpmrebuild is able to reconstruct an RPM by looking up the information about it on the RPM database that is part of every RPM-based distribution like Fedora. But rpmrebuild doesn’t stop there; you can also modify actual RPM packages without needing access to its SRPMS or even knowing much about SPEC files. Although this may not be recommended when dealing with core/base Linux system RPMS, it is incredibly useful for developers, release engineers, and system administrators who needs to create internal RPMs for their organizations.
For example, it is common practice for release engineers to have a “back out strategy” in case a release does not meet requirements during installation. With rpmrebuild, the version and release numbers of an RPM that may be replaced by a new one can be tweaked so that in case there is a failure and the ”back out” RPM is needed, the release engineers can simply install the back out RPMs over the new RPMs. Then the back out RPMs will have higher version and/or release numbers on them, so a tool like up2date or yum can automatically pick up on the changes.
Rpmrebuild is currently available for Fedora 10 and 11. To install:
yum install rpmrebuild
To rebuild an installed package in your system into an RPM:
rpmrebuild packagename
While rebuilding a package, rpmrebuild will let you know if files have been modified from their original state. If they have, it will give you the option to continue or halt the rebuilding of the package, and it will ask you if you want to change the release number of the package.
Example:
[root@dhcp227-94 SOURCES]# rpmrebuild httpd
Processing files: httpd-2.2.3-7.el5
Wrote: /usr/src/redhat/RPMS/i386/httpd-2.2.3-7.el5.i386.rpm
result: /usr/src/redhat/RPMS/i386/httpd-2.2.3-7.el5.i386.rpm
My favorite feature of rpmrebuild is the ability to modify its spec file on the fly. By that I mean that you can actually edit the spec of an existing RPM without having to rebuild from source. Why is this useful? Well, you can modify RPM package requirements, change logs, descriptions, and other fields on the spec without having to go through the entire build process again. It can save you a lot of time if you are in the business of building RPMs and don’t necessarily use auto-builders like koji or buildbot.
Here how’s it done:
rpmrebuild -e -p –no-test-install package.rpm
  • -e tells rpmrebuild you want to edit the whole spec file
  • -p is used because we are editing an actual RPM file
  • –notest-install stops rpmrebuild from auto-testing your RPM, just in case you are building an RPM on a workstation that does not have all required RPMs for that package
Rpmrebuild also offers certain shortcuts and plugins. Below I will change the release number of an RPM file without having to open up its spec file. This is a great for automating release numbering processes.
[root@dhcp227-94 i386]# rpmrebuild --release=99 -p --notest-install httpd-2.2.3-7.el5.i386.rpm
Processing files: httpd-2.2.3-99
Wrote: /usr/src/redhat/RPMS/i386/httpd-2.2.3-99.i386.rpm
result: /usr/src/redhat/RPMS/i386/httpd-2.2.3-99.i386.rpm
Notice that the httpd package went from release #7 to #99.
Not as recommended, but useful for your organization’s internal applications, you can modify the version number of an RPM as well:
rpmrebuild --change-spec-preamble='sed -e "s/^Version:.*/Version:1\.3\.1\.0\.1/"' --release=99 -p –notest-install  some-package-1.3.1-11.noarch.rpm
This command will rebuild your RPM and produce some-package-1.3.1.0.1-99.noarch.rpm.
Some other things to keep in mind about rpmrebuild are:
1.Once an RPM is rebuilt, it will lose its original signature (if signed).
2.You need to be root to rebuild a package only if there are root-protected files in that package.
3.Rpmrebuild will respect your RPM “home” building location, so if you have .rpmmacros set up in your home dir, your rebuilt RPMs will show up there.
The authors of rpmrebuild, Eric Gerbier and Valery Reznic, point out that even though the newer versions of RPM have a repackage option, they still require the user to uninstall that package from their system, which sometimes is not necessarily easy because of the dependencies on that package.
If you want to rebuild an old RPM that is not easily available on the Internet anymore, or if you need to tweak packages for your organization’s internal releases, or even if all you want to do is study and learn a bit more about RPM packaging, rpmrebuild is a great tool to have.

Setting Up a PXE Server


This section discusses how to set up a Pre-boot eXecution Environment (PXE) boot server for machines that cannot boot from CD, DVD, or USB media. PXE is a special extension of services provided by the Dynamic Host Configuration Protocol (DHCP). It uses a Trivial File Transfer Protocol (TFTP) server to provide minimal boot files to a network client. To set up a PXE boot service on a separate Fedora server on the local network, follow this procedure:
1.   Install the tftp-server, dhcp, and syslinux packages:
2.    su -c 'yum install tftp-server
·                dhcp syslinux'
3.   Edit the /etc/dhcpd.conf file to configure the DHCP server. The following example is a minimal configuration for a network that uses the following configuration:
·         192.168.1.0/24 addressing
·         Dynamic addresses provided between 192.168.1.200 and 192.168.1.240
·         DHCP/PXE server at IP address 192.168.1.10
·         No other dynamic configuration provided
4.    allow booting;
5.    allow bootp;
6.    ddns-update-style interim;
7.    ignore client-updates;
8.     
9.    subnet 192.168.1.0 netmask 255.255.255.0 {
10.      option subnet-mask 255.255.255.0;
11.      option broadcast-address 192.168.1.255;
12.      range dynamic-bootp 192.168.1.200 192.168.1.240;
13.      next-server 192.168.1.10;
14.      filename "pxelinux.0";
15. }

16.               As the root user, copy the PXE boot image and Fedora boot files to the TFTP server directory.



17. su -
18. cd /tftpboot
cp /usr/lib/syslinux/pxelinux.0 .
19.               Copy the vmlinuz and initrd.img files from the pxeboot directory on distribution media or a Web mirror to the /tftpboot directory.
20.               Create a minimal /tftpboot/pxelinux.cfg file:
21. DEFAULT pxeboot
22. TIMEOUT 50
23. LABEL pxeboot
24.       KERNEL vmlinuz
25.       APPEND initrd=initrd.img
ONERROR LOCALBOOT 0
26.               Turn on the dhcpd, xinetd and tftp services:
27. su -c '/sbin/service dhcpd start'
28. su -c '/sbin/service xinetd start'
su -c '/sbin/chkconfig tftp on'
Boot the client system and either use the required keys or configure its BIOS to boot from its network interface using PXE. At the boot prompt, hit Enter to boot the default Fedora installation image. If an error occurs, the system boots in its normal configuration, such as a local hard disk.

Linux Create A Bootable USB Pen

You need to format your USP pen device as Win FAT32. Once formatted type the following commands to make it bootable.

Our Device Names

  1. USB Pen Device Name : /dev/sdb1
  2. DVD Mount : /media/cdrom0
  3. USB Mount Point : /media/usb
  4. USB File System : Win FAT32
  5. ISO or DVD Image : Fedora / CentOS / RHEL
To find information about your devices and current partitions run:
# dmesg | less
# dmesg | egrep -i 'cd|dvd'
# fdisk -l

Use the first command to identify the USB device name.

Mount CD/DVD ISO or DVD ITSELF

Type the following command to mount Fedora 12 iso image:
# mount Fedora-12-x86_64-netinst.iso -o loop /media/cdrom0/
# DVD=/media/cdrom0
# ls -l $DVD

Sample outputs:
total 6
dr-xr-xr-x 3 root root 2048 2009-11-09 05:37 EFI
drwxr-sr-x 3 root  499 2048 2009-11-09 05:37 images
drwxr-sr-x 2 root  499 2048 2009-11-09 05:36 isolinux
You need to use files stored in isolinux directory to create a bootable usb pen.

Format Usb

Create the fdisk partition:
# fdisk /dev/sdb
You need to create only 1 partition. Next format the partition:
# USB=/media/usb
# mkdosfs /dev/sdb1

Finally mount the partition:
# mkdir -p /media/usb
# mount /dev/sdb1 /media/usb
# USB=/media/usb

Copy Required Files

Type the following commands:
# cp -av $DVD/isolinux/* $USB
# cd $USB
# rm isolinux.bin boot.cat TRANS.TBL
# mv isolinux.cfg syslinux.cfg

Also copy the installer's initial RAM disk $DVD/images/pxeboot/initrd.img (for CentOS / RHEL Linux use $DVD/RedHat/images/pxeboot/initrd.img file) CD/DVD onto the usb drive:
# cp -v $DVD/images/pxeboot/initrd.img $USB

Unmount the USB drive

# umount /dev/sdb1

Make the USB Bootable

Type the following command to make the USB drive bootable
# syslinux /dev/sdb1
# mount /dev/sdb1 $USB

syslinux is a boot loader for the Linux operating system which operates off an MS-DOS/Windows FAT filesystem.

Install Grub

Type the following command to install GRUB on the USB device:
# grub-install --root-directory=$USB /dev/sdb
Create grub.conf:
# cd $USB
# mkdir -p boot/grub

Edit the grub.conf file
default=0
timeout=5
root (hd1,0)
title Fedora Linux
kernel /vmlinuz
initrd /initrd.img
Finally, unmount the USB pen drive, enter:
# umount /dev/sdb1
Your USB pen is ready and should be bootable from the USB device. This can be used to install Fedora or CentOS or RHEL. You can also copy other required tools (such as sniffers or data recovery tools) on this pen. This is left as exercise for the reader.

Unetbootin Installer of Linux/BSD Distributions (GUI Tools)

If command line options are too complicated to follow. Try UNetbootin, which allows you to create bootable Live USB drives for a variety of Linux distributions from Windows or Linux, without requiring you to burn a CD. To install to a partition or USB drive type the following command:
$ sudo apt-get install unetbootin

Detect and Configure / Install Modem on UBUNTU

     

To find out what kind of software modem you are using, go to linmodems.org, read the page, and download the scanModem tool (which will only recognize PCI and USB modems, not ISA modems). Copy it to your desktop in your Ubuntu machine, then open a command line and enter:


  • $ cd ~/Desktop
     $ gunzip scanModem.gz
     $ chmod +x scanModem
     $ ./scanModem
     $ gedit Modem/ModemData.txt


The program gunzip will decompress the file, chmod will mark it as executable, and ./scanModem will run it. If it tells you to do something as root by issuing su - root, instead just enter the commands it wants following a "sudo", e.g. $ sudo modprobe snd-intel8x0m. scanModem will scan your modem and tell you what it is and how to configure it. It will not configure it for you. But after running, you will see a number of new folders, including a Modem folder. Read 1stRead.txt and ModemData.txt in there, and see if you modem was recognized. This is admittedly not a straight-forward read and might need some more reading around on above mentioned page to find out which drivers your modem needs. Then scan through the following sections to find out about the easiest way to install that driver under Ubuntu.
Note: For many of the following drivers, you will need to enable the universe and or the multiverse repositories. See AddingRepositoriesHowto. This requires you to have working network connection. You can also search for packages to download in another system and transfer to your Ubuntu installation at http://packages.ubuntu.com/ . Be careful with the dependencies... Check out this forum post for another way to get packages using the LiveCD on another system with network connection and a CD burner: http://www.ubuntuforums.org/showpost.php?p=893732&postcount=6
Now that you know what modem you have, please return to DialupModemHowto to continue.

install Ubuntu on a USB device

How to install Ubuntu Linux from USB Stick posted on this site a while ago, and found it to be quite some work to get Ubuntu working on a USB stick. Besides, having to prepare your USB device, creating a separate partition on it which will be more or less “useless” after the installation, giving up 750MB of space?

There had to be a better way.
Together with a colleague of mine, I decided to figure out whether there could be an easier way to install Ubuntu on a USB device.
I found a way of doing it in a much simpler way… without creating the separate partition to store the LiveCD:

  1. Insert the LiveCD into your computer;
  2. Connect your USB device;
  3. Boot your computer from the liveCD;
  4. Once Ubuntu is started, go to System - Administration - Partition Manager
    This will open the Partion Editor. Select your USB device and delete all partitions on it. Click Apply and exit Partition Editor;
  5. Double Click the Install Icon. This will start the Installer;
  6. The Welcome Screen is shown. Choose your language and click Forward;
  7. Select your Time Zone and click Forward;
  8. Choose your Keyboard Layout and click Forward;
  9. The partitioner will be started, and you will be given the choice where to install Ubuntu. Choose Guided - Use entire disk, selecting your USB device (this will most likely be /dev/sdb, don’t choose /dev/sdb1!);
  10. The next sceen you will give your username/password information. Provide the required info and hit Forward;
  11. If there is anything to migrate from other installations on your computer (most likely not), do whatever you want, and click Forward;
  12. The next screen is important - It is titled: “Ready to Install”. Be careful here: before clicking on Forward, make sure you click on the “Advanced” Button!
    This will open a new screen, giving you the option whether and where to install the bootloader. Select your USB device (in my case it was /dev/sdb) to install the bootloader to;
    Exit this screen and click on Forward in the “Ready to Install” screen, which will be shown;
  13. The installation will be started now. Just be patient, grab a cup of coffee and come back 15 minutes later, your installation will be more or less finished by then.
So you have finished the installation. However, when you will be restarting your system from USB, you will find out that the partition you just installed Ubuntu to cannot be mounted.
Here comes the trick:
  1. Once the installation is finished, reboot your PC (this is the safest) from your LiveCD, with your USB device connected;
  2. Once started, open up a terminal (Applications - Accessories - Terminal);
  3. In the Terminal, type: sudo -i (which will give you root privileges, so be careful from now on!);
  4. Change directories to /media/disk/boot/grub - This will take you to the “/boot/grub” directory on the USB device;
  5. open menu.lst with vi (make a backup first!)
  6. Go to line 130 (or somewhere in that area).
    You will find a line looking like:
    ## ## End Default options ##
    And underneath it you will find three entries pointing to your Ubuntu you just installed:
    title         Ubuntu 8.04, kernel 2.6.24-16-generic
    root        (hd1,0)
    kernel     /boot/vmlinuz………
    initrd       /boot/initrd…….
    quiet
    (the above 5 lines repeat 3 times with slight differences)
  7. The magic trick is to change (hd1,0) into (hd0,0) for all these three entries.
    Why? Booting from USB device makes your USB device hd0, in stead of hd1 at time of installation.
  8. Search for the line starting with “# groot=(hd1,0)” and change (hd1,0) to (hd0,0) - Don’t delete the # at te beginning of this line!
  9. Once you did this, you can optionally remove the remaining of the file
    (everything underneath ### END DEBIAN AUTOMATIC KERNELS LIST);
  10. Save the file, make sure it is owned by root:ubuntu (chgrp ubuntu menu.* will do)
  11. Edit device.map (in the same directory) and change the mapping of hd0 to /dev/sdb.
  12. Reboot your machine, from USB, choose the Ubuntu installation from the Boot Loader and you are one happy person.
I guess that is it. If I missed something, please comment.

How to set up RTL8101 Ethernet Driver in RHEL5

it is a enthernet driver required when u have installed RHEL5 into your machine, if your LAN is working proprely ...then no problem if not working follow these steps care fully,first you need to know is what driver you have in your syytem
[edit]
knowing drivers

#lspci

will give u over idea about wht u r looking for...


in the bottom of the output u will find wht driver u have.... Ex:06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E PCI Express Fast Ethernet controller (rev 01)

its very simple the way is you need to download RTL8101E from realtek web-site here is the link here

[step 1:]
$su -
#tar -xvf

[step 2:]
go to extracted folder
#make clean modules
#make install
#depmod -a
#insmod ./src/r8101.ko (or r8101.o for kernel 2.4.x)
#reboot

after rebooting the system your system able to connect to internet through LAN,if not type this command in terminal

#/sbin/services network restart

How to install a Network card in linux


There are different ways of installing a network card in linux - and that too depending on the linux distribution that you are using. I will explain each one of these methods here.
1) The Manual method
First open the computer case and insert the network card into an empty PCI slot. Then boot up your machine to load linux. In linux login as root and then navigate to the directory /lib/modules/kernel_version_number/net/ . Here you will find the modules supported by your system. Assuming that you have a 3Com ethernet card, in which case, the module name is 3c59x , you have to add this in the /etc/modules.conf file to let the machine detect the card each time the machine boots.
#File: /etc/modules.conf
alias eth0 3c59x
Note: If you have only one network card, it is known by the name eth0, the succeeding network cards in your computer go by the name eth1, eth2 ... and so on.
Now you have to load the module into the kernel.
root# /sbin/insmod -v 3c59x
Next configure an IP address for the network card using ifconfig or netconfig or any other method if your machine gets its IP address from a DHCP server. Eg:
root# ifconfig eth0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
2) The Easy way
RedHat/Fedora distributions of linux ships with Kudzu a device detection program which runs during systems initialization (/etc/rc.d/init.d/kudzu). This can detect a newly installed NIC and load the appropriate driver. Then use the program /usr/sbin/netconfig to configure the IP address and network settings. The configuration will be stored so that it will be utilized upon system boot.

Creating a Partition Size Larger than 2TB


Linux desktop user generally uses small hard disk and partition, but on server you need a large partition. For example, you cannot create 4TB partition size (RAID based) using fdisk command. It will not allow you to create a partition that is greater than 2TB. In this tutorial, you will learn more about creating Linux filesystems greater than 2 Terabytes to support enterprise grade operation under any Linux distribution.
To solve this problem use GNU parted command with GPT. It supports Intel EFI/GPT partition tables. Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the outdated PC BIOS, one of the few remaining relics of the original IBM PC. EFI uses GPT where BIOS uses a Master Boot Record (MBR).

(Diagram illustrating the layout of the GUID Partition Table scheme. Each logical block (LBA) is 512 bytes in size. LBA addresses that are negative indicate position from the end of the volume, with −1 being the last addressable block. Imaged Credit Wikipedia)

GPT Kernel Support

EFI GUID Partition support works on both 32bit and 64bit platforms. You must include GPT support in kernel in order to use GPT. If you don't include GPT support in Linux kernelt, after rebooting the server, the file system will no longer be mountable or the GPT table will get corrupted. By default Redhat Enterprise Linux / CentOS comes with GPT kernel support. However, if you are using Debian or Ubuntu Linux, you need to recompile the kernel. Set CONFIG_EFI_PARTITION to y to compile this feature.
File Systems
   Partition Types
     [*] Advanced partition selection
     [*] EFI GUID Partition support (NEW)
....

Linux create 3TB partition size

One of my clients has Raid 5 Array -7x500GB hard disks to store large data. To create partition start GNU parted as follows:
# parted /dev/sdx
Output:
GNU Parted 1.8.1
Using /dev/sdx
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Creates a new GPT disklabel i.e. partition table:
mklabel gpt
Create 3TB partition size:
mkpart primary 0 3001G
Quit and save the changes:
quit
Use mkfs to format file system:
# mkfs.ext3 /dev/sdx1
Note: Replace /dev/sdx with actual RAID or disk name or block Ethernet device such as /dev/etherd/e0.0 . Don't forget to update /etc/fstab, if necessary.

Further readings: