Archive for the 'fedora' Category

Desktop Linux distributions popularity 2007

Which Linux distros do we use on our home or office desktop system(s)?

2007-distributions-sm.jpg

More information is here.

Advertisements

Secure shell (ssh) session timeout

I’ve noticed that when I keep ssh sessions that I opened before untouched for some period of time (like 30 minutes) they become frozen and as a result I have to close ssh terminal and start a new connection. To prevent such situation I found several tips:

1) Start some utility updating the screen before leaving ssh session untouched. I usually use watch -n 1 ‘date’ that shows current date every second. Other simple way is to send icmp requests to some host, e.g. ping google.com.

2) Increase ssh session idle time by

echo “7200” > /proc/sys/net/ipv4/tcp_keepalive_time

I’ve checked these tips with Fedora Core, CentOS, Debian and Ubuntu but I’m completely sure that it applicable also for other Linux distributions. First tip (ping) can be used in Unix also.

 

Fedora Core remote installation howto

Sometimes it happens that it’s necessary to install Fedora Core onto server you have not physical access to and there is to luck to find any person who can do it for you there. Some other distributions like Debian provides remote ssh installation while Fedora (as well as Red Hat and CentOS) allows to install it over telnet from different computer over the network.

To get it done it’s enough to ask somebody who has physical access to server to boot up with Fedora Core installation compact disk and type one command. All the rest you can do by yourselves from any PC located at the same network.

When Fedora CD is booted above mentioned person will see at the following screen:

Fedora Core Installation menu

Ask him (or her) to type command at “boot:” prompt (in one line):

text telnet ip=[ip.address] netmask=[netmask] gateway=[gateway.address] ksdevice=[ethernet.device]

For example:

text telnet ip=192.168.0.123 netmask=255.255.255.0 gateway=192.168.0.1 ksdevice=/dev/eth1

Where IP address 192.168.0.123/24 will be assigned to eth1 NIC of server you’re going to install. ksdevice refers to your Ethernet network card (NIC) designation (if there only one NIC just omit ksdevice).

After it’s done you can connect to server via telnet command, for example:

telnet 192.168.0.123

and proceed installation. Please note that it would take some time before you can login as Fedora’s anaconda installer will be loading telnet server. During remote installation it’s impossible to switch consoles. Make sure you’ve set proper settings for your NIC(s) as after reboot previous IP settings will be lost. After installation is finished and server is rebooted you can login to fresh Fedora via ssh (with root login).

Google calendar and Linux Evolution sync

As we know Evolution is a default mail client program of Gnome Desktop manager. Here is a good article about how to sync Google Calendar with Evolution one.

Fully automated Fedora Linux installation manual (create custom installation cd)

Few will deny that everybody who installs Fedora or other Linux distributions on a regular basis will realize one day that the installation can be done without user intervention. There is no doubts that it could at least save installer’s time.

Let me describe how to create custom CD for fully automated installation of Fedora Core 5 (this manual is also is applicable for other versions of Fedora, RedHat and CentOS).

First of all copy contents of Fedora Core 5 FIRST installation compact disc to some directory. As Fedora Linux uses Anaconda installer and supports ‘kickstart’ installation method, we’ll create kickstart file (simply text file) with all needed installation options and put it to new Fedora installation CD. Create text file named as ks.conf (just for example) at the directory you’ve extracted CD and fill it up with the following contents (my example):

lang en_US
cdrom
keyboard us
install
reboot
timezone Europe/Kiev
selinux –disabled
auth –enablemd5 –useshadow
firewall –disabled
rootpw your_root_password
network –bootproto=static –device=eth0 –ip=192.168.0.1 –netmask=255.255.255.0 –hostname=viper_tes_fc5 –nodns
clearpart –all
part swap –recommended –ondisk=hda
part / –fstype ext3 –size 1 –grow –ondisk hda
bootloader –location=mbr
%packages
@ Core
-acpid
-anacron
-apmd
-cpuspeed
-aspell-en
-aspell
-at
-bluez-utils
-dhcpv6_client
-finger
-gpm
-irda-utils
-smartmontools
-ypbind
-nfs-utils
%post
/sbin/chkconfig sendmail off

This file assumes that your server has single IDE hard drive and one network interface card. In case of SATA or SCSI hdd just replace ‘hda’ with ‘sda’.

Please find full description of kickstart options here.

There are two ways to start kickstart installation when booting from Fedora installation CD: 1) type ks=cdrom:/ks.conf just after boot: prompt and press enter; 2) make kickstart installation method default (in this case installation will be performed automatically just since you’ve inserted disk to cdrom).

To apply first way it’s enough to assemble new Fedora installation cd and boot with it. To follow second way it’s necessary to modify file isolinux.cfg at isolinux directory of first Fedora Core 5 installation CD. To edit isolinux.cfg go to the directory you’ve copied Fedora installaion CD contents to, then change dir to isolinux folder and open file isolinux.cfg for writing. You’ll see something like this:

default linux
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append –

To make kickstart installation method default just replace line ‘
default linux‘ with ‘default kickstart‘ and add these lines to the end of the file:

label kickstart
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/ks.conf

You may also replace 600 timeout with timeout you like (in ms). After changes are done save file.

The last step is to assemble new Fedora boot CD. In case you’re running Windows you may use IsoMagic or some other programs to edit ISO images and create custom bootable CDs.

As I’m not Windows user (wow!) I’ll describe how to assemble new bootable Fedora installation CD with Ubuntu (or ANY other Linux distribution):

