How to Create a Partition in Linux

How to Create a Partition in Linux

Red Hat Linux   /   Feb 7th, 2023   /  A+ | a-
                  How to Create a Partition in Linux

Disk Partitioning in Linux?
Disk Partitioning is the process of dividing a disk into one or more logical areas, often known as partitions, on which the user can work separately. It is one step of disk formatting. If a partition is created, the disk will store the information about the location and size of partitions in the partition table. With the partition table, each partition can appear to the Operating System as a Logical Disk, and users can read and write data on those disks.
Advantages: The main advantage of disk partitioning is that each partition can be managed separately.
Why we need it?
  • To upgrade Hard Disk (to incorporate new Hard Disk to the system)
  • Dual Booting (Multiple Operating Systems on the same system)
  • Efficient disk management
  • Ensure backup and security
  • Work with different File System using the same system
  1. Mounting the file systems.
How to recover deleted Logical
If you have accidentally removed a logical volume (LV) or LVM meta data got corrupted or damaged in some way, it can be easily restored without losing the data using the ‘vgcfgrestore’ command.
By default, LVM automatically takes backup of its meta data whenever a configuration change occurs on all LVM devices using the ‘vgcfgbackup’ command.
  • /etc/lvm/backup : It contains a backup of the metadata, which taken after executing a command.
  • It contains metadata archives that were taken before executing a command.
What’s vgcfgbackup?
The vgcfgbackup command takes the configuration metadata from the LVM header of the disk and stores it in the default file location./etc/lvm/archive :
What’s vgcfgrestore?
The vgcfgrestore command restores the metadata of a volume group (VG) from the latest archive backup.
Checking existing LVMs:
Existing logical volumes (LV) can be listed using the blow command:
To list available logical volumes, run:
Command: lvs

Removing Logical Volume (LV):
We will remove the 'lv001' logical volume for demonstration purposes, which is the active logical volume listed in the above output.
Command: lvremove /dev/mapper/vg01-lv001

Recovering Logical Volume (LV):
Before restoring the deleted LVM, let’s identify the latest archive that contains the metadata of removed LVM. To do so, run the following command. It lists all VG metadata backups & archives.
Command: vgcfgrestore ---list vg01

Check if the deleted volume is successfully restored using the ‘lvscan’ command. Yes, it was restored but it’s in inactive state.
Command: lvscan

To activate logical volume, run:
Command:  lvchange -a y /dev/vg01/lv001

Finally, mount the logical volume and verify the data:
Command: mount /dev/mapper/vg01-lv001 /lvmtest


Mentor
Gandhar Bodas
Information and research are sources from internet.
Tags:  #Red Hat Linux #Operating System #nitsglobal #website #blog
 
Top