2013-07-31

Partition or File system creation in linux


Pranaam to all bhai ji _/\_
it this tutorial we will go through the partition aka file system concept in linux.Partition is the logical devision on hard disk which are used to store data .
Partition is nothing  but just file system type which have a specific type environment or format( like FAT,NTFS for windows and EXT3/4  LVM for linux ) .Partition provide a unique environment for files in an operating system.partition space is divided in sectors and sector may have different storage capacity value(mostly, value of a sector is 512 byte).
we have following partition/file system type

1. Primary
2. Logical
3. Extended

primary and logical aprtition are use to store data on it but extended doesnt store data but it just hold free space or we can use this partition for creating local partition.
in MBR(master boot recorder which keep track of  starting sector location of partition as well it contain boot loader )
MBR is like this
MBR: { Primary | PrimaryPrimaryPrimary }
MBR: { Primary | Primary | Extended [ Logical1 Logical2 Logical3,... Logical60] }

MBR total space is 512 bytes, 446 is reserved for boot loader, 64 bytes for information regarding partitions (16 bytes for each partition) and 2 bytes for checksum purpose.
so total partition can be 
either  4 primary partition
or  3 partition with one extented  partition and that extented partition can have 60 logical partitions means total partitions in this case will be 
3 primary+1 extented+60 logical=64 partitions

fdisk  command 
fdisk command is use to list all the partitions on the system, we mainly use this command to create edit or modify partition on our system.
to list HD and attached storage devices(like USB) run this command
fdisk -l  , and you will get screen like this.


to enter into hard disk for new partition creation , run this command
fdisk  -c  device_name  (like  fdisk  -c  /dev/sda )
and we will enter into partition creation command line interface


we are going ot create new partition , so we will type  n and press enter
screen will come up with option to select partition type either primary or extented or logical(if we have left space in extended partition only). i am selecting primary type partition and to select primary type , type p and press enter.
select partition number or just press enter if you want to select default partition number. mine is 3.
after selecting partition type,number, we have to specify storage size of partition i.e starting and ending of new partition . press enter to select start point of partition


 for storage limit of partition , we can either specify last sector for the partition or can provide space in KB, MB, GB using  +size/K/M/G
i am using size in MB , to set 40 MB space , i typed  +40M and press entered and done :)


we have to update our new partition in partition list , so type w and press enter.
we need to update our new partition in kernel too. for this, either run command   partprobe  or  reboot system if it doesnt your OS doesnt support partprobe command.
our partition has been successfully created.
now we will format this newly created partition according to our need.i am formatting this partition in EXT4 format because i want to use it for linux .
for formatting , we have mkfs command , we need to specify format type and partition device name in mkfs command 
syntax of mkfs command :-
mkfs.format  partiton_device_name
example
mkfs.ext4   /dev/sda3  (/dev/sda3 will be formated  in ext4 file system)
mkfs.vfat   /dev/sda3   (/dev/sda3  will be formated in FAT  file system)
mkfs.ntfs   /dev/sda3   (/dev/sda3  will be formated in NTFS file system)


now our partition has been formated ,  now we just need to mount it and then we can use our new partition for storage purpose .
i am mounting this partition on /sda3  directory on my machine using mount command.
so , lets start.
partition name is /dev/sda3 and mount point(directory where i want to mount /dev/sda3) is /sda3.
we have discussed in previous post about mount command and process of mounting device using it.
command will
mount /dev/sda3  /sda3
and done
our partition is accessible from /sda3 directory :)


we have done with partition creation,formatting and then mounting that newly created partiton \m/
Thank you
Greetz To:- Guru ji Zero and whole Team IndiShell  <3

Share this post

0 comments

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

© 2009 Start With Linux | Mannu Linux
Designed by cyb3r.gladiat0r
Posts RSSComments RSS
Back to top