2

My VM came with a 9GB setup but a 60GB drive. I'm trying to extend it to it's full size. I have to do this on several servers. I tried to follow a guide else where but when creating a new partition I got this msg.

If you want to create more than four partitions, you must replace a primary partition with an extended partition first.

Here is some info you might find handy to help.

root@ubuntu:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           396M  584K  395M   1% /run
/dev/dm-0        57G  3.0G   52G   6% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/sda1       134M   68M   57M  55% /boot

root@ubuntu:~# fdisk -l

Disk /dev/sda: 62.9 GB, 62914560000 bytes
64 heads, 32 sectors/track, 60000 cylinders, total 122880000 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 identifier: 0x00096132

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      292863      145408   83  Linux
/dev/sda2          292864     2246655      976896   82  Linux swap / Solaris
/dev/sda3         2246656    20969471     9361408   8e  Linux LVM
/dev/sda4        20969472   122879999    50955264   8e  Linux LVM

Disk /dev/mapper/CAC_VG-CAC_LV: 61.8 GB, 61761126400 bytes
255 heads, 63 sectors/track, 7508 cylinders, total 120627200 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 identifier: 0x00000000

Disk /dev/mapper/CAC_VG-CAC_LV doesn't contain a valid partition table`

Any help would be greatly appreciated. If you need additional info feel free to ask. I will be watching all morning.

Thanks

Edit- I'm actually thinking that script I ran earlier worked and did extend the drives, but one server has that partition error and the other doesn't.

Edit - Fstab output

root@ubuntu:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/CAC_VG-CAC_LV /               ext4    errors=remount-ro 0      1  
# /boot was on /dev/sda1 during installation
UUID=1d92b194-7885-4b25-a4ba-a7b8683229e1 /boot           ext4  defaults 0 2
# swap was on /dev/sda2 during installation
UUID=be7625e5-2e2c-41f2-8d5f-331f90980b9e none            swap    sw  0 0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

pvdisplay and vgdisplay

root@ubuntu:~# vgdisplay
  --- Volume group ---
  VG Name               CAC_VG
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               57.52 GiB
  PE Size               4.00 MiB
  Total PE              14725
  Alloc PE / Size       14725 / 57.52 GiB
  Free  PE / Size       0 / 0
  VG UUID               A4SRwW-Vqpz-qRLf-iXIm-yKny-tcyI-wYTMdg

root@ubuntu:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               CAC_VG
  PV Size               8.93 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2285
  Free PE               0
  Allocated PE          2285
  PV UUID               al3A0j-NEpg-yjRd-2yzF-pMUm-fa42-XdcZmc

  --- Physical volume ---
  PV Name               /dev/sda4
  VG Name               CAC_VG
  PV Size               48.59 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12440
  Free PE               0
  Allocated PE          12440
  PV UUID               phIhtw-wze3-IOTU-oiik-586P-ecJP-5KY913

Edit- Output of script cloud host said to run

root@ubuntu:~# sh zang.sh
Error: Can't create any more partitions.
Error: Partition doesn't exist.
partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'dos' detected
partx: /dev/sda: adding partition #1 failed: Device or resource busy
partx: /dev/sda: adding partition #2 failed: Device or resource busy
partx: /dev/sda: adding partition #3 failed: Device or resource busy
partx: /dev/sda: adding partition #4 failed: Device or resource busy
partx: /dev/sda: error adding partitions 1-4
  Device /dev/sda5 not found (or ignored by filtering).
  Device /dev/sda5 not found (or ignored by filtering).
  Unable to add physical volume '/dev/sda5' to volume group 'CAC_VG'.
  New size (9725 extents) matches existing size (9725 extents)
  Run `lvextend --help' for more information.
resize2fs 1.42.9 (4-Feb-2014)
The filesystem is already 9958400 blocks long.  Nothing to do!

As you can see it looks like it doesn't work but when logging in I go from this

Usage of /:  13.1% of 8.66GB   to    Usage of /:   3.1% of 37.27GB 

Thanks once again for your help.

2

The procedure is rather easy and it should even work on a running system. Keep the word "should" in mind. Normally, the procedure is as following:

  • Start off with resizing the LVM you need to resize: sudo lvresize -l 100%FREE /dev/vg00/myvolume This tells LVM to use up all free space to enlarge the volume /dev/vg00/myvolume
  • Now you need to resize the filesystem contained within: sudo resize2fs /dev/vg00/myvolume It should detect that you have the disk mounted any then use it's online resizing mode.

That's it... You're done.

Did I tell you to backup your data before doing all that? Here you go: backup your data before doing this.

Note that your output says something about a volume being about 61.8GB. The output of both lvdisplay, vgdisplay and the contents of /etc/fstab might give additional information regarding your system. I'm also not very certain why you have two LVM marked partitions. Did you create those?

12
  • No they all come with the VM upon creating it. My other servers all look similar. – Levi Aug 31 '16 at 11:38
  • Can you give me the output of sudo pvdisplay and sudo vgdisplay? – jawtheshark Aug 31 '16 at 11:41
  • I added it to the post – Levi Aug 31 '16 at 11:47
  • I'm pretty sure after looking over all this the script I ran before I made this post worked. I do believe the drive has been extended now. I don't know what I get that partition error though. – Levi Aug 31 '16 at 11:49
  • Thanks for the update... I just noticed something. In your fstab, it says that your root filesystem is /dev/mapper/CAC_VG-CAC_LV (this translates to /dev/md0, which you can check by issuinging ls -la /dev/mapper/CAC_VG-CAC_LV. Furthermore, if you look at your df -h command, your root partition is ... /dev/dm-0 57G 3.0G 52G 6% / . That means you already have your 60G mounted as root. Those "missing" 3G, are the /boot and the swap parition. I would conclude it is all in order. – jawtheshark Aug 31 '16 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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