0% found this document useful (0 votes)
23 views20 pages

Chapter 3

Chapter 3 covers file system administration, including the organization and management of data storage on devices, types of file systems, and basic administration tasks like building and mounting file systems. It also discusses partitioning disks using tools like parted and fdisk, creating and maintaining file systems, and the role of swap space in Linux. Additionally, the chapter introduces RAID configurations for improved performance and redundancy in data storage.

Uploaded by

atinasianegash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views20 pages

Chapter 3

Chapter 3 covers file system administration, including the organization and management of data storage on devices, types of file systems, and basic administration tasks like building and mounting file systems. It also discusses partitioning disks using tools like parted and fdisk, creating and maintaining file systems, and the role of swap space in Linux. Additionally, the chapter introduces RAID configurations for improved performance and redundancy in data storage.

Uploaded by

atinasianegash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Chapter :3 file system and management of Data storage

3.1 file system Administration

File system administration involves managing and maintaining file


systems on a computer or storage device.
Here are some key aspects of file system administration:
1. File Systems Overview:
o A file system organizes and manages data on storage devices.
o It provides a higher-level abstraction for applications, allowing them
to work with named files and directories rather than raw sectors.
o Core abstractions include files (named regions of bytes)
and directories (containers for files and subdirectories).
2. File System Types:
o Single Extents (1960s File Systems):
 Metadata: Starting sector and file size.
 Advantages: Simple, efficient for sequential and random I/O.
 Disadvantages: Preallocation challenges, external
fragmentation.
o Collections of Extents (IBM OS360, ext4):
 Metadata: Multiple extents.
 Advantages: Efficient for small files, still supports sequential and random I/O.
 Disadvantages: Complex design challenges.
o Hybrid Indices (FFS, ext2, ext3):
1
Page

 Top-level index with direct and indirect pointers.


 Efficient for small files, large maximum file size.
 Low internal and external fragmentation.
3. Basic File System Administration Tasks:
o Building File Systems:
 Use the mkfs command to create a file system on a block device.
o Mounting File Systems:
 Attach a block device to a mount point in the directory
hierarchy.
o Configuring Automounter:
 Set up automatic mounting of file systems.

Remember that file system administration ensures efficient data storage,


access, and reliability. Whether you’re managing local disks or network-
based storage, understanding file systems is essential for effective
system administration
3.1.1 Partitioning Disk with fdisk and parted

Certainly! Let’s delve into partitioning disks using


the parted and fdisk commands in Linux.

These tools allow you to create, manage, and organize disk partitions.
Here’s how you can use them:

1. parted Command:
2
Page
o Purpose: parted is a versatile utility for manipulating disk partitions.
It enables tasks such as creating space for new operating systems,
reorganizing disk usage, and copying data to new hard disks.

o Functionality:

o Resizing: parted allows resizing (both shrinking and extending) partitions.

o Partition Creation: You can create new partitions using parted.

o Steps:
1. List Partitions: Before creating a partition, list available storage devices and partitions
using:

2. sudo parted -l

This command provides information about storage devices,


partition tables, and existing partitions.
3. Open Storage Disk: Specify the storage device you want to partition
(e.g., /dev/sdb):

4. sudo parted /dev/sdb

5. Make a Partition Table: Create a partition table (e.g., GPT or


MSDOS):

6. mklabel gpt Confirm with “Yes.”

7. Check Table: Verify the partition table:

8. print
3

9. Create Partition: For example, to create a primary FAT32 partition from 0% to


Page

512MiB:
10. mkpart primary fat32 0% 512MiB

Repeat for other partitions as needed.

11. Name Partitions (optional):

12. name 1 EFI-Boot

13. name 2 Swap

14. name 3 root

15. name 4 /opt

16. name 5 /home

17. Set Flags (optional):

18. set 1 esp on

o Example:

o parted -s /dev/sdb mklabel gpt

o parted -s /dev/sdb mkpart primary fat32 0% 512MiB

o # ... (create other partitions)

