• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

securitywing

Menu
  • About
  • Must Read
      • IIS Performance Boost
      • RFID Security
      • Web App Security Testing
      • How to Secure Home Network
      • Prevent Cross-Site Scripting Attacks
      • Renew Self-Signed Certificates
      • Penetration Testing Tools
      • VPN Concentrator
      • Forensic Investigation Tools
      • Digital Certificates
      • Cloud Security Issues
      • Advanced Evasion Prevention
      • Firewall Types
      • Tips to Prevent Data Exfiltration
      • Classified Info Handling
      • MySQL Security
      • Definition of 7 Types of Malware
      • VOIP Security
      • Why Antivirus Software Fails
      • 15 Network Security Vulnerabilities
      • Web App Security
      • IT Security Standards
      • Types of Virtualization
      • Android Security
      • Digital Signature
      • Advanced Malware Protection
    • Close
  • Consultancy
  • Contact

How to Extend Linux LVM by Adding a New Hard Disk

by wing

You may need to add new disk to your Linux LVM for various reasons such as for adding capacity for your existing applications or new applications. This post aims to show you how you can add a new disk to your existing LVM as well as to a new LVM. The difference between adding a new disk to a new LVM and to an existing LVM is that in the latter case you do not have to create a new volume group using vgcreate command.

Required steps to expand Linux LVM:

  1. Add the new disk and then run ‘fdisk’ command to see the status of the newly added disks. At this stage if you run the “df -h” command you will not see any new disk because it was not initialized.

fdisk   –l

 

  1. To initialize the disk, run the following command.

pvcreate     /dev/sdb     /dev/sdc

initialize a physical volume in linux

 

 

  1. Create a new volume group. If you want to add the new disk to you existing volume then type vgdisplay command and note the volume group name that you need to use to create logical volume shown in step 4. To create a new volume named TestVG and to add the new disks to it use the command as shown below.

root@debian:/# vgcreate TestVG  /dev/sdb   /dev/sdc

create a new volume group in linux

 

After creating the new volume, check the new volume group using vgdisplay command.

volume group display command in linux

 

  1. Create a logical volume. To carve out a new logical volume inside the volume group use:

root@debian:/# lvcreate   -n  TestLV   -L    4.29G   TestVG

create logical volume in linux

  1. Next create a file system for the logical volume. Unless you create file system, you will not be able to use your logical volume.

root@debian:/# mkfs.ext3    /dev/TestVG/TestLV

create a file system in linux lvm

 

  1. Mount the new logical volume in a directory. Create a new directory or mount it in an existing directory.

 

root@debian:/# mkdir mydata

 

To mount the new LVM in the new directory, type the following command.

root@debian:/# mount      /dev/TestVG/TestLV      /mydata

mount a directory to a LVM

Now, use df –h command to see the new LVM space.

Since we have created a new volume group (TestVG), we do not have to use lvextend command in order to extend the LVM partition. If TestVG were an existing volume group in which we added two new disks, then we had to use the following two commands to expand the LVM and to extend the file systems.

root@debian:/# lvmextend    -L    +4.3G     /dev/TestVG/TestLV

root@debian:/# resize2fs      /dev/TestVG/TestLV

 

Adding a second hard disk to an existing volume group.

For instance, you have only one hard disk in your Linux system, and need to more space in order to add capacity.

#fdisk /dev/sbd

#Press ‘n’ to create a new partition.

# press ‘p’ for creating primary partition

#press enter to assign the size of default first sector

# +20B (for the last sector; it will add 20GB of space)

# Press ‘w’ to write

#pvcreate /sdb1

#vgdisplay

#vgextend  debian-vg  /dev/sdb1

 

For example you want to extend the /var directory

# lvextend   /dev/debian-vg/var    /dev/sbd1

# resize2fs    /dev/debian-vg/var

How to migrate data from Linux drive to SAN (storage area network)

At first, you need to initialize the SAN device using the following command:

#pvcreate /dev/sde

 

For example, your current volume group name is TestVG. Extend this volume group for SAN.

# vgextend    TestVG       /dev/sde

# pvmove      /dev/sdc             /dev/sde

# pvmove        /dev/sdd             /dev/sde

 

Now, you can reduce the local drive.

#vgreduce  TestVG    /dev/sdc     /dev/sdd

Mount a USB drive to expand Linux disk space

#mkdir /mnt/usb

#mount    /dev/sdb1     /mnt/usb

#cd /mnt/usb

Related Posts:

  • How to audit Linux CentOS Security with Lynis
  • How to Disable Root Login Via SSH in Linux
  • Linux Security Basics

Filed Under: Off Track Tagged With: hard disk, linux, lvm

Primary Sidebar

CISSP Sample Test

Take a CISSP Sample Test

CISA IT governance Sample test



Twitter Follow @securitywing

Categories

  • AWS
  • containers
  • Internet Security and Safety
  • IS Audit
  • IT Security Exams
  • Network Security Tips
  • Off Track
  • Telecom
  • Tutorial

Pages

  • About
  • Best IT Security Certification Exam
  • CISA IT governance Sample test
  • CISA Sample Test
  • CISSP Sample Test Online
  • Consultancy
  • Contact

Popular Posts

  • 8 Effective Ways to Impro...
  • 3 Steps to Install Miniku...
  • Yahoo Mail Security Setti...
  • How to Setup AWS CloudFro...
  • 3 Simple Steps to Capture...
  • 5 Steps to Setup a Nexus3...
  • How to Configure AAA (TAC...
  • How to Configure SNMP in...
  • How to Install AWS CLI an...
  • How to Renew Self-Signed...

Footer

Copyrights

Protected by Copyscape Duplicate Content Detection Software

Securitywing.com reserves the copyrights of all of its published articles.No contents of this site is permitted to be published to anywhere else in the Internet.If any contents are found in any other websites, securitywing reserves the rights to file a DMCA complaint. But you have the right to use the link of any relevant article of this site to point from your website if you consider that it might improve the quality of your article.

Tags

antivirus audit AWS backup browser check cisco cloud computer cyber data database encryption firewall home hsrp ids informaiton internet intrusion it kubernetes linux load balancing malware network protection putty risk router security security tips server ssh SSL switch tools virus vpn vulnerability web webserver website windows wordpress

Copyright © 2010-2023 ·All Rights Reserved · SecurityWing.com