Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»How to Create Disk Partitions in Linux

    How to Create Disk Partitions in Linux

    By RahulApril 6, 20182 Mins Read

    If you have added a new hard disk to your system or you are planning to add a new disk to your system. You will need to make file-system on newly created disks before using them. This article will help you to create partitions on disk in Linux system and format disk partitions to create a file system.

    Advertisement

    Step 1 – Create Disk Partitions

    If you have added a new disk to your system, You can simply format entire disk and create it as a single disk. But it’s a good idea to create smaller partitions on large size disks.

    fdisk /dev/sdc
    

    Use n to create new partition like below. After that select p or e for creating a primary or extended file system. As we are creating first partition, so we can use p (primary). Remember that you can’t create more than 4 primary partitions.

    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First sector (63-104857599, default 63): 2048
    Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +10G  
    

    Save new partitioning table using w command.

    Command (m for help): w
    

    Step 2 – Format Disk Partitions

    Use mkfs utility for creating the file system on disk partitions. You can define file system type with mkfs command which file system we need on disk.

    mkfs -t ext4 /dev/sdc1
    

    We can use any other file system type like: ext2, ext3, ext4, fat, vfat, ntfs etc.

    mkfs.ext4 /dev/sdc1
    

    3. Mount/Unmount Partitions

    Before mounting a disk, you are required to create a mount point. Then use the mount command to mound disk partition on a mount point.

    mkdir /newDisk1
    mount /dev/sdc1 /newDisk1
    

    Now use one of following command to verify disk is mounted successfully.

    mount | grep "/dev/sdc1"
    df -h | grep "/dev/sdc1"
    

    4. Mount Disk on Startup

    Use /etc/fstab file which is used for mounting disk partitions during system boot up. Add the following entry in /etc/fstab file at the end of file.

    /dev/sdc1 	/newDisk1	ext3	defaults	0	2
    

    disk format harddisk
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    What is Media Access Control (MAC) Address?

    SQL Queries to Change Domain Name for WordPress Site

    How To Block Specific Keywords Using Squid Proxy Server

    View 2 Comments

    2 Comments

    1. Nikola on October 23, 2019 12:10 pm

      Just press Enter and it will set to default value

      Reply
    2. shoaib on January 2, 2019 5:51 am

      what is sector and what to select for first and for last sector.???

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting and Getting the Default Timezone in Python
    • What is Media Access Control (MAC) Address?
    • What is Cross-Site Scripting (XSS)?
    • What is Content Security Policy (CSP)?
    • A User’s Guide to Understanding Redirection Operators in Bash
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.