Wednesday, 9 September 2015

Add a disk and create a mount point in linux

How to create mount point in Oracle Enterprise Linux

This section shows you that how to create mount point for a newly attached hard disk in OELinux/Linux

1. Check the file system

[root@chromepro ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3263    10747485    5  Extended
/dev/sda5            1926        3263    10747453+  8e  Linux LVM

2. Add a new hard disk

Now add a new hard disk or a disk in system. (Ignore this if you already added & go to Step:4)

3. restart the system to scan the newly added disk to add
                       
Restart the system to scan the new hard disk or a disk by OS level. (Ignore this if you already added & go to Step:4)

[root@chromepro ~]# init 6

Note : If you don’t want to restart the System, enter following command..

echo " - - - " >/sys/class/scsi_host/host0/scan

4. Check the new disk is added or not

[root@chromepro ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3263    10747485    5  Extended
/dev/sda5            1926        3263    10747453+  8e  Linux LVM
                                                                 
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

[root@chromepro ~]# cat /proc/partitions

major minor  #blocks  name

   8     0   26214400 sda
   8     1     104391 sda1
   8     2   10241437 sda2
   8     3    5116702 sda3
   8     4          1 sda4
   8     5   10747453 sda5
   8    16   10485760 sdb
 253     0    8486912 dm-0
 253     1    2228224 dm-1

5. Create Partition for new disk

[root@chromepro ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

6. Check it is successfully partitioned

[root@chromepro ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3263    10747485    5  Extended
/dev/sda5            1926        3263    10747453+  8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux

7. Check file is created or not in “/dev” location

[root@chromepro ~]# ls /dev/sd*

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sda5  /dev/sdb  /dev/sdb1

8. Format the disk as per linux file system with block allocation

[root@chromepro ~]# mkfs.ext3 -b 4096 /dev/sdb

mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

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

9. Enter in “/etc/fstab” for automatic mount

[root@chromepro ~]# cat /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/u02              /u02                    ext3    defaults        1 2
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0

[root@chromepro ~]# vi /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/u02              /u02                    ext3    defaults        1 2
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb                /u03                    ext3    defaults        1 1

[root@chromepro ~]# cat /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/u02              /u02                    ext3    defaults        1 2
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb                /u03                    ext3    defaults        1 1

10. Make directory for mount point

[root@chromepro ~]# mkdir -p /u03

11. Mount the new file to “/u03”

[root@chromepro ~]# mount /dev/sdb /u03

12. Check the mount point is working or not

[root@chromepro ~]# df -hk

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       8220860   3276888   4519628  43% /
/dev/sda3              4956316   3916068    784416  84% /u02
/dev/sda2              9920624   5827120   3581436  62% /u01
/dev/sda1               101086     12145     83722  13% /boot
tmpfs                   556160         0    556160   0% /dev/shm
/dev/sdb              10321208    154236   9642684   2% /u03


No comments:

Post a Comment

Thanks...