Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»General Articles»How to Create Disk Partitions in Linux

    How to Create Disk Partitions in Linux

    RahulBy RahulSeptember 11, 20152 Mins ReadUpdated:April 6, 2018

    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.

    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
    Previous ArticleHow to Change Git Commit Message
    Next Article How to find Ubuntu Version, Codename and OS Architecture in Shell Script

    Related Posts

    How to Find Django Install Location in Linux

    Updated:April 27, 20221 Min Read

    (Resolved) – ReactJS 404 Error on Page Reload

    2 Mins Read

    Adding a New SSH Key in GitHub

    Updated:April 1, 20223 Mins Read

    13 Best Linux Terminal Emulators and Bash Editors

    8 Mins Read

    How To Install Oracle VirtualBox on Debian 11

    2 Mins Read

    10 Best Linux FTP Clients in 2022

    5 Mins Read

    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

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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