What is difference between /dev/hda & /dev/sda?

May people wonder what is difference between /dev/hda & /dev/sda, here is simple post which explains the difference.

If you are using Linux, you must have noticed that on some systems command “df -h” shows /dev/hda whereas on some systems drives are labelled as /dev/sda, so what’s the difference between these two? Many people just wonder that there is no difference, actually the Linux names the drives according to their type.

If you have IDE/ATA/ drive, it’s named as /dev/hda

If you have SATA or SCSI drive it will named as /dev/sda

Read More

How to mount a new drive to Linux.

You have a got a new drive and you have to mount it as a backup drive ? How you would do it ? Here are the steps to mount a new drive to Linux as a backup drive.

Note: Be careful while doing this steps, and make sure you are using the drive names correct. One incorrect step will put you in trouble.

In my case the new drive is fdisk /dev/sdb, first of all I will have to create a new partition. You will need at least one partition for the drive to be mounted. You can use the command fdisk /dev/sdb

 

[root]# fdisk /dev/sdb
Command (m for help): m     (Enter the letter "m" to get list of commands)
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-9729, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-9729, default 9729):
Using default value 9729

Command (m for help): w    (Write and save partition table)

Partition has been added, now you will have to format that partition as ext3 or ext4. As per your choice.

[root]# mkfs -t ext3 /dev/hdb1
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2508352 inodes, 5016052 blocks
250802 blocks (5.00%) reserved for the super user
First data block=0
154 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Now you mount the partition.

[root]# mkdir /opt2

[root]# mount -t ext3 /dev/hdb1 /opt2

The above example shows the addition of a drive as one whole extended partition used to extend the storage space of the system. It was not created to hold additional operating systems as this would require a primary partition. Primary partitions can be used to extend the storage space of the system as well.

Open file /etc/fstab and put in the highlighted line.

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/hda2               swap                    swap    defaults        0 0
/dev/hdb1               /opt2                   ext3    defaults        1 2
/dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0

Read More

How to change Time-Zone in Linux

You many have forgot to setup the correct time-zone on Linux when you have installed it, or your host must have provided the server with the incorrect time-zone. Here is the post about how to change time-zone in Linux.

Change TimeZone Using /etc/localtime File

For this example, assume that your current timezone is EST as shown below. You would like to change this to IST time.

[root@justgeek ~]# date
Mon Jan 25 15:37:19 EST 2016
[root@justgeek ~]#

On some distributions (for example, CentOS), the timezone is controlled by /etc/localtime file.

Delete the current localtime file under /etc/ directory

[root@justgeek ~]# cd /etc

[root@justgeek /etc]# rm -fv localtime
removed localtime

All US timezones are located under under the /usr/share/zoneinfo/US directory.  For other country timezones, browse the /usr/share/zoneinfo directory 

Link the Indian timezone from the above Asia directory to the /etc/localtime directory as shown below.

[root@justgeek /etc]# ln -s /usr/share/zoneinfo/Asia/Calcutta localtime
[root@justgeek ~]# date
Tue Jan 26 02:16:14 IST 2016
[root@justgeek ~]#

Read More