With the volumes created, you need to put file systems on them. (If you’re accustomed to
Microsoft Windows, this is akin to formatting the disk once you’ve partitioned it.)
The type of file system that you want to create will determine the particular utility
that you should use. In this project, we want to create an ext3-type file system; therefore,
we’ll use the mkfs.ext3 utility. Many command-line parameters are available for the
mkfs.ext3 tool, but we’ll use it in its simplest form here.
Following are the steps for creating a file system:
The only command-line parameter you’ll usually have to specify is the partition
(or volume) name onto which the file system should go. To create a file system
on /dev/VolGroup00/LogVol04, you would issue the following command:
[root@fedora-serverA ~]# mkfs.ext3 /dev/VolGroup00/LogVol04
mke2fs 1.4* (12-Jun-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
...(Output truncated)...
This file system will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Once the preceding command runs to completion, you are done with creating
the file system. We will next begin the process of trying to relocate the contents
of the current /var directory to its own separate file system.
Create a temporary folder that will be used as the mount point for the new file
system. Create it under the root folder. Type
[root@fedora-serverA ~]# mkdir /new_var
Mount the LogVol04 logical volume at the /new_var directory. Type
[root@fedora-serverA ~]# mount /dev/VolGroup00/LogVol04 /new_var
Copy the content of the current /var directory to the /new_var directory. Type
[root@fedora-serverA ~]# cp -rp /var/* /new_var/
In order to avoid taking down the system into single-user mode to perform the
following sensitive steps, we will resort to a few old military tricks. Type
[root@fedora-serverA ~]# mount --bind /var/lib/nfs/rpc_pipefs
/new_var/lib/nfs/rpc_pipefs
The preceding step is necessary because the rpc_pipefs pseudo-file system happens
to be mounted under a subfolder in the /var directory.
Now you can rename the current /var to /old_var. Type
[root@fedora-serverA ~]# mv /var /old_var
Create a new and empty /var directory. Type
[root@fedora-serverA ~]# mkdir /var
Restore the security contexts for the new /var folder so that the daemons that
need it can use it. Type
[root@fedora-serverA /]# restorecon -R /var
NOTE The preceding step is only necessary on a system running an SELinux-enabled kernel, like
Fedora, RHEL, or Centos.
We are almost done now. We need to create an entry for the new file system in
the /etc/fstab file. To do so, we must edit the /etc/fstab file so that our changes
can take effect the next time the system is rebooted. Open up the file for editing
with any text editor of your choice, and add the following entry into the file:
/dev/VolGroup00/LogVol04 /var ext3 defaults 1 2
TIP You can also use the echo command to append the preceding text to the end of the file. The
command is echo "/dev/VolGroup00/LogVol04 /var ext3 defaults 1 2" >> /etc/fstab
This will be a good time to reboot the system. Type
[root@fedora-serverA /]# shutdown -r now
Hopefully the system came back up fine. After the system boots, delete the
/old_var and /new_var folders using the rm command.
NOTE If, during system bootup, the boot process was especially slow starting the system “logger
service,” don’t worry too much—it will time out eventually and continue with the boot process. But
you will need to set the proper security contexts for the files now under the /var folder by running the
restorecon -R /var command again, with the actual files now in the directory. Then reboot
the system one more time.