How to Create and Delete partition in RedHat enterprise Linux

Posted: January 25, 2017 in LINUX
Tags: , ,

If you are a Linux User and you are using Linux for storing data and doing multiples tasks then you must need to manage your hard drive in linux.sometimes you need to create new partition,sometimes you need to delete some of your partitions as per your requirement.And if you don’t have idea about how to create and delete partition in Linux then it will become very hectic task for you to manage your data in Linux and sometimes it may result in Data Loss.even many people used Linux and windows together in Dual Boot(mean Windows and Linux Together in a Hard Disk).In such case even a little mistake done at Linux Side can Destroy  your all Windows data because all data resides on same Hard Disk.

ethical Hacking

So for everyone who wants to keep Linux in His/Her laptop or Computer this article is for you.here in this article i am going to show you how to Create and Delete partitions in Linux very easily in just few simple steps.

Step1:How to see partition table in Linux.

before Creating a new partition you must know how to see your already created partition available at the time.

 [root@localhost ~]# fdisk -l
 Disk /dev/sda: 34.3 GB, 34359738368 bytes
 255 heads, 63 sectors/track, 4177 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Device Boot Start End Blocks Id System
 /dev/sda1 * 1 3315 26627706 83 Linux
 /dev/sda2 3316 3576 2096482+ 82 Linux swap / Solaris
 /dev/sda4 3577 4177 4827532+ 5 Extended
 /dev/sda5 3577 3613 297171 8e Linux LVM
 /dev/sda6 3614 3650 297171 8e Linux LVM
 /dev/sda7 3651 3712 497983+ 8e Linux LVM
 [root@localhost ~]#

 

You can clearly see the partition is up to /dev/sda7 now.

Step2:How to create a new partition in Linux.

 

Now I am going to show you how to create a new partition in redHat Enterprise Linux.
See the below image to understand linux partition creation.

create partition in linux
Step3:Update Partition table using partprobe

After every change made to partition table you must run this command to update the partition table.

[root@localhost ~]# partprobe /dev/sda

Step4:Now Format and mount the Newly created partition to make it usable.

[root@localhost ~]# mkdir /E

 

Before Format check the partition you have created exist or not.

 

[root@localhost ~]# fdisk -l
 Disk /dev/sda: 34.3 GB, 34359738368 bytes
 255 heads, 63 sectors/track, 4177 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Device Boot Start End Blocks Id System
 /dev/sda1 * 1 3315 26627706 83 Linux
 /dev/sda2 3316 3576 2096482+ 82 Linux swap / Solaris
 /dev/sda4 3577 4177 4827532+ 5 Extended
 /dev/sda5 3577 3613 297171 8e Linux LVM
 /dev/sda6 3614 3650 297171 8e Linux LVM
 /dev/sda7 3651 3712 497983+ 8e Linux LVM
 /dev/sda8 3713 3774 497983+ 83 Linux

 

Now format the partition /dev/sda8 which we have created.

 

[root@localhost ~]# mkfs.ext3 /dev/sda8
 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.

 

Mount the Drive after Format.

 

[root@localhost ~]# mount /dev/sda8 /E
 [root@localhost ~]#

Check the drive mounted or not.

 

[root@localhost ~]# df -Th
 Filesystem Type Size Used Avail Use% Mounted on
 /dev/sda1 ext3 25G 8.5G 15G 37% /
 tmpfs tmpfs 760M 0 760M 0% /dev/shm
 /dev/sda8 ext3 471M 11M 437M 3% /E
 [root@localhost ~]#

step5:Make the mount Permanent so that it exist even aftre reboot.

see the below image in /etc/fstab file

/etc/fstab entry

 

Now how to delete Linux partition

step1:To Delete Partition First remove the Permanent Mount option from /etc/fstab file.

step2:Then unmount the mounted Drive and Check it.

[root@localhost ~]# umount /E
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext3 25G 8.5G 15G 37% /
tmpfs tmpfs 760M 0 760M 0% /dev/shm
[root@localhost ~]#

step3:Now you are free to delete the partition created.

here I am going too Delete Linux Partition /dev/sda8

delete linux partition

Update the partition table after making change in partition table.
[root@localhost ~]# partprobe /dev/sda

Finally Check the Partition table.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 34.3 GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3315 26627706 83 Linux
/dev/sda2 3316 3576 2096482+ 82 Linux swap / Solaris
/dev/sda4 3577 4177 4827532+ 5 Extended
/dev/sda5 3577 3613 297171 8e Linux LVM
/dev/sda6 3614 3650 297171 8e Linux LVM
/dev/sda7 3651 3712 497983+ 8e Linux LVM
[root@localhost ~]#

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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