🌐 🇵🇱 Polski · 🇬🇧 EN
So far, we have spent a lot of time creating partitions, logical volumes, and RAID; now it is time to put the created disks to use. From this point on, we will start discussing file access settings, access control lists (ACLs), and quotas. All these tools will allow you to manage the system and available space more effectively.
FILE SYSTEM CONFIGURATION
Previously, we created various types of partitions and volumes in the system, which configured the available data space. However, before partitions can be used, a file system must be created on them. The default file system in the RHEL5 distribution is ext3, which was replaced in RHEL4 by ext4. Both file systems offer journaling, which has two main advantages. First, it helps to recover data quickly in case of disk failure because files are logged in the system using metadata. Second, during system startup, files are checked much faster. Journaling was not available in older file system versions like ext2. Creating a file system is identical for both ext3 and ext4. To practice the discussed topic, we need a few partitions; if they do not exist, they should be created.
/dev/hdb1 8GB Normal partition
/dev/hdc1 4GB Normal partition
/dev/hdc2 4GB Swap partition
/dev/hdd* 5GB Logical volume using LVM
/dev/hdd1 8GB Normal partition
When we create a file system, we have many ways to achieve the same result. Familiarize yourself with the commands that can be used to create and configure a file system.
mkfs - create ext2, ext3, ext4
mkfs.ext2 - create ext2
mkfs.ext3 - create ext3
mkfs.ext4 - create ext4
Regardless of the partition type on which the file system is created—whether it is a primary partition, RAID, or a logical volume—everything proceeds in the same way. To see how it looks in practice, let's create a file system on the hdb1 volume (with a size of 8GB).
Syntax of the mkfs command: # mkfs [options] device
mkfs command options:
- -j - Create journaling option (default in ext4, for ext2 only upgrades the fs version)
- -m - Specify the percentage of file system blocks reserved
- -L - Volume label
Step 1 - Creating the first file system
# mkfs.ext4 /dev/hdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
524288 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Step 2 - You can also do the above like this:
# mkfs -t ext4 /dev/hdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
524288 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Both versions will give the same result.
Step 3 - You can also create a file system on a logical volume, in which case you execute:
# mkfs.ext4 /dev/vg_group01/lvol0
Sometimes you may encounter file systems in the ext2 version, and if you want to add journaling options, such a version will need to be upgraded to ext3 or higher. To practice this, we will create one partition in the ext2 version for the purpose of upgrading it later.
Step 4 - On the hcd1 partition with a size of 4GB, we create an ext2 file system
# mkfs.ext2 /dev/hdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262944 inodes, 1050241 blocks
52512 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1077936128
33 block groups
32768 blocks per group, 32768 fragments per group
7968 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
After creation, we upgrade the version to ext3 using the "tune2fs" command
# tune2fs -j /dev/hdc1
tune2fs 1.41.12 (17-May-2010)
Creating journal inode: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Basic information about creating file systems is now behind us.
Comments