Skip to content

This repository provides a comprehensive guide on managing disk partitions, creating file systems, and configuring logical volumes in Linux. It covers essential topics such as MBR and GPT partitioning, file system mounting, and advanced techniques like LVM (Logical Volume Management) and swap space creation.

Notifications You must be signed in to change notification settings

panwar100/Partitioning-and-Mounting-Linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Partitioning-and-Mounting-Linux

This repository provides a comprehensive guide on managing disk partitions, creating file systems, and configuring logical volumes in Linux. It covers essential topics such as MBR and GPT partitioning, file system mounting, and advanced techniques like LVM (Logical Volume Management) and swap space creation.

Table of Contents

1.Basic Partitioning

2.File System Creation and Mounting

3.Dynamic Partitioning (LVM)

4.Swap Creation

1.Basic Partitioning

a)Concepts:

  • Partition Types:
    • MBR (Master Boot Record): Supports up to 4 primary partitions.
    • GPT (GUID Partition Table): Allows up to 128 partitions and supports larger disk sizes.
  • Primary Partition: Contains bootable and critical system files.
  • Extended Partition: Used to create additional logical partitions.

Adding a Hard Disk to Your VMware Virtual Machine

1.Go to setting

  • click on Settings and then click Add.

Screenshot from 2024-12-07 21-22-34 2.Select Hard Disk

  • Choose Hard Disk and click Next. Screenshot from 2024-12-07 21-22-52

3.Choose the Disk Type

  • Select SATA and click Next. Screenshot from 2024-12-07 21-23-00

4.Create a New Virtual Disk.

  • Choose Create a new virtual disk and click Next. Screenshot from 2024-12-07 21-23-15

5.Specify the Disk Size

  • Enter the desired disk size and click Next. Screenshot from 2024-12-07 21-24-09

6.Finish Adding the Disk

  • Review the settings and click Finish. Screenshot from 2024-12-07 21-24-34

7.Verify the New Hard Disk

  • You will now see the newly added hard disk in the list. Screenshot from 2024-12-07 21-24-47

8.Add Additional Disks (Optional)

  • Repeat the steps to add more hard disks if needed. Screenshot from 2024-12-07 21-26-23

Commands:

b)View Disks and Partitions:

Lists all block devices

Screenshot from 2024-12-07 22-02-31

Lists partition details

Screenshot from 2024-12-07 22-03-00

c)Create a New Partition with fdisk:

Screenshot from 2024-12-07 22-06-21

Steps:

Press n for a new partition.

Choose p for Primary or e for Extended.

Specify Partition Number (default: 1).

Define First and Last Sector (e.g., +8G for size).

Save with w.


Verify the changes

Screenshot from 2024-12-07 22-07-24

d)Partition Types and Operations:

Screenshot from 2024-12-07 22-10-55 Screenshot from 2024-12-07 22-11-37 Screenshot from 2024-12-07 22-11-56

View Partitions: p

List Types: l

Change Type: t (e.g., switch 83 to 82 for swap)

Delete Partition: d

Show Free Space: F

Detect Errors: v

Quit Without Saving: q

e)Using gdisk:

Screenshot from 2024-12-07 22-15-57

Steps:

Press n for a new partition.

Enter Partition Number (default: 1).

Define First and Last Sectors (e.g., +15G for size).

Enter Hex Code for Type (e.g., 8300 for Linux filesystem).

Save with w.


Verify the changes.

Screenshot from 2024-12-07 22-16-53

2.File System Creation and Mounting

a)Create File System:

Screenshot from 2024-12-07 22-24-33

b)Mount Partition:

Screenshot from 2024-12-07 22-25-56

Screenshot from 2024-12-07 22-26-26

It is temporary; it will be gone after a restart.

c)Temporary and Persistent Mounting:

  • Check Mounted Disks:

Screenshot from 2024-12-07 22-28-47

  • View UUID:

Screenshot from 2024-12-07 22-30-03

  • Add to /etc/fstab for persistent mounting:

vim /etc/fstab

Screenshot from 2024-12-07 22-32-49

  • Apply changes:

Screenshot from 2024-12-07 22-34-43


  • Unmount and Clean Up All:

Screenshot from 2024-12-07 22-39-11

Screenshot from 2024-12-07 22-40-36

Choosing the Right File System

  • Enterprise storage: XFS, ZFS, or Btrfs.
  • Desktop usage: ext4.
  • Compatibility: FAT32 or exFAT.
  • Snapshots and advanced features: Btrfs or ZFS.

3.Dynamic Partitioning (LVM)

a)Prepare Physical Volumes:

Screenshot from 2024-12-07 22-42-58

n # Create new partition

p # Print partition

w # Write and exit

Repeat for /dev/sdb, /dev/sdc.

Screenshot from 2024-12-07 22-44-18

b)Initialize Physical Volumes:

Screenshot from 2024-12-07 22-46-01

c)Create Volume Group:

Screenshot from 2024-12-07 22-46-48

d)Create Logical Volume:

Screenshot from 2024-12-07 22-48-03

Screenshot from 2024-12-07 22-48-54

e)Format and Mount:

Screenshot from 2024-12-07 22-49-39

Screenshot from 2024-12-07 22-50-23

f)Clean Up:

Screenshot from 2024-12-07 22-51-58

4.Swap Creation

a)Create Swap Partition:

Screenshot from 2024-12-07 22-54-41

Change Type: t

Hex Code: 8200 (for swap)

w # Save

b)Enable Swap:

Screenshot from 2024-12-07 22-58-23

c)Verify:

Screenshot from 2024-12-07 22-59-20

Screenshot from 2024-12-07 23-00-06

d)Disable Swap:

Screenshot from 2024-12-07 23-00-40

About

This repository provides a comprehensive guide on managing disk partitions, creating file systems, and configuring logical volumes in Linux. It covers essential topics such as MBR and GPT partitioning, file system mounting, and advanced techniques like LVM (Logical Volume Management) and swap space creation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published