1) go to directory you’ve copied Fedora Core 5 CD files to

2) execute command:

sudo mkisofs -o /tmp/new.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V “Custom Fedora” .

This will create new ISO CD image at /tmp/new.iso.

After ISO is ready you can use any CD burning tools like cdrecord, k3b, gnome-baker to burn it onto compact disc.

At this point procedure is finished and you can test custom Fedora Core 5 installation CD by booting with it. BACKUP YOUR DATA BEFORE BOOTING with just created Fedora installation CD as the installation procedure is automated and HDD formatted without user confirmation.

If everything goes well after finishing installation you will get Fedora installed with hostname ‘viper_tes_fc5’ set and IP address 192.168.0.1/255.255.255.0 assigned to server’s network interface card.

Hope it helps anybody. Please feel free to contact me and I’ll help. Good luck!

How to create custom linux ISO image?

It’s rather trivial task to make some changes into already burned installation or live CD. It may be performed to add some files to this CD or edit files on it. In any case it’s impossible to loop mount .iso file and then save it as iso9660 filesystem is read-only.

So, just mount your CD or iso image to some directory by commands:

sudo mkdir /mnt/image

sudo mount /dev/cdrom /mnt/image

or

sudo mount /path/to/your.iso /mnt/image -o loop

then copy it’s contents to some directory:

mkdir /tmp/newiso

cp -r /mnt/image /tmp/newiso

After this you can modify any files in /tmp/newiso, add files, delete them. After modifications are done, create new ISO image to be burned onto CD (or kept somewhere for a rainy day):

cd /tmp/newiso

and

sudo mkisofs -o /tmp/new.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V “new iso name” .

After mkisofs is finished new ISO file will be created at /tmp directory.
It works in any Linux distributions like Ubuntu, Debian or Fedora.

Moving Linux to remote server (over ssh via third server)

Source: server running rather obsolete Fedora Core 1 with Apache, sendmail, ftp and other stuff.
Target: any Linux server with at least one hard drive of appropriate disk space installed (in this case target server was running Knoppix).
Third server: any ssh running system.

First of all it’s necessary to get all servers to be accessible to each other via ssh. Read your distribution’s manual to find out how to achieve it.

There are several possible ways to move Linux to another server by means of using dump/restore utilities over ssh. I’ve chosen this one: I’ve saved source server’s filesystem backup to third server over ssh and then restored this backup to target server (again over ssh).

To do this I’ve installed dump 0.4b41 onto source server and performed the following commands to save it’s /boot and / filesystems backups to third server (both in one line):

dump -0uan -f – /boot | ssh -c aes256-cbc @ dd of=/home/artemn/backup/dump/dump-boot-l0.bak

and

dump -0uan -f – / | ssh -c aes256-cbc @ dd of=/home/artemn/backup/dump/dump-root-l0.bak

It took several hours to transmit 20Gb over Internet in my case. If you’re performing these operations remotely I recommend to use utility screen to be sure that transmitting won’t be stopped when ssh session to source server is closed. To use it just login to source server over ssh and type screen and then dump command with necessary agruments (see below). In case you’ve been disconnected just ssh again and restore screen session by command screen -r.

You can control above mentioned dump command activity by watching file size of dump-root-l0.bak and dump-boot-l0.bak files at third server.

After dump is finished you can check backup at third server by performing restore -i -f dump-root-l0.bak and walking through directories in backup file (use ls command). For further information read restore manual (interactive restore section): man restore.

Then login to target server and partake hard disk in the same way as it’s done at source server. In my case I’ve created three partitions /dev/sda1 for /boot, /dev/sda2 for / and /dev/sda3 for swap. Target server can be running Live CD like Knoppix and have only one hardware drive.

When partitioning is done create filesystems at every partition:

mkfs -t ext2 /dev/sda1

mkfs -t ext2 /dev/sda2

mkswap /dev/sda3

Then set volume labels to just created filesystems by commands:

tune2fs -L “/boot” /dev/sda1

and

tune2fs -L “/” /dev/sda2

Labels should be the same as at source server (you can see them by executing tune2fs -l /dev/sda1 and tune2fs -l /dev/sda2 at source server). Sometimes it’s also necessary to set up volume label for swap filesystem.

When it’s done mount created filesystems by commands:

mount /dev/sda1 /mnt/sda1

and

mount /dev/sda2 /mnt/sda2

(be sure that /mnt/sda1 and /mnt/sda2 are created).

To restore filesystem from backed up copy, ‘cd‘ to destination directory and restore data by commands:

cd /mnt/sda1

and

ssh @ “cat /home/artemn/backup/dump/dump-boot-l0.bak” | restore -r -f –

then

cd /mnt/sda2

and

ssh @ “cat /home/artemn/backup/dump/dump-root-l0.bak” | restore -r -f –

In case of success /mnt/sda1 and /mnt/sda2 will contain the same files at /boot and / directories at source server.

When filesystems restoration is done we should install boot loader onto hard drive of target sever: start grub console by typing grub and then type root (hd0, 0), then setup (hd0). After this boot loader will be installed and target server can be booted from hard disk.

Note: be sure that dump and restore commands run at source and target servers are of same versions as it causes problems sometimes. I’ve used 0.4b41 at Fedora Core 1 (source) and Knoppix (target server).

Another note: I’ve spent a day to solve the problem with kernel panic when booting into target server’s hard disk. The problem was in volume labels. So don’t forget to set them.

Hope it helps somebody! Good luck, mates!


Archive