Partition : The total data storage space of a PC hard disk can be divided into at most four primary partitions, or alternatively three primary partitions and an Extended. These partitions are described by 16-byte entries that constitute the Partition Table, located in the master boot record.
Primary partition :The System Partition was required to be the first partition.More recent Windows operating systems (Win7, XP, etc.) can be located on any partition, but the boot files (bootmgr, ntldr, etc.) must be on a primary partition. However, other factors, such as a PC's BIOS may also impart specific requirements as to which partition must contain the primary OS.Maximum 4 primary partition we can do
Extended partition :A hard disk may contain only one extended partition; the extended partition can be subdivided into multiple logical partitions
Partition ID For Linux:Linux Native Partition ext-2/3 = 83
Swap = 82
Extended = 5
Linux LVM = 8e
Raid auto detect = fd
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 247 240 7 0 23 77
-/+ buffers/cache:139 108
Swap: 698 0 698
[root@localhost ~]# parted /dev/hda
GNU Parted 1.8.1
Using /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: SAMSUNG SP0802N (ide)
Disk /dev/hda: 80.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 22.7GB 22.7GB primary ntfs boot
2 22.7GB 80.1GB 57.3GB extended
5 22.7GB 54.3GB 31.6GB logical ntfs
6 54.3GB 70.0GB 15.7GB logical ext3
7 70.0GB 70.8GB 732MB logical linux-swap
8 70.8GB 71.0GB 206MB logical ext2
71.0GB 80.1GB 9089MB Free Space
Necessary Command for Partitioning:
# fdisk –l [To view all partition, Total HD Partition]
Example:
[root@localhost ~]# fdisk -l
Disk /dev/hda: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2764 22201798+ 7 HPFS/NTFS
/dev/hda2 2765 9733 55978492+ 5 Extended
/dev/hda5 2765 6602 30828703+ 7 HPFS/NTFS
/dev/hda6 6603 8514 5358108+ 83 Linux
/dev/hda7 8515 8603 714861 82 Linux swap / Solaris
/dev/hda1 * 1 2764 22201798+ 7 HPFS/NTFS
/dev/hda2 2765 9733 55978492+ 5 Extended
/dev/hda5 2765 6602 30828703+ 7 HPFS/NTFS
/dev/hda6 6603 8514 5358108+ 83 Linux
/dev/hda7 8515 8603 714861 82 Linux swap / Solaris
# free –m [To view all RAM & Swap Partition]
Example:[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 247 240 7 0 23 77
-/+ buffers/cache:139 108
Swap: 698 0 698
# df –h (d=disk,f=free,h=human redable format)
Example:
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 15G 7.1G 6.5G 53% /
tmpfs 124M 0 124M 0% /dev/shm
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 15G 7.1G 6.5G 53% /
tmpfs 124M 0 124M 0% /dev/shm
#parted /dev/hda [To view all partition,With Total Free HD Partition]
Example:
[root@localhost ~]# parted /dev/hda
GNU Parted 1.8.1
Using /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
GNU Parted 1.8.1
Using /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: SAMSUNG SP0802N (ide)
Disk /dev/hda: 80.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk /dev/hda: 80.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 22.7GB 22.7GB primary ntfs boot
2 22.7GB 80.1GB 57.3GB extended
5 22.7GB 54.3GB 31.6GB logical ntfs
6 54.3GB 70.0GB 15.7GB logical ext3
7 70.0GB 70.8GB 732MB logical linux-swap
70.8GB 80.1GB 9295MB Free Space
1 32.3kB 22.7GB 22.7GB primary ntfs boot
2 22.7GB 80.1GB 57.3GB extended
5 22.7GB 54.3GB 31.6GB logical ntfs
6 54.3GB 70.0GB 15.7GB logical ext3
7 70.0GB 70.8GB 732MB logical linux-swap
70.8GB 80.1GB 9295MB Free Space
For Creat new partion:fdisk /dev/hda (sda for sata hard disk)
Example:
[root@localhost ~]# fdisk /dev/hda
The number of cylinders for this disk is set to 9733.
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)
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
command (n for new partition): n [enter]
Command action
l logical (5 or over)
p primary partition (1-4)
l (press l for logical partition,p for primary partition,e for extended partition )
First cylinder (8604-9733, default 8604): Press Enter Button
Using default value 8604
Last cylinder or +size or +sizeM or +sizeK (8604-9733, default 9733):+200M(Partition size in MB)
Command (m for help): w(For Save)
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/hda
l logical (5 or over)
p primary partition (1-4)
l (press l for logical partition,p for primary partition,e for extended partition )
First cylinder (8604-9733, default 8604): Press Enter Button
Using default value 8604
Last cylinder or +size or +sizeM or +sizeK (8604-9733, default 9733):+200M(Partition size in MB)
Command (m for help): w(For Save)
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/hda
[root@localhost ~]# partprobe /dev/hda
[root@localhost ~]# partprobe /dev/hda
[root@localhost ~]# mkfs.ext2 /dev/hda8(For change file system)
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
50200 inodes, 200780 blocks
10039 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
50200 inodes, 200780 blocks
10039 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# parted /dev/hda
GNU Parted 1.8.1
Using /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: SAMSUNG SP0802N (ide)
Disk /dev/hda: 80.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 22.7GB 22.7GB primary ntfs boot
2 22.7GB 80.1GB 57.3GB extended
5 22.7GB 54.3GB 31.6GB logical ntfs
6 54.3GB 70.0GB 15.7GB logical ext3
7 70.0GB 70.8GB 732MB logical linux-swap
8 70.8GB 71.0GB 206MB logical ext2
71.0GB 80.1GB 9089MB Free Space
[root@localhost /]# mkdir /saifulpartion(For make a mount point directory)
[root@localhost /]# mount /dev/hda8 /saifulpartion(Mount hda8 to saifulpartition directory)
[root@localhost /]# vim /etc/fstab(For permanently mount we should give a antry in fastab)
LABEL=/ / ext3 defaults 1 1
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-hda7 swap swap defaults 0 0
/dev/hda8 /saifulpartion ext2 defaults 0 0
[root@localhost /]# mount -a
[root@localhost saifulpartion]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 15G 7.1G 6.5G 53% /
tmpfs 124M 0 124M 0% /dev/shm
/dev/hda8 190M 1.6M 179M 1% /saifulpartion