Tags

, , , ,

partition in linux

Hi friend’s welcome back to helpingyouonline, today i am  back with a basic Linux tutorial. I am going to share how to create and delete partition in Linux . This tutorial is dedicated to beginners who are new to Linux .

This tutorial covers ===>

>how to create a partition in linux?

>how to change type of a partition in linux?

>how to delete a partition in linux?

 

so Let’s get started ==>

                                          Partition creation in Linux

Step 1.– (Device Identification)

First of all check the partition table using fdisk command.
using fdisk command we can identify that the device is your Internal Hard disk or External hard disk.
#fdisk -l

1
Output of above command shows that partition table contains partition upto /dev/sda4
so now we will create a new partition /dev/sda5

Step 2.–>

Now we use fdisk command to create a partition ==>
#fdisk    /dev/sda

2
Note: Here we take sda because fdisk -l command show us our hard disk type is sda 

>now follow below process step by step ==>

:m ==> for help

3

:n ==> it will create a new partition.

4
Press enter to take default first cylinder value.
Now enter size of partition, for example to create a 100Mb partition we use +100M
so simply input +100M and hit enter.

:p ==> to view or to print the partition table

5

:w ==> to save all the changes.

6

#partprobe ==> to update partition table without reboot.

7

Note ==> if partprobe command does not work then simply reboot your linux system.

8

Step 3.–>

Now to make filesystem we have to format the partition /dev/sda5 using mkfs command.

#mkfs.ext3   /dev/sda5
here .ext3 is file system type

9

Step 4 .

Now to use the partition on Linux system we have to mount it on a directory.

>First create a directory with mkdir command ==>

#mkdir  /new

10

Here / indicates that directory is created on root.

Step 5 ->

Now simply mount the partition on /new directory
#mount   /dev/sda5   /new

11

Now we will check that the partition is mounted or not ==>

#df  -h

12

Step 6.–>

If we reboot now then the partition will unmounted automatically, it happens because the partition is mounted temporarily, to make it permanent so that it will not change after reboot or shutdown we have to do its entry in /etc/fstab file
now go to the file–

#vim /etc/fstab

13

/dev/sda5    /new     ext3    defaults    0    0

Here /dev/sda5 is the newly created partition , /new is the directory on which the partition is mounted and ext3 is the file system type and rest are default values.

14

>So we have successfully created a partition /dev/sda5

>Now check the newly created partition with fdisk command==>

#fdisk -l

Output of above command is shown below=>

5

 

 

Read more ==>

|| Complete tutorial on SSH server configuration in Rhel5/Rhel6.

||User and group management in Linux.

||Finger server in Linux.

                     how to change partition type in Linux??

There are two ways =>

1>First you can change the type of partition at the time of partition creation.

2>Second you can change the partition type at any time but to do it you have to unmount the partition first.

Lets change the partition type using second type =>

>First unmount the partition /dev/sda5.

#umount  /dev/sda5

16

>Now use fdisk utitlity to change type as shown below==>

#fdisk    /dev/sda

>Follow below process  to change the type of partition ==>

:t ==>to change the partition type
:5 ==> number of the partition.(/dev/sda5)
:L ==> to list the partition type with appropriate codes for individual type.

17
:fd ==> i have selected fd code from above list of codes, fd refers to linux autoraid partition type

18
w ==> to save and write changes

6

># partprobe ==> to update the partition table without reboot.

7
>fdisk -l ==> to view partition table

19

>Now you will see that the type of partition is successfully changed

                          how to delete a partition in Linux ??

To delete a partition in Linux simply follow below steps ==>

Step 1.–>

First of all remove the entries from /etc/fstab file
#vim    /etc/fstab
Simply erase the entered line or put # sign before the line.

15

Step 2.

Now unmount the partition

#umount   /dev/sda5

16

Step 3

Now use fdisk ==>
#fdisk    /dev/sda
:d ==> is used to delete the partition
:5 ==> number of partition which you want to delete

20
:w ==> save and exit

6

Step 4.

Use partprobe to update the partition table without reboot.
#partprobe

7

Step 5.

Now check the partition table
#fdisk -l

21
Now you will see that /dev/sda5 has been removed from your linux system.

>So today we have learned how to create a partition, how to change its type and how to delete a partition in Linux . As you see its very easy to manage partitions in Linux .

>Hope you like this article, follow us and share this article to facebook , twitter for more exciting articles.