Add a HDD in Linux , make pertition and Format it.

Posted: July 27, 2010 in Redhat
Tags: ,

Adding a new disk to a Linux

Senario:

I am using a Vmware Virtual Box and just added a new HDD on that . I am not going through how I have done it . You can check this post for reference on that . Assuming the HDD is added and now go through the following.

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

The number of cylinders for this disk is set to 3916.
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): p

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

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

Command (m for help): p

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3916    31455238+  83  Linux

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

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

Disk /dev/sda: 32.2 GB, 32259548160 bytes
255 heads, 63 sectors/track, 3922 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         131     1052226   83  Linux
/dev/sda2             132         784     5245222+  83  Linux
/dev/sda3             785        1437     5245222+  83  Linux
/dev/sda4            1438        3918    19928632+   5  Extended
/dev/sda5            1438        1698     2096451   83  Linux
/dev/sda6            1699        1959     2096451   82  Linux swap / Solaris
/dev/sda7            1960        2220     2096451   82  Linux swap / Solaris
/dev/sda8            2221        2481     2096451   83  Linux
/dev/sda9            2482        2612     1052226   83  Linux
/dev/sda10           2613        3918    10490413+  83  Linux

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3916    31455238+  83  Linux

[root@aurhel05 ~]# 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)
3932160 inodes, 7863809 blocks
393190 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
240 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, 2654208,
4096000

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

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

[root@aurhel05 ~]# mkdir /u02

[root@aurhel05 ~]# mount /dev/sdb1 /u02

[root@aurhel05 ~]# mkdir /u02

[root@aurhel05 ~]# mount /dev/sdb1 /u02

[root@aurhel05 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda9            1020M  632M  337M  66% /
/dev/sda10             10G  5.1G  4.4G  54% /u01
/dev/sda8             2.0G   36M  1.9G   2% /tmp
/dev/sda5             2.0G  161M  1.8G   9% /home
/dev/sda3             5.0G  5.0G     0 100% /var
/dev/sda2             5.0G  2.4G  2.4G  50% /usr
/dev/sda1            1020M   42M  927M   5% /boot
tmpfs                  12G     0   12G   0% /dev/shm
/dev/sdb1              30G  173M   28G   1% /u02

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

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/u02              /dev/sdb1                    ext3    defaults        1 2
LABEL=/tmp              /tmp                    ext3    defaults        1 2
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/var              /var                    ext3    defaults        1 2
LABEL=/usr              /usr                    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
LABEL=SWAP-sda6         swap                    swap    defaults        0 0
LABEL=SWAP-sda7         swap                    swap    defaults        0 0

Save and exit . This will mount that pertition automatically after next reboot.

Advertisements
Comments
  1. […] I can see the 1.5 TB HDD . Click here for my post of how to format it and make […]

    • Mohamamd says:

      You can also use the following command to create Physical Volumn while adding LUN from SAN

      # pvcreate /dev/mapper/
      # mkfs.exts /dev/mapper/mpathxx
      # mount /dev/mapper/mpathxx /u15

      Then editr fstab file to reflect on next reboot.

  2. Mohamamd says:

    Just a small note , if you mistake in fstab and it does not boot properly . Log in to rescue mode , type [mount -o remount,rw /] and then edit the /etc/fstab file again properly.

    Ashraf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s