Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I tried to extend my partition with LVM, but not having much success. These are my HDD's in my server. The 2000GB is the new HDD. I would like to add it for my first HDD.

root@webstar:~# fdisk -l

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xe116fa32

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1      243201  1953512001   8e  Linux LVM
Partition 1 does not start on physical sector boundary.

Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 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: 0x0002eb1e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       29787   239256576   83  Linux
/dev/sdb2           29787       30402     4939777    5  Extended
/dev/sdb5           29787       30402     4939776   82  Linux swap / Solaris

Disk /dev/dm-0: 1932.7 GB, 1932735283200 bytes
255 heads, 63 sectors/track, 234975 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

I have downloaded and installed LVM. I have a group and maybe did something good with that 2TB HDD.

root@webstar:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               vgpool
  PV Size               1.82 TiB / not usable 2.56 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              476931
  Free PE               16131
  Allocated PE          460800
  PV UUID               m9rO1H-1OeC-0W38-gRUg-p9aQ-xEBZ-ZDxRvi

I used this command: lvcreate -L 1800G -n lvstuff vgpool and after that mkfs -t ext3 /dev/vgpool/lvstuff and after I tried to mount it for my first HDD : mount -t ext3 /dev/vgpool/lvstuff /, but it doesn't work for me. It looks like It just copied my first HDD or what? On my cpanel I see this:

Device                      Type    Mount point %   free        used        size
/dev/mapper/vgpool-lvstuff  ext3    /           93% 16.39 GB    196.79 GB   224.59 GB
/dev/sdb1                   ext3    /           93% 16.39 GB    196.79 GB   224.59 GB
share|improve this question

marked as duplicate by slm, Anthon, jasonwryan, Sukminder, manatwork Jun 11 '13 at 6:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
You know this has been asked and answered several times in the various SE groups. Did you search before you asked the question? –  mdpc Jun 10 '13 at 18:36
    
    

1 Answer 1

up vote 1 down vote accepted

You cannot extend a partition with one that is under LVM as such. What you can do is combine multiple partitions that are managed with LVM to be combined into one virtual partition.

The first thing obvious from your post is that the result of fdisk -l shows only one LVM partition. If you want to combine things you need at least two.

The other thing that I find strange is that you mount /dev/vgpool/lvstuff on /, would that work, you would no longer have access to your running OS. Normally you mount something in a subdirectory X. Most often that directory will be empty, because you cannot access any file/sudirectories available under X before the mount by name.

(It would be nice to know which instructions you are following so we don't have to guess what you want to do, where things went wrong, what you should have been doing and how to fix it given where you are now (if possible).)


Edit:

My first recommendation is as per this. If you absolutely need to have the combined space of the 250Gb drive and the 2Tb drive as one volume then:

  1. You have to check whether you can boot from an LVM partition (I am not sure and although I use LVM, it is only for data partitions, not for those with the OS).

  2. If you find you can boot from a system under LVM, then the easiest thing to do is mount /dev/mapper/vgpool-lvstuff to /mnt/tmp and copy everything from / to that directory. Then make sure you can boot from /dev/sda1, wipe /dev/sdb1 and use vgextend on that /dev/sda1

  3. If you find you cannot boot from a partition under LVM (which is more likely unless grub knows about how LVM rearranges blocks), then you will somewhere have a non-LVM partition with at least /boot. There are various ways to go about that, but you need to make some room somewhere to have this partition and its data (280Mb on my Ubuntu 12.04 server). Then copy your /boot contents there, change /etc/fstab and the grub configuration so that you can boot from this new partition. Then, for the rest of / the same steps would need to be done as for when LVM is bootable.

It might be a tricky process and will take time (copying files, rebooting etc), I have moved data around this way but only without LVM.

Once more: you should really consider whether it is worth having just 10% more contiguous disc space space compared to a simple mount of /dev/sda1 as a normal partition. If that contiguous space is so important I would have bought a 3TB drive and save a few hours of work.

share|improve this answer
    
I followed this one: howtogeek.com/howto/40702/… –  user2301881 Jun 10 '13 at 14:57
    
That seems ok to me on first glace. But you have not used vgextend to extend a 'pool'. If /dev/sdb1 had been under LVM, then you could have extended it by using vgextend poolname /dev/sda1 but I don't think you can bring a mounted root filesystem under LVM. I will extend my answer with some tips on how to proceed (and checks if that is worthwhile). –  Anthon Jun 10 '13 at 15:09
    
I wanted to extend my 250GB HDD with 2TB... –  user2301881 Jun 10 '13 at 15:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.