≡ Menu

Linux: How Do I Create a New ext3 File System If a Disk Was Added To The Server / Desktop?

Q. How Do I Create a New ext3 File System If a Disk Was Added To The Server / Desktop Under Any Linux Operating Systems?

A.First, create the partition using the fdisk command line utility. To start fdisk, type the following command at a shell prompt. You need a device name refers to the entire hard disk.:
# fdisk /dev/device-name
# fdisk /dev/sdb

Where /dev/sdb is the device name for the drive you want to configure and format with a new ext3 filesystem.

The Command (m for help): prompt is displayed as follows:
(m for help):

Type n then p, to create a new (n) primary (p) partition. You will then be asked to enter a partition number 1-4. You can only have a total of 4 primary partitions. If you need more than 4 partitions, then your 4th partition will become your extended partition. You will then enter the size of the partition that you want to create. The easiest way to do this is to select the defaulted start cylinder, then issue a size based on MB. Example: +10000MB to create a 10 GB partition.

Format hard disk

To format the partition with the ext3 file system use mke2fs command.
# mke2fs -j /path/to/partition
# mke2fs -j /dev/sdb1

Where /dev/sdb1 is the partition you want to format. If mke2fs does not recognize your partition, then you must reboot your system or run this command so that the new partition table is recognized.

Update /etc/fstab

Create a mount point:
# mkdir /disk2
Edit the /etc/fstab to include the new partition
# vi /etc/fstab
Append the new line as follows:
/dev/sdb1 /disk2 ext3 defaults 1 2
To mount, enter:
# mount -a
# df -H

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 5 comments… add one }
  • syed ali June 16, 2015, 9:02 pm

    finally I was able to add a new drive very good instruction-God bless you

  • Nirav July 11, 2015, 2:45 am

    When I try to format the partition, It shows me “/dev/sda4 is mounted; will not make a filesystem here! ”

    Any suggestion??

    Thanks

  • shashi April 19, 2016, 5:37 am

    nice post, thanks

  • Yuvaraj July 1, 2016, 5:03 am

    crfs -v jfs2 -d /dev/$2 -m $3 -a yes -p’rw’

    $3 – Size
    $2 -VG

    The above is in AIX….I am in need of equivalent unix code.. can any one help me??

  • Benny February 18, 2017, 9:20 am

    9 years later – still short, simple and helpful.
    Thanks a lot!

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , , , , , ,