Tuesday 17 May 2011

Linux How To Mount Hard Disks And File Systems


Step One: Check the current had disk mount status:

command "df -h"

Sample Output:

"df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             6.0G  5.4G  231M  96% /
/dev/sda1             2.0G  268M  1.7G  14% /boot
tmpfs                 500M     0  500M   0% /dev/shm
"


Step Two: Check the hard disks attached to the server.

Command "fdisk -l"

Sample Output:

fdisk -l

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

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         261     2096451   83  Linux
/dev/sda2             262         522     2096482+  82  Linux swap / Solaris
/dev/sda3             523        1305     6289447+  83  Linux

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

   Device Boot      Start         End      Blocks   Id  System

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


Step Three: Find the unmounted hard disks from "fdisk -l"

Eg: "Disk /dev/sdb" and "Disk /dev/sdc"

Step Four: Format the disks to make linux filesystem.

Eg: "

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): 1
Last cylinder, +cylinders or +size{K,M,G} (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.


--------------------------------------------------------------------

fdisk /dev/sdc

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, +cylinders or +size{K,M,G} (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.

--------------------------------------------------------------------


Step Five: Check current "fdisk -l" status

Eg:
"fdisk -l

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

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         261     2096451   83  Linux
/dev/sda2             262         522     2096482+  82  Linux swap / Solaris
/dev/sda3             523        1305     6289447+  83  Linux

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

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

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

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        1305    10482381   83  Linux
"
You will find "/dev/sdb1               1        1305    10482381   83  Linux"
and "/dev/sdb1               1        1305    10482381   83  Linux" created.

Step Six: Use mkfs.ext3 command to build linux file system over "/dev/sdb1 and /dev/sdb1"

Eg:
"mkfs.ext3 /dev/sdb1
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 2620595 blocks
131029 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
8192 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.


------------------------------------------------------------------------------

mkfs.ext3 /dev/sdc1
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 2620595 blocks
131029 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
8192 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 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
"

Step Seven: Make directory to mound the two hard disks.

Eg:
"mkdir /mnt/diskone"
"mkdir /mnt/disktwo"

Step Eight: Mount the hard disk to created folders

Commands:
"mount /dev/sdb1 /mnt/diskone/"
"mount /dev/sdc1 /mnt/disktwo/"

Step Nine: Check the mount status:

Command" "df -h"

Eg:
"df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             6.0G  5.4G  229M  97% /
/dev/sda1             2.0G  268M  1.7G  14% /boot
tmpfs                 500M     0  500M   0% /dev/shm
/dev/sdc1             9.9G  151M  9.2G   2% /mnt/disktwo
/dev/sdb1             9.9G  151M  9.2G   2% /mnt/diskone
"

Step Ten: Commnds to unmount hard disks:

Commands:
"umount /dev/sdb1"
"umount /dev/sdc1"

Eg: "df -h"

"df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             6.0G  5.4G  229M  97% /
/dev/sda1             2.0G  268M  1.7G  14% /boot
tmpfs                 500M     0  500M   0% /dev/shm
"

No comments:

Post a Comment