Monday, December 27, 2010

To Create a New logical volume in Linux

Execute the below command to create the new logical volume “netcoolvol01” from “systemvg” Volume group. Please use “vgs” & “lvs” command to know the free space in a volume group


===========================================

lvcreate -L10000 -n netcoolvol01 systemvg


Execute the below command to format the new file system

===========================================

mkfs -t ext3 /dev/mapper/systemvg-netcoolvol01

Mount the new file system
============================================

mount /dev/mapper/systemvg-netcoolvol01 /mnt

[root@dbserver /]# df –h /mnt

/dev/mapper/systemvg-netcoolvol01 9.7G 55M 9.1G 1% /mnt

[root@dbserver /]#

How to extend a Logical volume in Linux (LVM)

Execute the lvextend and resize2fs commands to increase the size of a logical volume. Some Linux version we need to use ext2online command instead of resize2fs



lvextend -L + G

resize2fs

ext2online

Eg:

dbserver:/etc # lvextend -L +2G /dev/mapper/sysvg-var

Extending logical volume var to 5.00 GB

Logical volume var successfully resized


dbserver:/etc # resize2fs /dev/mapper/sysvg-var

resize2fs 1.41.1 (01-Sep-2008)

Filesystem at /dev/mapper/sysvg-var is mounted on /var; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 1

Performing an on-line resize of /dev/mapper/sysvg-var to 1310720 (4k) blocks.

The filesystem on /dev/mapper/sysvg-var is now 1310720 blocks long.



dbserver 1:/etc # df -h /var

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/sysvg-var

5.0G 1.2G 3.6G 24% /var

dbserver:/etc #

Change Time Zone in Linux

Check the /usr/share/zoneinfo directory. Hopefully, it will contain a UTC or


GMT file timezone file. You can then simply link that file to /etc/localtime:



# cp /etc/localtime /etc/localtime.backup ;ln -s /etc/localtime /usr/share/zoneinfo/UTC /etc/localtime



Are you sure you don't have a TZ variable set in your user ENV? Regardless of

system time zone, the TZ variable will over-ride that on a per user basis.



# date

Mon Apr 19 19:39:04 CEST 2004

# mv /etc/localtime /etc/localtime.save

# date

Mon Apr 19 17:39:11 UTC 2004

Change Date and Time in Linux

Please execute the “date” command in order to see the current time and date settings

[root@racnode-2 ~]# date

Thu Aug 14 17:49:04 BDT 2008

So current time is month 8 day 17, year 2008, time 17:49:04.



Now to change only time to 11:51.30 execute



[root@racnode-2 ~]# date 08141151.30

Thu Aug 14 11:51:30 BDT 2008



[root@racnode-2 ~]# date

Thu Aug 14 11:51:32 BDT 2008



Note that setting date in this way will not cause the date to remain after a reboot. The date command sets the Linux system clock which is separate from the hardware clock.

We can check linux hardware clock by,



[root@racnode-2 ~]# hwclock

Thu 14 Aug 2008 05:57:01 PM BDT -0.788181 seconds



To make date setting persistent update the hardware clock with the date from the Linux system clock.



[root@racnode-2 ~]# /sbin/hwclock --systohc

If you are using universal time then use,

hwclock --utc --systohc



An alternative way is if you want to set the hardware(BIOS) clock so the system will keep the time when it reboots using,



clock -w

or

setclock

after changing date and time by date command.



To set date and time we can also use,



# date -s "2 OCT 2008 8:00:00"



If you wanted to change the year as well, for example to change year to 2007 of 30th April time 11:16pm you could type



#date 043023162007



To change only the time to 10:10 am you also can use,



#date -s 10:10



Using NTP (Network Time Protocol)



This is simple process. Just adding the time server to /etc/ntp.conf and to /etc/ntp/step-tickers Here I use time server as 192.168.1.91.



#vi /etc/ntp.conf

server 192.168.1.91

#vi /etc/ntp/step-tickers

192.168.1.91

Then of course make sure that ntp will start at boot time by,

chkconfig --level 2345 ntpd on

chkconfig --list ntpd



And let's start the service now by,

service ntpd start



It will display output as

ntpd: Synchronizing with time server: [ OK ]

Starting ntpd: [ OK ]

Posted by Arju at 10:53 PM

Labels: How to change date and time on Linux using hand and NTP

0 comments: