What is Disk partition?
Disk Partition means dividing a single hard disk into multiple logical drive using partition editors such as fdisk, parted tools. Once a hard disk divided into several partition, directories and files of different categories may be store in different partition or location.
Many new system admin create only two partition one is on /root and second one is swap for entire hard disk. So all directories like /bin, /usr, /var are created under the /root partition. Later on there may a need to create a new partition for these directories or for other mount points , so admin should know how to create a new disk partion.
►Primary Partition: The number of partition was limited from the very beginning and we can have only four partition and now these partition are called as Primary partition.
►Extended Partition: The extended partition is a way to overcome the limitation of the four primary partition on a drive. Here you can create more then four partition, You can create lots of partition.
►Logical Partition: A logical partition is a partition that has been created inside of an extended partition
Linux users make a distinction of the Filesystem stating that a filesystem is the programmatic scheme used to organize and find files on a partition. Whilst the file system refers to all the files on your computer.
What this essentially means is that the Filesystem is the structure used to see, find and use your files using Ubuntu, whilst the File System is both all the separate files in that structure and those files format.
|File System||Operating System||Description|
|FAT||Legacy||Legacy File System that was universally adopted. Came in 12 FAT12, 16 FAT16 and 32 FAT32.|
|NTFS||Windows||New Tech File System – replaced FAT on Windows systems. It is still needed to read Windows partitions.|
|Ext2||Linux||Second Extended filesystem – used by many Linux distro’s.|
|Ext3||Linux||Third Extended filesystem – default choice for Ubuntu distro’s. Journaling added.|
|Ext4||Linux||Fourth Extended filesystem – used by many Linux distro’s. Extends storage limits.|
|JFS||Linux||Journaled File System – was introduced by IBM and is still supported but has been replaced by Ext4.|
|XFS||Linux/Irix||64bit option mostly supported now as an option in Red Hat.|
|ReiserFS||Linux/SUSE||This was a file format that was in use across several distro’s, but has largely been replaced by Ext3.|
Linux Directories Partition
|/bin||Contains the common programs, shared by the system, the system administrator and the users.|
|/boot||This has the start up files and the kernel, vmlinuz. In some recent distributions it also has grub data. GRUB is the GRand Unified Boot Loader.|
|/dev||Contains references to all the CPU peripheral hardware. They are represented as files with special properties.|
|/etc||This has the most important system configuration files, this directory is similar to the control panel in Windows.|
|/home||This is the home directory for the common users.|
|/initrd||This contains information for booting in some distributions. Do Not Remove.|
|/lib||This holds the library files, it includes files for all kinds of programs needed by the user.|
|/lost+found||Every partition has a lost+found in its upper directory. Files that were saved during falures reside here.|
|/misc||For miscellaneous uses.|
|/mnt||Standard mount point for external files systems, such as media players, digital cameras and CD ROMs.|
|/net||Standard mount point for entire remote file systems.|
|/opt||Typically this will have third party software and any extra files required.|
|/proc||This is a virtual files system containing information about system resources. You can get more information about the meaning of the files in proc by entering the command man proc in a terminal window. The file proc.txt discusses the virtual file system in detail.|
|/root||This is the system administrator user’s home directory. Remember there is a difference between / the root directory and /root the home directory of the root user.|
|/sbin||This contains programs for use by the system administrator.|
|/tmp||This is temporary space for use by the system. It is regularly wiped so remember not to keep anything you want to retain here.|
|/usr||This has programs, libraries and documentation for all the user related programs.|
|/var||This is the storage for all the variable files and the temporary files created by users. Things like the log files, the mail queue, the print spooler area, space for the internet cache or to keep an image of a CD/DVD before burning it.|
Normally there are three types of partition:
►Normal(Physical) Partition: This is primary partition. There’s two ways to create a normal partition.
- MBR: This scheme support a max of four partition and eleven of extended partition. It means we can create max 15 partition. MBR allocated 32bit for logical partition and max disk partition size limit is 2TB.
- GPT: GPT is standard for laying out partition table on physical hard disk. GPT is default to support up to 128 partition. GTP allocated 64bit and max partition size is 8ZB.
►Swap Partition: A swap partition is an area of a disk which can be used with linux kernel memory management subsystem. Swap space are used to supplement the system RAM by holding inactive pages and services of memory. “In simple term we can use a part of hard disk as a RAM”
►LVM Partition: LVM is “dynamic partitions”, meaning that you can create/resize/delete LVM partitions(they’re called “Logical Volumes” in LVM-speak) from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly-created or resized partitions. Basically it is created for future use.
Create a normal partition:
First command to see the created partition is:
root@localhost:~#lsblk ##lsblk stands for list of blocks ##
Check the partition table using fdisk command.
Using fdisk command one can identify his device that whether it is your internal Hard disk or external hard disk.
root@localhost:~# fdisk -l Disk /dev/sda: 26.8 GB, 26843545600 bytes 255 heads, 63 sectors/track, 3263 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 3133 21029085 83 Linux
/dev/sda4 3134 3263 1044225 5 Extended
/dev/sda5 3134 3263 1044193+ 82 Linux swap / Solaris
we have seen that already partition up to /dev/sda5 has been created.
So now we have to create a new partion that will start from /dev/sda6
Before Partition we need to know about our hard disk in use. We use here some commands to know the detail information of hard disk we are using and we are going to partitioning.
root@localhost:~#cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST3160215AS Rev: 4.AA ------>> My hard Disk Type: Direct-Access ANSI SCSI revision: 05 Host: scsi4 Channel: 00 Id: 00 Lun: 00 Vendor: Kingston Model: DataTraveler G2 Rev: 1.00 ---->> My usb Device Type: Direct-Access ANSI SCSI revision: 02
We do partition or you can say disks are partitioned to make a separate File System according our need.
root@localhost:~# fdisk /dev/sda The number of cylinders for this disk is set to 3263. 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):
note: here we have taken sda because fdisk -l show us our hard disk is sda type not hda or hdb.
:n this will create a new partition
:l this will create a logical partition
: just press enter to take default
:+2000M this mean we want to create a partion of size 2gb approx ie 2000Mb.
:w write the changes and save it and exit
If You don’t want to reboot your linux system for making update for the changes you have made in the partition table above just use partprobe command.
make a file system in Linux
Mkfs or mke2fs command is used to create file system in linux.
So Create an ext3 file system.(Make File System so that it get recognized by OS)
#mke2fs -j /dev/sda6
#mkfs -t ext3 /dev/sda6
This will format the /dev/sda6 partition and create journal file system ext3 which can be regognised by our Linux operation System
Now make a new directory and mount /dev/sda6 newly created partion on it. mountpoint are directories where file systems are mapped.
#mkdir /new #mount /dev/sda6 /new
Now above command will mount /dev/sda6 on /new directory.
So now whatever you write in new directory will be saved in newly created partition /dev/sda6
To verify whether the filesystem has been mounted or not.
This will show you clearly that your /dev/sda6 is mounted on /new directory
Creating a Swap Partition:
root@localhost:~# lsblk root@localhost:~# fdisk /dev/vdb2 :n ## new partition ## :e ## extended ## :n ## new ## :l ## for logical partition ## :+1G ## size of partition in GB ## :t ## type of partition ## :5 ## partition number ## :82 ## Hex code for Swap partition ## :w ## for save ##
root@localhost:~# partprobe root@localhost:~# mkswap /dev/vdb2 ## To create file system ## root@localhost:~# swapon /dev/vdb2 ## for temporary mount ## root@localhost:~# free -m ## to check the swap partition ##
For permanent mount :
root@localhost:~# blkid /dev/vdb2 ## copy the block id of swap and past it in /etc/fstab file ## root@localhost:~# echo "UUID------- swap swap deafault 0 0" >> /etc/fstab
Deleting a Partition
First unmount the partition and remove the entry from /etc/fstab u have made above
Then use fdisk command to delete the partition
#fdisk /dev/sda:d here d is used to delete the partion:6 it means delete the partion /dev/sda6:w save the abve changes and exit
update change without a reboot.
Now check the partition table whether it is updated or not.
You will find /dev/sda6 has been deleted.
How to see the filesystem type creation command exists for your system?
Let’s Join our Hacking Team
We Are Indian We Are Great
Hope this article helpful for you. Thank You
Indian Cyber Army | Make IT Secure
Enjoy…Stay Happy…Stay Secure…
Hope this article helpful for you. Thank You
If You Appreciate What We Do Here On Hackonology, You Should Consider:
Hackonology is the fastest growing and most trusted community site where you can find lots of courses, articles about Technology/Hacking/Cracking. Millions of people visit Hackonology! to search or browse the thousands of published articles available FREELY to all.
Let's be a part of Hacker's Community! Join our Hacking Team
We Are Indian We Are Great