o parted -s /dev/sdb name 1 EFI-Boot

o # ... (name other partitions)

o parted -s /dev/sdb set 1 esp on


4

2. fdisk Command:
Page
o Purpose: fdisk is another disk partitioning tool, but it has
fewer features compared to parted.

o Functionality:
 Basic Partitioning: fdisk allows creating, deleting, and modifying partitions.

 MBR Support: It works with MBR (Master Boot Record) partition tables.

o Steps:

1. List Existing Partitions:

2. sudo fdisk -l

3. Select Storage Disk (e.g., /dev/sdb):

4. sudo fdisk /dev/sdb

5. Create a New Partition:

 Press n to create a new partition.

 Specify partition type (primary, extended, logical).

 Set partition size and location.

 Save changes with w.

o Example:

o sudo fdisk /dev/sdb

o # Follow prompts to create a new partition


5
Page
Remember to adapt the commands to your specific requirements and
disk configuration. Both parted and fdisk are powerful tools, so choose
the one that best suits your needs1

3.1.2 Create mounting and maintaining file system


1. Creating a File System:
o To create a file system on a device (such as a hard disk partition), you use
the mkfs command.
o This command is a front end for various file system builder utilities
like mkfs.ext2 and mkfs.ext4.
o The basic syntax for creating a file system is:
o # mkfs [options] device
o By default, the mkfs command creates an ext2 file system. You can specify a
different file system type using the -t fstype option. For example:
o # mkfs -t ext4 /dev/sdX1
o Supported file system types include:
 ext2: High performance for fixed disks and removable media.
 ext3: Journaling version of ext2.
 ext4: Supports larger files and file system sizes.
 vfat: MS-DOS file system (useful for sharing files between Windows and
Linux).
 XFS: High-performance journaling file system.
 Btrfs: Addresses scalability requirements for large storage systems.
o You can check which file system types are installed using:
o # ls /sbin/mkfs*
6

2. Mounting a File System:


Page
o After creating a file system, you need to mount it to a directory in the existing
file hierarchy.
o First, create a mount point (e.g., /mnt/mydata) using:
o # mkdir /mnt/mydata
o Then, add an entry to the /etc/fstab file to mount the partition at boot time.
Use the partition’s UUID to ensure stability across reboots.
3. Maintaining a File System:
o Regular maintenance ensures optimal performance and reliability.
o Some common maintenance tasks include:
 Checking File System Integrity: Use fsck to check and repair file system
inconsistencies.
 Monitoring Disk Space: Keep an eye on available space using tools
like df and du.
 Backup and Restore: Regularly back up critical data and restore as
needed.
 Tuning File System Parameters: Adjust parameters like block size,
journal options, and inodes.
 Defragmentation (for certain file systems): Fragmentation can impact
performance; defragment if necessary.

3.1.3 Swap

Linux Swap is a crucial component in the world of Linux operating systems. Let
me explain it in a bit more detail.

1. What Is Linux Swap?


o The Linux Kernel divides RAM into chunks of memory. When your system
7
Page

runs out of physical RAM, it employs a process called swapping. During


swapping, the Linux Kernel uses a portion of your hard disk space (known
as swap space) to store information from RAM. This frees up some RAM
space for other processes.
o When you install a Linux distribution, the installation wizard typically
prompts you to allocate space for the system and another portion for swap.
o Why Use Swap?
 Extending RAM: Swap provides additional memory when your RAM is
exhausted, allowing processes to continue running.
 Recommended for Low RAM: If your computer has less than 1GB of
RAM, using swap is especially recommended.
 Safety Net: Even if you have ample RAM, having swap space acts as a
safety net. Without it, when RAM is full, your system might crash.
 Slower Than RAM: Keep in mind that swap space is slower than RAM, so
it won’t make your computer faster. It helps overcome RAM limitations.
o Creating Swap Partition:
 During Linux installation, it’s advisable to create a swap partition. Here are
