How to format a new volume in Linux as ext4 or ext3

In this article i will walk you thru the steps you need to format a new volume as ext4 format and make it available to your Linux box. We have a volume called /dev/sdg and at the moment it needs formatting.

[root@aodba~]# blkid /dev/sdg
inode To format the new volume to ext4 file system type we will use mkfs.ext4 utility as root user.
  • you need to provide him with the y falg to continue.
Note:
[root@aodba~]# mkfs.ext4 /dev/sdg
mke2fs 1.41.12 (17-May-2010)
/dev/sdg is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3932160 inodes, 15728640 blocks
786432 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
480 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

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

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

Now we can check that our volume thou is no mounted the file system type if ext4

[root@aodba~]# blkid /dev/sdg
/dev/sdg: UUID="d3ab63f7-f7e1-4207-8a6e-7dd925a73346" TYPE="ext4"
  •  Great we can see that now we have the volume formatted with ext4 fs type.

Next we need to mount the new formatted volume to our Linux host

  • we are going to mount it on directory /vertica_storage/t1_data_03
[root@aodba~]# mount /dev/sdg /vertica_storage/t1_data_03
[root@aodba~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   29G  7.6G   20G  29% /
tmpfs                   48G     0   48G   0% /dev/shm
/dev/sda1              485M   94M  366M  21% /boot
/dev/sdc               1808G  143G   306G  81% /vertica
/dev/sdd                380G  172M   280G   1% /vertica_storage/t0_temp
/dev/sde               2427G  190G   404G  82% /vertica_storage/t1_data
/dev/sdf               1428G  107G   305G  76% /vertica_storage/t1_data_02
/dev/sdg                600G  180M   599G   1% /vertica_storage/t1_data_03
We can see that our volume is mounted.

Add the new new mount point to /etc/fstab file.

The configuration file /etc/fstab contains the necessary information to automate the process of mounting partitions. In a nutshell, mounting is the process where a raw (physical) partition is prepared for access and assigned a location on the file system tree (or mount point).
echo "/dev/sdg   /vertica_storage/t1_data_03  ext4  defaults   1 2"  /etc/fstab
Wanna know more about /etc/fstab file ? Read the article Fstab in detail.