LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2014, 03:24 PM   #1
samalchow
LQ Newbie
 
Registered: Jan 2014
Location: Colorado
Distribution: Debian/Centos
Posts: 18

Rep: Reputation: Disabled
Re-sizing filesystem on Virtualbox Centos


I'm having a hell of a time here, not sure what is needed. So I've created a Centos VM on VirtualBox with the original HDD size of 8GB. I've since needed to make it larger, which was made to 25GB. After trying to increase the
"/dev/mapper/VolGroup-lv_root" filesystem I get the following error:

[user@services ~]$ sudo lvextend -L+5GB /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 11.71 GiB
Insufficient free space: 1280 extents needed, but only 0 available

What am I missing here? I see that "/dev/sda" has increased but nothing to "/dev/mapper/VolGroup-lv_root". I'm lost of what needs to be completed.

[user@services ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 6.7G 1.5G 4.9G 23% /
tmpfs 250M 0 250M 0% /dev/shm
/dev/sda1 485M 50M 410M 11% /boot
[user@services ~]$ sudo fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0005fd2a

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1045 7875584 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 7205 MB, 7205814272 bytes
255 heads, 63 sectors/track, 876 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 855 MB, 855638016 bytes
255 heads, 63 sectors/track, 104 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[user@services ~]$ sudo lvextend -L+5GB /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 11.71 GiB
Insufficient free space: 1280 extents needed, but only 0 available
 
Old 01-26-2014, 04:31 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,412

Rep: Reputation: Disabled
LVM is a multi-layered storage system:
the file system resides on a
block device called a Logical Volume, created from
a Volume Group, which is a pool of
Physical Volumes, which in turn are either
devices and/or partitions
You've extended the device. You must now:
  • either extend the existing partition (with fdisk or parted or whatever) and the Physical Volume (with pvresize), or create a new partition and Physical Volume from the available free space
  • add the new Physical Volume to the existing Volume Group (with vgextend), or do nothing if you extended the existing Physical Volume, as that will cause the Volume Group to grow automatically
  • extend the Logical Volume (with lvextend)
  • extend the file system (with resize2fs if your're using ext2/3/4, or the equivalent tool for your filesystem of choice)
 
Old 01-26-2014, 06:55 PM   #3
samalchow
LQ Newbie
 
Registered: Jan 2014
Location: Colorado
Distribution: Debian/Centos
Posts: 18

Original Poster
Rep: Reputation: Disabled
Well I want to extend the existing partition. So running fdisk -l shows the following:

Disk /dev/sda: 26.8 GB, 26843545600 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1045 7875584 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 7205 MB, 7205814272 bytes

Disk /dev/mapper/VolGroup-lv_swap: 855 MB, 855638016 bytes

This is where I'm still confused in this Linux world. So does this show that my system acts like there is 3 different drives? And that sda is partitioned twice to sda1 and sda2?
 
Old 01-26-2014, 09:01 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,035

Rep: Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912
Yes, the (virtualised) /dev/sda is partitioned into 2 partitions - presumably sda1 for /boot, and sda2 is for your LVM vg (currently holding lvs root and swap). For what you need to do, re-read post #2, then have a look at Logical_Volume_Manager_Administration on the RHEL site for a description of the LVM architecture as well as commands for admin. LVM is another layer of (device) virtualisation on top of everything else you've got virtualised.
 
Old 01-26-2014, 09:05 PM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,412

Rep: Reputation: Disabled
/dev/sda is the drive, and it contains the partitions /dev/sda1 (a small boot partition with a file system containing the kernel and an initrd) and /dev/sda2 (an LVM Physical Volume).

The device nodes in /dev/mapper represent virtual LVM devices, and do not point to physical drives. The names indicate that you have one Volume Group called "VolGroup", and from this volume group, two Logical Volumes have been created: "VolGroup-lv_root" (must be the root file system) and "VolGroup-lv_swap" (a swap partition).

So you have one drive with two partitions, the latter of which is an LVM Physical Volume, serving as the only member of a Volume Group.

According to fdisk, the 2nd partition starts at block 64 and ends at block 7875584. You need to alter this partition so that it still starts at block 64, but covers the entire disk. Here's how you can do that:
  1. Start fdisk with fdisk /dev/sda
  2. Delete partition 2 by typing
    • d [Enter] (delete partition)
    • 2 [Enter] (the partition number)
  3. Recreate partition 2 by typing
    • n [Enter] (new partition)
    • p [Enter] (primary partition)
    • 2 [Enter] (the partition number)
    • 64 [Enter] (the start sector)
    • [Enter] (the end sector; the default is the end of the disk)
  4. View the partition table with p [Enter]
  5. If all looks OK, write the partition table to disk with w [Enter]
The partition has now been extended. fdisk doesn't touch the actual data on the disk when partitions are deleted and created, so as long as you create a new partition with the same number (2) starting at the same sector (64), the data inside that partition will still be valid.

The next step is to extend the data structures inside the Physical Volume to cover the entire partition, but you'll probably have to reboot first. You could try running partprobe, but you'll most likely get a message saying the partitions are in use, so the kernel will still be using the old partition table.
 
Old 01-28-2014, 07:28 PM   #6
samalchow
LQ Newbie
 
Registered: Jan 2014
Location: Colorado
Distribution: Debian/Centos
Posts: 18

Original Poster
Rep: Reputation: Disabled
Alrighty so I've extended to the partition but still unable to extend the LVM

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0005fd2a

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 3263 25697023+ 83 Linux



sudo lvextend -L+5G /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 11.71 GiB
Insufficient free space: 1280 extents needed, but only 0 available


I've noticed the the ID for sda2 has changed, along with the System stating Linux instead of LVM.
 
Old 01-28-2014, 07:39 PM   #7
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,412

Rep: Reputation: Disabled
The type identifier isn't all that important, but you can easily change it back (fdisk /dev/sda, t, 2, 8e, w).

Did you run pvresize /dev/sda2? (No parameters are required; the default is to extend the PV to cover the entire device/partition).
 
Old 01-28-2014, 07:51 PM   #8
samalchow
LQ Newbie
 
Registered: Jan 2014
Location: Colorado
Distribution: Debian/Centos
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Ser Olmy View Post
The type identifier isn't all that important, but you can easily change it back (fdisk /dev/sda, t, 2, 8e, w).

Did you run pvresize /dev/sda2? (No parameters are required; the default is to extend the PV to cover the entire device/partition).

i did not.....

So ran the pvresize command with success. NOW new issues.

Increased by 5GB to verify it worked, which it did.

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 12G 1.5G 9.5G 14% /
tmpfs 250M 0 250M 0% /dev/shm
/dev/sda1 485M 50M 410M 11% /boot

I've increased to 24.4GB but running df still shows 12G

Disk /dev/mapper/VolGroup-lv_root: 24.4 GB, 24385683456 bytes
255 heads, 63 sectors/track, 2964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Old 01-28-2014, 08:25 PM   #9
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,412

Rep: Reputation: Disabled
Of course. The device on which the file system lives is now bigger than it used to be, but the file system structures remain unchanged.

The final step is to extend the file system. If you're running ext2/3/4, resize2fs /dev/mapper/VolGroup-lv_root should do the trick.

The "ext" family of file systems can be extended while mounted (online). Other file systems may require unmounting.
 
Old 01-28-2014, 08:39 PM   #10
samalchow
LQ Newbie
 
Registered: Jan 2014
Location: Colorado
Distribution: Debian/Centos
Posts: 18

Original Poster
Rep: Reputation: Disabled
That did it. Thanks all for the great help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem With VirtualBox On Centos 6.2 mhm233 Linux - Virtualization and Cloud 7 05-15-2012 12:15 PM
CentOS on Virtualbox joshuayip Linux - Newbie 4 09-22-2011 09:07 PM
CentOS in one VirtualBox, Windows in another - can I set up Samba in the CentOS VB? ismism Linux - Newbie 10 08-08-2010 04:34 PM
virtualbox install of centos bic Linux - Software 1 06-15-2008 10:30 PM
Sizing filesystem? Randux Slackware 19 03-03-2006 07:04 PM


All times are GMT -5. The time now is 12:11 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration