Extending a partition with LVM, "device not found"
UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Extending a partition with LVM, "device not found"
Hello!
I'm trying to extend a partition from 10 to 100GB on a server I'm managing.
Current situation:
Code:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu-root 8.5G 5.4G 2.8G 67% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.4G 4.0K 3.4G 1% /dev
tmpfs 698M 544K 698M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.5G 0 3.5G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 228M 60M 157M 28% /boot
# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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: 0x00080ac2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 20969471 10233857 5 Extended
/dev/sda5 501760 20969471 10233856 8e Linux LVM
Disk /dev/mapper/ubuntu-root: 9403 MB, 9403629568 bytes
255 heads, 63 sectors/track, 1143 cylinders, total 18366464 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/ubuntu-root doesn't contain a valid partition table
Disk /dev/mapper/ubuntu-swap_1: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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/ubuntu-swap_1 doesn't contain a valid partition table
# vgdisplay
--- Volume group ---
VG Name ubuntu
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.76 GiB
PE Size 4.00 MiB
Total PE 2498
Alloc PE / Size 2498 / 9.76 GiB
Free PE / Size 0 / 0
VG UUID gG7dRH-wy0v-M2cL-wBjo-ALha-YRHp-ieceEi
# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name ubuntu
PV Size 9.76 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2498
Free PE 0
Allocated PE 2498
PV UUID U8FaKr-ynzz-sV08-T8Ro-NEbz-aX8o-7U3C4l
# lvscan
ACTIVE '/dev/ubuntu/root' [8.76 GiB] inherit
ACTIVE '/dev/ubuntu/swap_1' [1.00 GiB] inherit
I'd like /dev/mapper/ubuntu-root to use all the available space (100gb).
AFAIK, /dev/mapper/ubuntu-root is on /dev/sda5, so I should initialize /dev/sda2 with pvcreate, then extend it with vgextend/lvextend (need to look it up yet).
output:
Code:
# pvcreate /dev/sda2
Device /dev/sda2 not found (or ignored by filtering)
Distribution: Debian Testing, Stable, Sid and Manjaro, Mageia 3, LMDE
Posts: 2,628
Rep:
A good place to start would be with;
Code:
man lvm
sda2 is not a lvm volume. sda5 is. Try initializing it instead of sda2. I suspect that will give sda2 some sort of recognizable partition table.
You seem to have one drive with 2 partitions so why are you creating an lvm within an extended partition?
Is this simply to raise the overhead with the extra partition in the MSDos partition table or is there some other reason.
There is mention of some sort of swap. This is not liste by fdisk so it is not correctly created.
Why not start by getting rid of sda2 and whatever is supposed to be swap and then start over with simply a new sda2 and a new swap. Leaving the lvm completely off the drive?
If you had more than one drive and little idea what you were going to need partition wise would make lvm make some sense to me. This just looks kind of silly.
Thank you for your answer. This is a remote cloud server that came with 10GB. They have a control panel where they set my available space to 100GB.
I'm not sure if /dev/sda5 was already there or it was created after this, but I don't have much control over this.
My only task is to make 'ubuntu-root' use the whole 100GB.
I'm sorry but I mentioned /dev/sda2 by mistake before, I meant /dev/sda5.
Output:
Code:
# pvcreate /dev/sda5
Can't initialize physical volume "/dev/sda5" of volume group "ubuntu" without -ff
I'm not sure if forcing this would create any issues. This is a live production server unfortunately, so I'm trying not to mess things up
On the contrary, that is a quite common LVM arrangement.
Simply create a new logical partition (/dev/sda6) using all the unallocated space, then pvcreate that, then as you say simply vgextend, then lvextend.
Plenty of tutorials online, but Redhat have a good LVM Admin guide you might find useful.
# fdisk /dev/sda
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
No free sectors available
Also I'm not sure what is the role of /dev/sda2 in all this.
An extended partition is a container for logical partitions. It is a (Microsoft) hack to get around the MS-DOS limit of 4 primary partitions. Let's see the output from this run as sudo/root
# parted /dev/sda "print free"
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 256MB 255MB primary ext2 boot
256MB 257MB 1048kB Free Space
2 257MB 10.7GB 10.5GB extended
5 257MB 10.7GB 10.5GB logical lvm
10.7GB 107GB 96.6GB Free Space
So does this mean that sda2 contains sda5 (which "contains" ubuntu-root) ?
I don't have 4 primary partitions yet though, so it should let me create /dev/sda6 with all the unallocated space in it.
You could use a primary to allocate that space (it would become /dev/sda3), however if your provider later adds more space again, you might start to get into trouble.
Better to use cfdisk to create the new logical - it will enlarge the extended partition automatically for you. fdisk won't do that. In cfdisk, simply highlight the unused space (it's an ncurses application), and create the new logical.
Got it, done with cfdisk, thank you very much!
For the record, after creating a new logical partition using cfdisk, taking up all available space, I ran the following:
pvcreate /dev/sda6
vgextend ubuntu /dev/sda6
lvextend -l +100%FREE /dev/mapper/ubuntu-root
resize2fs /dev/ubuntu/root
Distribution: Debian Testing, Stable, Sid and Manjaro, Mageia 3, LMDE
Posts: 2,628
Rep:
That sounds better.
When asking for help it is always a great idea to say what hardware you are using. Knowing this is a cloud server does make some difference in what your options are.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.