LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 02-25-2018, 05:36 AM   #1
framacomputer
LQ Newbie
 
Registered: Jan 2010
Posts: 25

Rep: Reputation: 0
Virtual Machine Debian 8 64bit expand partition


Hi, i just updated the disk size from 20 to 40gb, and i'm looking how to expand the partition withous shutdown the system, i just need to have only one partition of total available space.

~# parted /dev/sda print
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 500MB 499MB primary ext2 boot
2 500MB 10.7GB 10.2GB primary lvm
3 10.7GB 21.5GB 10.7GB primary lvm

#fdisk -l

Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1606d709

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 976895 974848 476M 83 Linux
/dev/sda2 976896 20969471 19992576 9.5G 8e Linux LVM
/dev/sda3 20969472 41943039 20973568 10G 8e Linux LVM

Disk /dev/mapper/vg-lv_root: 17.7 GiB, 18975031296 bytes, 37060608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/vg-lv_swap: 1.9 GiB, 1996488704 bytes, 3899392 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Thanks.
 
Old 02-25-2018, 06:59 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
What distribution / version are you running?

It would be nice to see the output from the command pvdisplay and vgdisplay. I assume that you originally ran out of space in your root VG and added sda3.

To remove sda3 you need to move enough files from /(root) to go back to just using sda2 root VG which is around 7 GB. If you can not or do not want to move the files then I would suggest keeping sda2 and enlarging it to the added disk size. You can use parted and pvresize command to increase sda2.

Once the PV is resized you can resize the LV and then the filesystem itself(depends on the actual type).

All of the commands can be executed on a running system but as always make sure you have a good backup.

Last edited by michaelk; 02-25-2018 at 07:59 PM.
 
Old 02-25-2018, 07:56 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,153

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
You can't arbitrarily increase partitions - the space to increase it must be contiguous. And there is absolutely no point in even considering it in an LVM system. That's what LVM was designed to avoid.

Create a partition on the free space, do a pvcreate, add it to the vg, increase the lv, and it's all done. As you seem to be in the habit of doing this, better create an extended partition and use a logical partition for the pv - else next time there won't be a next time.
 
Old 02-26-2018, 08:45 AM   #4
LQParsons
Member
 
Registered: Feb 2010
Location: North of Boston, Mass (North Shore/Cape Ann)
Distribution: CentOS 7.0 (and kvm/qemu)
Posts: 91

Rep: Reputation: 22
Quote:
You can't arbitrarily increase partitions - the space to increase it must be contiguous. And there is absolutely no point in even considering it in an LVM system. That's what LVM was designed to avoid.
Sorry, you've got it backwards. LVM lets two (physically) non-contiguous APPEAR (logically) contiguous.
Quick Google should tell you what you need to know, for instance:
https://www.rootusers.com/lvm-resize...lvm-partition/

and:
https://linuxconfig.org/linux-lvm-lo...volume-manager

and lots more.

Remember there are two sides of the process (actually three):
(one) the KVM has to change the size to the VM
(two) the VM has to be made aware that their disk has changed size.
[The third side if is you have to physically change the size, like adding a disk to the LVM]

It's pretty straight forward when Linux is involved.
It's a bit painful if windows is involved and you need PowerShell.
With Apple's OS/X version of virtualization, it's almost one slider bar and everyone is all set.

Let us know how you make out!
 
Old 02-26-2018, 08:28 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,153

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Nope - what I said stands.

We are saying the same thing - read it (all) again.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I expand a partition less virtual drive while preserving the data? MissingPixels Linux - Hardware 1 11-19-2013 12:56 PM
[SOLVED] Increase LVM partition in virtual machine dirtyfishtank Linux - General 8 11-05-2013 05:43 AM
Can I use my virtual box machine that i have installed on my windows partition j0eh4x Linux - Software 2 09-04-2011 12:33 PM
Putting a virtual machine on a partition thus being able to boot into it. blacksiddis Linux - Virtualization and Cloud 9 05-03-2011 01:16 PM
Will apt-get installs 32bit debain package on 64bit debian/ubuntu machine ?? narendra1310 Linux - Software 1 03-09-2010 07:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 06:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration