0% found this document useful (0 votes)
32 views3 pages

Linux Disk Management & Formatting

Uploaded by

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

Linux Disk Management & Formatting

Uploaded by

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

Linux Disk Management & Formatting.

md 2024-01-19

Linux Disk Formatting and Management


1. Disk Partitioning and LVM
1.1 lsblk: List Block Devices

lsblk

Displays information about block devices, their mount points, and sizes.

1.2 pvcreate: Physical Volume Creation

sudo pvcreate /dev/sdb

Initializes a physical volume on the /dev/sdb disk.

1.3 vgcreate: Volume Group Creation

sudo vgcreate myvg /dev/sdb

Creates a volume group named myvg using the physical volume /dev/sdb.

1.4 vgs: Display Volume Groups

vgs

Shows information about existing volume groups.

1.5 vgdisplay: Display Volume Group Details

vgdisplay myvg

Provides detailed information about the volume group myvg.

1.6 lvcreate: Logical Volume Creation

sudo lvcreate -L 10G -n mylv myvg

1/3
Linux Disk Management & Formatting.md 2024-01-19

Creates a logical volume named mylv with a size of 10GB in the volume group myvg.

1.7 lvs: Display Logical Volumes

lvs

Lists information about logical volumes.

1.8 mkfs: Create a File System

sudo mkfs.ext4 /dev/myvg/mylv

Formats the logical volume /dev/myvg/mylv with the ext4 file system.

1.9 /etc/fstab: File System Table

The /etc/fstab file contains information about disk drives and partitions. Edit it to automatically mount
partitions at boot.

Example entry:

/dev/myvg/mylv /mnt/mydata ext4 defaults 0 0

1.10 mount -a: Mount All File Systems

sudo mount -a

Mounts all file systems listed in /etc/fstab.

1.11 systemctl daemon-reload: Reload Systemd Manager Configuration

sudo systemctl daemon-reload

Reloads the Systemd manager configuration after making changes.

1.12 LVM Examples

Creating a Physical Volume

sudo pvcreate /dev/sdc

2/3
Linux Disk Management & Formatting.md 2024-01-19

Extending a Volume Group

sudo vgextend myvg /dev/sdc

Adding a New Logical Volume

sudo lvcreate -L 5G -n mynewlv myvg

Displaying Logical Volume Information

lvdisplay /dev/myvg/mynewlv

2. Linux File Systems


There are various file systems like ext4, xfs, btrfs, etc. Each has its own features and use cases. For example,
creating an ext4 file system:

sudo mkfs.ext4 /dev/sdc1

3. /etc/yum.repos.d: YUM Repository Configuration


This directory contains configuration files for YUM repositories. Create a new repository file, e.g.,
myrepo.repo:

[myrepo]
name=My Custom Repository
baseurl=http://example.com/repo
enabled=1
gpgcheck=0

Add more examples with different repository configurations to /etc/yum.repos.d/ based on your specific
needs.

These commands and configurations provide a comprehensive guide for Linux disk management, covering
logical volume management (LVM), file system creation, mounting, and YUM repository configuration. Always
exercise caution when working with disk-related commands to avoid data loss.

3/3

You might also like