Lesson 1, Topic 1
In Progress

Create and Configure File Systems

1. File Systems: vfat, ext4, and xfs

a. vfat

  • Originally for DOS and Windows systems.
  • Useful for flash drives and cross-compatibility.

b. ext4

  • Default for most Linux distributions.
  • Supports journaling, improving data integrity.

c. xfs

  • High-performance file system.
  • Ideal for large files and directories.

Example

# To create a vfat file system
mkfs.vfat /dev/sda1

# To create an ext4 file system
mkfs.ext4 /dev/sda2

# To create an xfs file system
mkfs.xfs /dev/sda3


Practical Exercise

  1. Create three different partitions and format each with vfat, ext4, and xfs.

2. Mounting and Unmounting File Systems

Example:

# To mount an ext4 file system
mount -t ext4 /dev/sda2 /mnt/mydrive

# To unmount
umount /mnt/mydrive


Practical Exercise

  1. Mount and unmount each of the file systems created in the previous exercise.

3. Network File Systems (NFS)

a. Mount and Unmount NFS

Example:

# To mount an NFS share
mount -t nfs server:/path/to/share /mnt/nfs

# To unmount
umount /mnt/nfs

b. Configure autofs

Autofs is a program that auto-mounts file systems when they’re accessed.

Example:

  1. Install autofs:

yum install autofs

  1. Edit /etc/auto.master and add:

/mnt/nfs /etc/auto.nfs

  1. Create /etc/auto.nfs:

share -fstype=nfs server:/path/to/share

  1. Restart autofs:

systemctl restart autofs

Practical Exercise

  1. Setup NFS on a test system, then use another system to mount the NFS share.
  2. Configure autofs to auto-mount the NFS share.

4. Extending Logical Volumes

Example:

# Extend the logical volume by 10GB
lvextend -L +10G /dev/myvg/mylv

# Resize the filesystem
resize2fs /dev/myvg/mylv


Practical Exercise

  1. Create an LV, fill it up, and then extend it.

5. Set-GID Directories for Collaboration

When a directory has the set-GID bit set, all files created within it inherit the group ownership of the directory.

Example:

# To create a directory and set the set-GID bit
mkdir /shared
chown :team /shared
chmod g+s /shared


Practical Exercise

  1. Create a set-GID directory and test its behavior with multiple users.

6. Diagnosing and Correcting File Permission Problems

Typically involves understanding the ls -l output, which provides file permission details.

Example:

# To correct permissions
chmod 755 /path/to/file

# To change ownership
chown user:group /path/to/file


Practical Exercise

  1. Create a file with incorrect permissions, try to access it with another user, and then correct the permissions.

Summary

Managing file systems efficiently is crucial for system performance, reliability, and data integrity. File system types like ext4 and xfs each offer unique advantages. Networking solutions like NFS provide shared resources across networks. Tools like autofs and set-GID enhance the flexibility and collaboration of these resources. Regularly diagnosing and correcting permission issues ensures data safety and proper access controls.

Key Points

  1. Know the benefits and drawbacks of each file system type.
  2. NFS provides a robust way to share files across the network.
  3. Regularly check and correct file permissions for data integrity and security.