Manage Partition in linux

What is Partition ?
A Partition can be thought of as a division or "part" of a real HDD. When you partition a hard drive, you make it available to an os . Multiple partition on a single hdd appear as separate drives to the operating system.

Device Recognition-

1.Master Boot Record (MBR) Contain.


  • Executable code to load os.
  • Space for partition table information, including:



  1.             Partition ID or Type
  2.             Starting cylinder for partition
  3.             Number of cylinder for partition

Partition Type-

1.Primary
2.Extended
3. Logical
4.Swap
Partition ID-

5 or f ------Extended
82     ------Linux swap
83     ------Linux
8e     ------Linux LVM
fd     ------Linux RAID auto

Note- Total Number of partition supported by kernel-

63  for IDE Drive
15  for SCSI Drive


How to Create Partition--


1) Verify if the Linux system is detecting new hard disk

#fdisk -l

2)To create partitions on new hard disk (if the new disk is shown as “/dev/sda”)

#fdisk /dev/sda

Note-where /dev/sda is the device name 



Type Example:
Command (m for help): m     (Enter the letter “m” to get list of commands)
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 (m for help): n
Command action
e   extended
p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-2654, default 1):        (press enter)
Using default value 39473
Last cylinder , +cylinders or +size{K,M,G} (39473-60802, default 60802): +5G (press enter)
(Note-+5G Partition size)
Command (m for help): p
Command (m for help): w    (Write and save partition table)
3). Update the partition table-
#partx -a /dev/sda
4).Formate the partition-
#mkfs.ext4 /dev/sda4
5). Mount The Partition-
  •  Temporary
  •  permanent

Temporary Mount -
#mount /dev/sda/ /mnt
#mount

Permanent Mount-
#vim /etc/fstab
Press G
Then last line and entry-

/dev/sda4                  /jet               /ext4              defaults                    0 0

(Note- Jet is a Directory name)

6). Update Partition Table-
#mount -a

How to change system ID-

#fstab /dev/sda

Press:  t
Command (m for help): t
Select Partition Number-
Partition number (1-5): 4

Press: L              (To show all types system ID number)
Hex code (type L to list codes): l


Then Type- ID Number and enter
Hex code (type L to list codes): 82

Command (m for help): p

Command (m for help): w    (Write and save partition table)

Update partition table-
#partx -a /dev/sda

No comments:

Post a Comment