the recommended sizes:
 If you have 1GB of RAM or less, make the swap partition twice the size of RAM.

 For 2GB to 4GB of RAM, allocate a swap partition half the size of RAM.
 If you have more than 4GB of RAM, a 2GB swap partition is sufficient.
 You can check your swap type and size using the command: swap on.
 Example: My system has a 2GB swap partition1.
o Creating Swap File:
 Alternatively, you can create a swap file after installation. The modern
Linux Kernel allows swapping to a file instead of a partition.
8
Page

1. Check Current Swap Usage:


o First, verify if swap is currently active. Open a terminal and run the command:
o swapon --show
o If it displays any swap devices or files, your system is using swap.
2. Turn Off Swap:
o To temporarily disable swap (until the next reboot), use the following command:
o sudo swap off -a
o This command deactivates all swap devices/files.
3. Permanently Disable Swap:
o To permanently disable swap, follow these steps:
 Edit the /etc/fstab file using a text editor (such as nano or vim):
 sudo nano /etc/fstab
 Locate the line that defines your swap partition or swap file. It
will look something like:
 UUID=<swap_UUID> none swap sw 0 0
or
/path/to/swapfile none swap sw 0 0
 Comment out (add a # at the beginning of) that line.
 Save the file and exit the text editor.
 Run the following command to apply the changes:
 sudo swapon --all --verbose
4. Reboot:
o After making these changes, reboot your system for the changes
to take effect:
9
Page

o sudo reboot
Remember that disabling swap can impact system stability if
your RAM usage exceeds its capacity. Only proceed if you
understand the implications and have sufficient physical
Determining Disk usage with df and du
3.1.4 Configure Disk quotes
Certainly! Let’s delve into disk usage and explore how the df command helps us monitor it in
Linux.
1. Understanding df Command:

o The df command primarily checks disk usage on mounted


filesystems. When you run df without specifying a file name, it
displays the space available on all currently mounted
filesystems.
o By default, it shows disk space in 1K blocks:
o $ df
o Filesystem 1K-blocks Used Available Use% Mounted on
o devtmpfs 883500 0 883500 0% /dev
o tmpfs 913840 168 913672 1% /dev/shm
o tmpfs 913840 9704 904136 2% /run
o /dev/sda1 1038336 260860 777476 26% /boot
o To make the output more human-readable, use the -h or --
human-readable option:
o $ df -h
10

o Filesystem Size Used Avail Use% Mounted on


Page

o devtmpfs 863M 0 863M 0% /dev


o tmpfs 893M 168K 893M 1% /dev/shm
o ...
o /dev/sda1 1014M 255M 760M 26% /boot
2. Inodes (Index Nodes):
o In addition to space, df can also show inodes (used to track files
and directories). Use the --inodes or -i option:
o $ df -ih
o Filesystem Inodes IUsed IFree IUse% Mounted on
o devtmpfs 216K 393 216K 1% /dev
o tmpfs 224K 3 224K 1% /dev/shm
o /dev/sda1 512K 310 512K 1% /boot
3. Total Available Space:
o To omit non-essential entries and get a total, use the --
total option:
o $ df --total
o Filesystem 1K-blocks Used Available Use% Mounted on
o devtmpfs 883500 0 883500 0% /dev
o tmpfs 913840 168 913672 1% /dev/shm
o /dev/sda1 1038336 260860 777476 26% /boot
Total 17811456 7193312 10618144 41%

3.2 . Logical volume management and RAID


11

RAID in Linux can be implemented in multiple levels, each offering distinct


Page

benefits. RAID 0 focuses on performance, RAID 1 on mirroring for redundancy, RAID 5


and 6 provide a balance of performance and redundancy, while RAID 10 offers a
combination of mirroring and striping. Understanding these levels is crucial for selecting
the most suitable RAID configuration for your needs

Certainly! Let’s delve into RAID and its configuration in Linux.


1. RAID (Redundant Array of Independent Disks):
o RAID is a technology that combines multiple physical disks into a single
logical unit to improve performance, redundancy, or both.
o It provides fault tolerance, data redundancy, and increased storage
performance.
o There are two main types of RAID: Hardware RAID (built using
dedicated RAID controllers) and Software RAID (configured within the
operating system).
2. Software RAID in Linux:
o Software RAID is managed by the operating system using tools
like mdadm (Multiple Device Administration).
o It uses system resources (CPU, RAM) and is cost-effective.
o Software RAID levels include:
 RAID 0 (Striping): Data is split across multiple disks for improved
performance but without redundancy.
 RAID 1 (Mirroring): Data is duplicated on two or more disks for redundancy.
 RAID 5 (Striping with Parity): Provides both performance and
redundancy by distributing data and parity information across multiple disks.
 RAID 6 (Striping with Double Parity): Similar to RAID 5 but with
an additional parity disk for better fault tolerance.
12

 RAID 10 (Combination of RAID 1 and RAID 0): Mirrored pairs are


striped for both performance and redundancy.
Page
3. Configuring Software RAID in Linux:
o Step 1: Install mdadm:
 Ensure that the mdadm package is installed on your system.
o Step 2: Create RAID Arrays:
 Use mdadm to create RAID arrays (e.g., RAID 1, RAID 5, etc.).
 Specify the RAID level, devices, and other parameters.
o Step 3: Format and Mount the RAID Array:
 Format the RAID array using a filesystem (e.g., ext4).
 Mount it to a directory in the filesystem.
o Step 4: Monitor and Manage:
 Use /proc/mdstat to check the status of RAID devices.
 Use mdadm commands to manage arrays (add/remove disks, grow
arrays, etc.).
4. Example Commands:
o To create a RAID 1 array with two disks:
o sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdX1 /dev/sdY1
o To format and mount the RAID array:
o sudo mkfs.ext4 /dev/md0
sudo mount /dev/md0 /mnt/myraid
3.2.1 Implement LVM concept, creating logical volumes (LVS), manipulating
VGS and LVS

Certainly! Let’s explore the world of Logical Volume Manager


(LVM) in Linux.

LVM provides a flexible way to manage storage by abstracting


13

physical disks into logical volumes. Here are the key concepts:
Page
1. Physical Volumes (PVs):

o PVs are recognized disks or partitions.

o They serve as the building blocks for LVM.

o You initialize PVs using tools like pvcreate.

2. Volume Groups (VGs):

o VGs are collections of PVs.

o They create larger storage pools.

o You can combine multiple PVs into a VG using vgcreate.

3. Logical Volumes (LVs):

o LVs are the final storage units in LVM.


o They are functionally equivalent to partitions on a physical disk but offer more flexibility.

o LVs are created from VGs.

o You can create different types of LVs based on your needs.

Now, let’s dive into creating and manipulating LVs:

Creating Logical Volumes

1. Linear Logical Volume:

 The default LV type.


14

 Combines one or more disks into a single usable storage unit.


Page
 Example: Let’s create a linear LV named lv_linear from
our existing VG called LVMvgTEST:

 sudo lvcreate -L 500M -n lv_linear LVMvgTEST

Output (using lvdisplay or lvs):

 LV Path: /dev/LVMvgTEST/lv_linear

 LV Size: 500.00 MiB

2. Striped Logical Volume:

 Spreads data across multiple disks for improved performance.

 Useful for large files or databases.

 Created using lvcreate with the --stripes option.

3. Mirrored Logical Volume:

 Provides redundancy by duplicating data across multiple disks.

 Enhanced data protection.

 Created using lvcreate with the --mirrors option.

Manipulating LVs

 To display LV information:

 sudo lvdisplay or sudo lvs


15

 To extend an LV (e.g., adding more space):


Page

 sudo lvextend -L +1G /dev/LVMvgTEST/lv_linear


 To resize the filesystem on an LV:

 sudo resize2fs /dev/LVMvgTEST/lv_linear

Remember, LVM allows dynamic resizing and management of


LVs without disrupting services. Explore further and enjoy the
flexibility LVM offers!

3.2.2 Advanced LVM concept (i.e. system config-lvm)


Certainly! Let’s explore the advanced concepts related to Logical Volume
Manager (LVM), specifically focusing on the system-config-lvm utility.
1. System-config-lvm:
o system-config-lvm provides a graphical interface to manage LVM
tools and related utilities.
o It is particularly useful for non-emergency storage administration.
o With this tool, you can easily manage your logical volumes and
filesystem configurations using a few mouse clicks.
2. Installation and Access:
o system-config-lvm does not come pre-installed, so you’ll need to install it first.
o On Red Hat-based systems, you can install it using the following command:
o sudo yum install system-config-lvm
o Once installed, you can access the application in one of the following ways:
 From the menu panel: System → Administration → Logical Volume Management

 From the terminal: Type system-config-lvm


3. Main Window:
o When you open system-config-lvm, you’ll see the main window.
16

o This window allows you to manage logical volumes within X windows or graphically.
Page
o It displays both the logical view (individual logical volumes) and
the physical view (volume groups and physical volumes).
4. Renaming Logical Volumes:
o Suppose you want to rename a logical volume (LV). For example, let’s
rename LogVol03 to Swap.
o Follow these steps:
 Select the respective logical volume from the list (not the
image) in the left-side column.
 Click on the Edit Properties button.
 In the Edit Logical Volume window, modify the LV name,
size (in extents, gigabytes, megabytes, or kilobytes), and use
any remaining space available in the logical volume group.
5. Example Configuration:
o During installation, you might encounter a volume group with logical
volumes like:
 /boot (Ext3) file system
 LogVol00 (LVM) containing the root (/) directory
 LogVol02 (LVM) containing the home (/home) directory
 LogVol03 (LVM) for swap
o These logical volumes exist on the same physical volume
(e.g., /dev/hda2).

Remember that system-config-lvm simplifies LVM management, making it easier


to handle logical volumes and storage configurations. Explore its features and
enjoy efficient storage administration!
17
Page

3.2.3 RAID concept (create and managing a RAID-5 Array)


Certainly! Let’s delve into the concept of RAID (Redundant Arrays of Independent
Disks) and explore how to create and manage a RAID-5 array.RAID Overview:

 RAID combines multiple physical disks into a single logical unit to enhance
performance, redundancy, or both.

 It operates as a layer between raw drives/partitions and the filesystem.

 RAID is valuable for data redundancy and performance gains.

When Is RAID a Good Idea?

1. Data Redundancy:

o RAID helps increase data availability.

o During drive failures, data remains accessible, minimizing disruptions.

o Note that RAID is not a substitute for backups; separate backups are always
recommended.

2. Performance Enhancement:

o Storage I/O speed is often limited by a single disk.

o RAID allows data distribution or redundancy, improving throughput.

o Write operations can also benefit from certain RAID configurations.

RAID-5 Array:

 Requires at least three disks.

 Utilizes striping to divide data across all hard drives.

 Includes additional distributed parity data across all disks.

 Handles the loss of any one disk in the array.

 Parity blocks allow complete data reconstruction if a disk fails.


18

 Each disk holds a balanced amount of parity information.


Page
Creating a RAID-5 Array (Using mdadm):

1. Install Necessary Utilities:

o Begin by installing the required RAID utilities, such as mdadm.

2. Create the RAID Array:

o Use mdadm to create the RAID-5 array.

o Specify the disks involved (at least three) and their order.

o Example command:

o sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdX1


/dev/sdY1 /dev/sdZ1

3. Format and Mount:

o Format the RAID array with a filesystem (e.g., ext4).

o Mount it to a directory in the filesystem.

Managing RAID Arrays:


 Monitoring:

o Check the status of RAID devices using /proc/mdstat.

 Expanding:

o To add more disks or increase capacity, use mdadm commands.

 Resizing Filesystem:

o Resize the filesystem on the RAID array using appropriate tools.


19

Remember that RAID-5 provides both redundancy and performance benefits. Explore further
Page

and enjoy efficient storage management!


End ….
20
Page

You might also like