Archive for July, 2009

SBDavid

Install VNC in VPS server with Gnome

Install VNC in VPS server with Gnome

VNC, or Virtual Networked Computing, is a way of controlling a remote server just as though you are sitting in front of it. Like RDP remote desktop connection in Windows we have VNC for Linux. You can connect using a VNC client to a remote server system running the VNC server, then an image of the remote desktop is transmitted to your local computer and you can see and control the desktop.

Usually Linux servers are not installed with graphical interface(only text mode). However, for VNC to gain access of the user friendly interface like windows, Gnome or KDE have to be installed.

Note : Please make sure you have at least 128MB of unused ram to allocate for VNC. Also, YUM and its required libraries are installed (python, sqlite, etc) on the server.

Installation :

1. Login as root to your server and run the following:

yum -y groupinstall gnome (”yum -y groupinstall kde” for KDE )
yum -y install vnc vnc-server firefox x11-xorg

This will install Gnome and neccesary applications (VNC, FireFox, X11 libraries, etc) in the server.

2. Start up the vnc server with the ‘vncserver’ command and it will prompt you to enter a desired password. Just type what you want to use in and then confirm it. (if running as root, it will be in /.vnc or /root/.vnc or /home/root/.vnc)

3. Now, you’ll see VNC server is running by executing:

ps -ef |grep vncserver

Now kill the VNC processes,

pkill -9 vnc
rm -rf /tmp/.X1*

4. Edit xstartup file

vi /root/.vnc/ xstartup

Replace the last line(usually ‘twm & ‘ ) with ‘gnome-session & ‘ (without quotes of course). you can use ’startkde &’ for KDE

This tells VNC to startup GNOME instead of the default window manager, twm (or whatever the last line was).

5. Create users to VNCServer as follows,

Edit the lines below in the file /etc/sysconfig/vncservers and add a user (user should be a valid user created on your server and not just simply a name).

VNCSERVERS=”1:root”
VNCSERVERS=”2:newuser”

You can change the password of the VNCServer as :

vncpasswd homedir/.vnc/passwd

If you want to change the password for the VNC user root, run the following
command from konsole,

vncpasswd /root/.vnc/passwd

6. Go ahead and execute the command ‘vncserver’ again, and VNC will startup, using the password specified earlier and create a default VNC instance on VNC port 1.

7. Start up your RealVNC client on your PC, and put in :1, and it should ask for your password that you put in earlier.

Disable journaling in ext3 file system

We know that EXT3 file system is nothing but EXT2 + a e. This allows faster FSCK process and avoids metadata corruption.

We can disable journaling (i.e convert EXT3 to EXT2) using tune2fs command.

tune2fs -O^has_journal /dev/xdy

Now the journaling is removed from /dev/xdy partition. The file system for this partition is know EXT2 rather than EXT3.

This is normally used when you want to re-size a partition.

If you want to convert it back to EXT3, use the following command:

tune2fs -j /dev/xdy

Note: The partition should be un-mounted before converting the file-systems. For converting EXT2 to EXT3 you can also have the partition re-mounted as read-only too, but the former is safer.

SBDavid

Using tune2fs to free up disk space.

Using tune2fs to free up disk space.

We usually encounter issues, where a partition becomes 100% full, say if you get / as 100%, you even can’t edit the fstab entries.

In such instance, you can use the tune2fs command to free up disk space, since for every file system under Unix, approximately 5% of disk space is reserved for the “root” user.

To check this, take the ratio of Block count to the Reserved block count. (these values can be obtained by listing the information in the specified file system’s superblock.

tune2fs -l /dev/device (it should be a partition actually)

To free up all the reserved space use,

tune2fs -m 0 /dev/device, instead of 0, you can specify 1 or 2.

The only risk in setting zero reserved blocks is that, other Unix users can fill the file system to 100%.

SBDavid

ISCSI mount on boot

ISCSI mount on boot

Steps to mount ISCSI on boot:

You can see the ISCSI drive while issuing “fdisk -l”. Let it be /dev/sdb1

Consider that you want it to mount over /vz partition.

step 1) e2label /dev/sdb1 /vz

step 2) In /etc/fstab, add the following entry.

LABEL=/vz /vz ext3 _netdev 0 0

step 3) chkconfig –level 3 netfs on

step 4) Reboot

Note:
ISCSI drives should be mounted with “_netdev” mount option.

“netfs” is the daemon which would mount the filesystems with “_netdev” mount option.

How to Backup MBR - Master Boot Record

The MBR (master boot record) is located at cylinder 0, head 0, sector 1. It’s the very first sector of the hard drive and it is 512 bytes in size. When the BIOS boots your machine it looks in the MBR for information on your partitions and the initial boot loader. The MBR contains a partition table and boot code. The boot code executes and then transfers the process to the bootloader program on your active(bootable) partition.

We can take the backup of MBR either to a floppy disk or to a CDROM.

1. Backup to a floppy:

dd if=/dev/hda of=/dev/fd0 bs=512 count=1

2. Backup to CDR:

First, create the MBR backup to a file on your hard drive.

dd if=/dev/hda of=mbr.bak bs=512 count=1

Now, burn the file you just created to CDR.

« Prev - Next »