How do I create a new ext3 file system if a disk was added to the system?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 4
  • Red Hat Enterprise Linux 5

Issue

  • How do I create a new ext3 file system if a disk was added to the system?

Resolution

  • Create the partition using the fdisk command. To start fdisk at a shell prompt (as root), type the command:
[root@host ~]# fdisk /dev/hdb
  • /dev/hdb is the device name for the drive you want to configure. The Command (m for help): prompt is displayed. 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 and you can create up to 15 partitions that the system will recognize. 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: +5000MB to create a 5 GB partition. Then at the prompt put p to check and confirm the partition is created as specified. Finally put w at the prompt to write changes to the disk and create the partition(s) on it, or put q to quit without creating the parition and quit fdisk.

  • Format the partition with the ext3 file system using mke2fs. Note that an ext3 file system is an ext2 filesystem with journaling (the -j option). See man mke2fs for more options. Type:

[root@host ~]# /sbin/mke2fs -j /dev/hdb3
  • /dev/hdb3 is the partition you want to format.

  • Note: If mke2fs does not recognize your partition, then you must reboot your system or run partprobe so that the new partition table is recognized.

  • You can label the partition using e2label. For example, if you want to label the new partition /work, type:

[root@host ~]# e2label /dev/hdb3 /work
  • As root, create the mount point:
[root@host ~]# mkdir /work
  • As root, edit the /etc/fstab to include the new partition. The new line should similar to the following:
LABEL=/work           /work               ext3      defaults    1 2
  • Reboot your system so that the new partition table is recognized.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments