WONDERING HOW TO CREATE PARTITION IN LINUX . CHECK IT OUT

 

In this post we will learn how to create partitions in linux .

 

  • First check how many partition you have by fdisk -l command .
[root@localhost ~]# fdisk -l
Disk /dev/sda: 50.9 GB, 50985402368 bytes
255 heads, 63 sectors/track, 6198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        5099    40957686   83  Linux
/dev/sda2            5100        5736     5116702+  82  Linux swap / Solaris
You have new mail in /var/spool/mail/root
  • Now run fdisk  /dev/sda command to create new partition .
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 6198.
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)
e
  • Give extended partition full size ,  So just hit Enter button till next command it asks?
Partition number (1-4):
Value out of range.
Partition number (1-4): 4
First cylinder (5737-6198, default 5737):
Using default value 5737
Last cylinder or +size or +sizeM or +sizeK (5737-6198, default 6198):
Using default value 6198

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (5737-6198, default 5737):
Using default value 5737
Last cylinder or +size or +sizeM or +sizeK (5737-6198, default 6198): +500M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (5799-6198, default 5799):
Using default value 5799
Last cylinder or +size or +sizeM or +sizeK (5799-6198, default 6198): +500M
Command (m for help): p
Disk /dev/sda: 50.9 GB, 50985402368 bytes
255 heads, 63 sectors/track, 6198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        5099    40957686   83  Linux
/dev/sda2            5100        5736     5116702+  82  Linux swap / Solaris
/dev/sda4            5737        6198     3711015    5  Extended
/dev/sda5            5737        5798      497983+  83  Linux
/dev/sda6            5799        5860      497983+  83  Linux

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# partprobe /dev/sda
  • First format partition you created (sda5 and sda6)
[root@localhost ~]# mkfs.ext3 /dev/sda5

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
124928 inodes, 497980 blocks
24899 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
61 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost ~]# mkfs.ext3 /dev/sda6

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
124928 inodes, 497980 blocks
24899 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
61 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
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.
  • To use partition we have to mount it to any folder . So create a  folder where you want to mount that partition .
[root@localhost ~]# mkdir D
[root@localhost ~]# mkdir A
  • Now mount that partition to that folder .
[root@localhost ~]# mount /dev/sda5 D
[root@localhost ~]# mount /dev/sda6 A
  • Check by df -h command whether your partition have been mounted or not .
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              38G   12G   25G  32% /
tmpfs                 887M     0  887M   0% /dev/shm
/dev/sda5             471M   11M  437M   3% /root/D
/dev/sda6             471M   11M  437M   3% /root/A

SO THIS IS HOW YOU CREATE PARTITION IN LINUX .

CHECK OUT MY VIDEO IF YOU GOT ANY PROBLEM .

 

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