Format a partition with the ext3 filesystem

Posted in Linux/Unix/BSD -

The ext3 filesystem is a Linux filesystem with journalling capabilities. I'm always forgetting the command I need to run to format a partitition with the ext3 file system so have posted this article so I always have a easy to find reference for it... The example used here is done on the command line, and not using a GUI tool.

Use the mk2fs command to format an ext3 partition as shown in the example below. You first need to have created a partition (or have a spare partition available) using the fdisk command. In the example below we are formatting the /dev/sdb1 partition.

mke2fs -j /dev/sdb1

The output of the above command will look something like this:

mke2fs 1.40.2 (12-Jul-2007)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
39075840 inodes, 78142160 blocks
3907108 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2385 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Writing inode tables: 1170/2385

While it writes out the inode tables, the 1170 part of the 1170/2385 at the end of the example above will increment for each inode being written.

When the process has completed it will look something like this:

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Now that the partition has been created it you can use the mount command to mount it, and/or add an entry to your system's /etc/fstab file to make it easier to mount or automount in the future.