Thursday, August 23, 2012

Managing LVM part 2


scan utilities

pvscan

for showing up the physical volumes,suppose pvcreate didn't work,in that case pvscan can show you the physical volumes

vgscan

for showing up the volume groups

lvscan for searching the logical volumes

lvrename volumegroup001 lvol0 logvol0(new name)

is for renaming logical groups

to add another partition from a different hard disk 

say /dev/sdb

create a partition there by fdisk /dev/sdb

n and then specify it's size,type to t to set it LVM(code is 8e)

if there is an error in writing the partition table try rebooting,if still there is an error try pvcreate the partition and then write the partition table

now to add this partition to the existing volume group

we have to use the vgextend command

vgextend volumegroup001 /dev/sdb2

now as we added another partition from another hard drive the logical volume size should be increased to utilize the extra space that we added,previuosly we set the logical volume as 2.5 GB usable,to extend it we have to use the lvextend command

lvextend /dev/volumegroup001/logvol0 -L +1G(we want to increase by say 1 GB)

but df -h or df -h lvm1/ will show as 2.5 GB

if we unmount the logical volume from lvm1 and then mount again it will still ahow as 2.5 GB

so it basically means although we resized the logical volume at the filesystem the mount point is not increased so we have to use an utility resize

To resize the logical volume so that we can use the extra space

resize2fs resize ext2 and ext3 filesystem

resize2fs /dev/volumegroup001/logvol0 3G(will resize the filesystem to 3GB from 3.5 GB,but it supports only ext3 and not ext2)

now df -h will show lvm1 as 3.0 GB

wow resize2fs really helped me in online resizing

what a relief isn't it,haha.

now resize2fs only support online(that is when mounted) increment,it doesn't support online decrement,so we can not make the size of lvm1 from 3GB to 2.8G,it does not support values like 3.1G,we have to use 3100MB to make it work

so to shrink it we have to unmount first,that is called offline

umount lvm1/

now if I put command as 

resize2fs /dev/volumegroup001/logvol0 2800M

it will instruct me to first run 

e2fsck -f /dev/volumegroup001/logvol0 to prevent data loss,as we are shrinking,not extending,shrinking has the possibility of losing data

so we have to first run

e2fsck -f /dev/volumegroup001/logvol0

then we have to run

resize2fs /dev/volumegroup001/logvol0 2800M

then mount by

mount /dev/volumegroup001/logvol0 lvm1/

now df -h will show it as 2.8GB 







Some info about managing LVM in Debian 5


The hierarchy of LVM is


1.Physical volume(lowest layer)

2.Volume Groups

3.Logical Volume

Use fdisk to create partion in one or separate harddisk,make it's type LVM(8e),writing partition table might throw an error,in that case try pvcreate first then write the partition table

pvcreate /dev/hda1 /dev/hda2 /dev/hda4 to create Physical volumes

pvdisplay will show the physical volumes

vgcreate volumegroup001 /dev/hda1 /dev/hda2 /dev/hda5

lvcreate -L 2.5GB volgroup001

lvdisplay or

lvdisplay volumegroup001

find the the location of the logical volume from the output of the command lvdisplay

in my case it is

/dev/volumegroup001/lvol0

then

mkfs.ext3 /dev/volumegroup001/lvol0(to enable a journaling filesystem)

create a folder

mkdir souravlvm

mount /dev/volumegroup001/lvol0 souravlvm/ && echo $?

see the mounted folder by


df -h

put it in the /etc/fstab file to make it available after reboot

/dev/volumegroup001/lvol0 /home/sourav/souravlvm ext3 defaults 0 2

unmount it by umount souravlvm/

then run mount -a which will read the fstab entry and then if you do df -h you will see the logical volume mounted in souravlvm again

Install qbasic in Ubuntu 10.10



sudo apt-get install dosboxThis should install dosbox on your ubuntu desktop. 


http://www.4shared.com/file/0CfT8EWS/OLDDOS.html

Open your home directory and right-click the downloaded olddos.exe file. Open it with archive manager. Extract it to a new folder, I suggest QBasic.

Now in the terminal type:


dosbox


After "dosbox" opens type the following:


mount c /home/username/QBasic/
C:
QBASIC.EXE

Thursday, August 16, 2012

Some info about OSPF

OSPF uses hello protocol


In OSPF Hello messages are sent every 10(some people tune it,make it even 2 seconds) seconds on broadcast/point to point networks and every 30 seconds on NBMA(Non Broadcast Multi Access such as Frame Relay) Networks

Hello message contains information such as

Router ID(name of the router)

Hello and Dead Timers(how often they are saying and this has to match between the neighbours)

Network Mask(subnet mask and this has to match between the neighbours)

Area ID(the area they are in and this has to match between the neighbours)

Neighbours(they have to match)

Router Priority

DR/BDR IP Adress

Authentication Password(this has to match)

Brief Intro on Link State Protocols

Link State Routing protocols


Forms different relationship rather than sending broadcasts in a periodic interval

After the exchange of initial routing table ,routers send small event based updates


Example OSPF and IS-IS

Advantages of link state protocols

Much Faster to converge

No Routing Loops

Forces you to design your network correctly


Disadvantages of Link State Routing

Takes heavy resources on routers

Requires a solid network design

Technical Complexity

Distance vector protocols and their issue of looping

Distance vector Routing Protocols send entire table at specific intervals


Distance vector protols are simple to implement but they have looping issues,count down to infinity issue

There are 5 loop prevention mechanism in Cisco Routers

1.Maximum Distances(For RIP it is 16 hops,if any network is 16 hops away it's not considered anymore,)

2.Route Poisoning(advertise that the network is down immediately,they kill the network by sending the network a maximum hop count bigger than 16 so that the maximum distance law takes the network out)


3.Triggered Updates(send the update immediately rather than waiting 30 sec like RIP generally does,poison the route,and tell the neighbour device that the network is down,triggered idea should be avoided in an unstable network where interfaces are going up and down)

4.Split Horizon(tell routers do not send updates/advertisements in the same direction you recieved them)

5.Hold Down Timer(it won't believe any other updates about a particular route for a cirtain amount of time,180 sec is typical,works great in a situation where interfaces are going up and down)

Tuesday, August 14, 2012

Playing with swap


after creating a swap partion by by Gparted tool you need to turn swapping on that partition,

swapon /dev/sdb1

swapon -s will reveal all the swap partitions

instead of free -m you need to use the free command to see the total swap and it's usage

swapon -a enables swap from /etc/fstab

we need to update the /etc/fstab to make the newly created swap partition available after reboot

in nano ctrl+k for cut and ctrl+u for uncut and by this way you can copy the existing lvm based swap line and just replace the directory,ehich in my case is /dev/sdb1

swapoff /dev/sdb1 will release the swap on the device(device and file)

swapon -a will read the /etc/fstab again and the released swap will be activated again


to create a swap from shell

fdisk /dev/sdb 


N for creating disk

T for making it swap

W for writing the partitioning table

swapon /dev/sdb1

if not succesful then try using mkswap /dev/sdb1



allocation of swap from a file

dd if=/dev/zero of=/root/swapfile bs 1024 count=524288

mkswap /root/swapfile

swapon /root/swapfile

swapon -s will show the swap

to make this parmanent modify the /etc/fstab file

it will be like

/dev/mapper/debian5-swap_1  none swap sw 0   0
/dev/sdb1                   none swap sw 0   0
/root/swapfile              swap swap defaults 0   0


swapon -a will read the /etc/fstab and show the 3 swap

swapoff -a will disable every swap in /etc/fstab

swapon -a will enable the swap in/etc/fstab