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

securitywing

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:

  1. Project Manager Interview Questions and Answers
  2. Cisco Router Security Check for Auditor
  3. How to Share Internet Connection using Android Mobile Tethering
  4. Docker Command List with Examples in Linux

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

Primary Sidebar

Please help us sharing

Categories

  • AWS
  • Basics
  • Containers
  • Cryptocurrency
  • Cyber
  • Internet Security and Safety
  • IS Audit
  • IT Security Exams
  • Law & Human Rights
  • Network Security Tips
  • Off Track
  • Social Media Governance
  • Tech Comparisons
  • Tech Stack Suitability
  • Telecom
  • Tutorial

CISSP Sample Test

Take a CISSP Sample Test

CISA Sample Test

CISA IT governance Sample test

Please Follow Us

Contact us for Ads

Go to Contact Form

Search

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

audit AWS backup basics browser check cisco cloud computer configuration cyber data database email gmail hsrp ids iis informaiton internet kubernetes linux load balancing malware microsoft network protection redundancy risk router security security tips server social media SSL switch test tools vpn vrrp web webserver website windows wordpress

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