a

SAINORA

HomeBlogsDisk Maintenance

Disk Maintenance

Adding a Disk in Linux

Step 1:
Create a Disk in VMware

Step 2 :
Start the Virtual Machine

Step 3 :

  Login as root and open a terminal window.
Use fdisk -l to list the hard drives.

 

[root@oraclehost ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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          650   5116702+  82  Linux swap / Solaris
/dev/sda3               651         1032 3068415   83  Linux
/dev/sda4        1033        2610  12675285    5  Extended
/dev/sda5        1033        2610  12675253+  83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

 

/dev/sdb is the new device that should be mounted. Create partitions in /dev/sdb as given below

[root@oraclehost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End  Blocks   Id  System
/dev/sdb1               1           261   2096451   83  Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@oraclehost ~]#

 

Create a filesystem for the disk (ext3)

[root@oraclehost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

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

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@oraclehost ~]#

Then mount the disk to /u01
[root@oraclehost ~]# mkdir /u01
[root@oraclehost ~]# mount -t ext3 /dev/sdb1 /u01
[root@oraclehost ~]# df -h
Filesystem              Size  Used Avail Use% Mounted on
/dev/sda5               12G  3.5G  7.7G  32% /
/dev/sda3               2.9G   72M  2.7G   3% /tmp
/dev/sda1               99M   12M   83M  12% /boot
tmpfs                   506M 0  506M   0% /dev/shm
.host:/                 221G   18G  204G   8% /mnt/hgfs
/dev/sdb1               2.0G   36M  1.9G   2% /u01
[root@oraclehost ~]#

 

To mount the disk automatically after reboot,  add a entry in fstab like

[root@oraclehost ~]# vi /etc/fstab
[root@oraclehost ~]# cat /etc/fstab
LABEL=/                 /                       ext3  defaults          1 1
LABEL=/tmp              /tmp                    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/sdb1               /u01                    ext3  defaults          0 0
LABEL=SWAP-sda2         swap                    swap  defaults          0 0
To check the entry in fstab , umount and remount the disk.

][root@oraclehost ~]# umount /u01
[root@oraclehost ~]# mount -a
[root@oraclehost ~]# df -h
Filesystem              Size  Used Avail Use% Mounted on
/dev/sda5               12G  3.5G  7.7G  32% /
/dev/sda3               2.9G   72M  2.7G   3% /tmp
/dev/sda1               99M   12M   83M  12% /boot
tmpfs                   506M 0  506M   0% /dev/shm
.host:/                 221G   18G  204G   8% /mnt/hgfs
/dev/sdb1               2.0G   36M  1.9G   2% /u01

           

Published on 19th July 2012

Published by Gopinathan D