LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-01-2016, 10:26 AM   #1
DaveGinBoav
LQ Newbie
 
Registered: Mar 2016
Location: SW England
Distribution: Ubuntu 18.04.1 LTS
Posts: 18

Rep: Reputation: Disabled
Logical Volume Management (LVM) Disk Tangle?


Backstory

Last month I attempted to clone my 60GB disk onto a 120GB disk. Little did I know at the time but the 60GB disk had some LVM on it - I guess I wrongly ticked a box when installing Ubuntu some years ago. The consequence of the clone appears to be that despite me having a 120GB disk the system appears to think it is only 60GB and some outputs seem to be showing errors/warnings. I tried cloning twice - once using Clonezilla and the other using dd. I was cloning to avoid a great of configuring - my system is just right for my Low Vision needs.
For reasons I will not explain; my original 60GB disk is now not in its original state and has a fresh install of Ubuntu 14.04 LTS. But I do have all my data and important config files backed up.

The 120GB still boots up fine but I am worrying that a disaster is only a matter of time. The outputs below detail my issues.

http://www.tiikoni.com/tis/view/?id=13ecbc2
http://www.tiikoni.com/tis/view/?id=e236e10
http://www.tiikoni.com/tis/view/?id=35fe8c3
http://www.tiikoni.com/tis/view/?id=aa8a024

$ sudo fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x0003df66

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 234440703 116969473 5 Extended
/dev/sda5 503806 234440703 116968449 8e Linux LVM

Disk /dev/mapper/ubuntu--vg-root: 57.6 GB, 57612959744 bytes
255 heads, 63 sectors/track, 7004 cylinders, total 112525312 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--vg-root doesn't contain a valid partition table

Disk /dev/mapper/ubuntu--vg-swap_1: 2139 MB, 2139095040 bytes
255 heads, 63 sectors/track, 260 cylinders, total 4177920 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--vg-swap_1 doesn't contain a valid partition table

======================================================

sudo pvdisplay -m
--- Physical volume ---
PV Name /dev/sda5
VG Name ubuntu-vg
PV Size 55.65 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 14246
Free PE 0
Allocated PE 14246
PV UUID tXWgOP-Ams3-ks9R-4UdZ-Q0C2-sr2r-krRnaR

--- Physical Segments ---
Physical extent 0 to 13735:
Logical volume /dev/ubuntu-vg/root
Logical extents 0 to 13735
Physical extent 13736 to 14245:
Logical volume /dev/ubuntu-vg/swap_1
Logical extents 0 to 509

========================================


$ sudo vgdisplay
--- Volume group ---
VG Name ubuntu-vg
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 55.65 GiB
PE Size 4.00 MiB
Total PE 14246
Alloc PE / Size 14246 / 55.65 GiB
Free PE / Size 0 / 0
VG UUID D1GsMY-4IxD-Ze65-Av25-lZ0l-Nb0O-xMZmkZ

===================================================


sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/root
LV Name root
VG Name ubuntu-vg
LV UUID CwP4rm-x2qT-Jxyk-m4DC-bEBf-d7Mn-3XB3cP
LV Write Access read/write
LV Creation host, time ubuntu, 2014-11-15 07:39:09 +0000
LV Status available
# open 1
LV Size 53.66 GiB
Current LE 13736
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Path /dev/ubuntu-vg/swap_1
LV Name swap_1
VG Name ubuntu-vg
LV UUID sIhjl9-fNs2-NG7a-qpCP-DfkM-DH2K-qblVeI
LV Write Access read/write
LV Creation host, time ubuntu, 2014-11-15 07:39:10 +0000
LV Status available
# open 2
LV Size 1.99 GiB
Current LE 510
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

===================================================


$ sudo parted -l

Model: ATA TOSHIBA MK1255GS (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary ext2 boot
2 257MB 120GB 120GB extended
5 258MB 120GB 120GB logical lvm


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/ubuntu--vg-swap_1: 2139MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number Start End Size File system Flags
1 0.00B 2139MB 2139MB linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/ubuntu--vg-root: 57.6GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number Start End Size File system Flags
1 0.00B 57.6GB 57.6GB ext4

===================================


Solution now sought please:-
Ideally full use of my 120GB disk without having to configure all my Low Vision settings again. Preferably without LVM - the whole topic leaves me cold - my brain cannot handle the concepts. But all suggestions welcome. Happy to post other outputs. And happy to be led to happiness
 
Old 03-01-2016, 12:43 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,535

Rep: Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077
Converting from or to LVM is for experts only. I don't see anything wrong in your current setup other than not using all the available space. It's much the same as copying a small filesystem to a larger partition -- you can't make use of the space until you enlarge the filesystem.

You just need to tell LVM to enlarge its structures to use the whole partition. It's pretty straightforward:
Code:
pvresize /dev/sda5
lvresize --resizefs --extents +100%FREE /dev/ubuntu-vg/root
That should be all there is to it. The first command adjusts the size field in the physical volume header, and in the absence of any specific size option will default to the full size of the partition. Now that the space is available for logical volumes, the second command will enlarge your ubuntu-vg/root LV by 100% of the free space in the volume group and, with the "--resizefs" option, will also resize the filesystem to fill the LV. You can do all of that while the system is running.

LVM makes growing things really easy. (Shrinking, not so easy.)
 
2 members found this post helpful.
Old 03-01-2016, 12:49 PM   #3
tlowk
Member
 
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 184

Rep: Reputation: 26
I see you are afraid of LVM, but it is a way to make partitions more flexible and you can even add a disk and have partition moving between disks and then remove the old disk. Physical Volumes are combined into a volume group, this about a VG like a harddisk. This VG you can divide into logical volumes like partitions, but you can grow and shrink them on a running system. I start with small logical volumes for things like /home and grow when needed.

since rknichols pointed out that the physical volume already covers almost the complete disk, I snipped the part about using more of the disk.

consider this part FYI only: you could get rid of the lvm, but getting it ready too boot again might be tricky. Grub starts your kernel with some mini system called initramfs (or initrd in the old day) this system contains the drivers for LVM and it knows how to boot from an LVM. In case this does not scare you (it scares me). Get a live distribution with gparted and support for lvms

I'll explain the steps to do this, if you want to really try it, I need to write more, one of the things to consider is that you'll need space for the original and for a copy into a partition during this. So I'd get rid of the swap and shrink the logical volume root
and it filesystem.

first shrink the filesystem of root, then shrink the logical volume root.
then just remove the swap lv (you can create it again) probably ubuntu stores in /etc/fstab what swap it uses (part of the tricky story of booting it again)

then shrink with pvresize the volume and then shrink with parted /dev/sda5 and create a partition for root
then mount this new root with rw (just normal) and mount the root volume with read-only option. Then copy all files to the new partition and umount both.

Now you can delete the physcal volume and hope for the best
then you can create a new swap before the new root partition and then move the two partition to the front
and grow the root partition and it filesystem.


Greetings,

Tlowk

Last edited by tlowk; 03-01-2016 at 01:07 PM. Reason: removed too long explanation about growing the pv which is not needed
 
Old 03-01-2016, 12:57 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,535

Rep: Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077
Quote:
Originally Posted by tlowk View Post
If the LVM is not a problem you could grow the partition sda5 but this requires to grow first sda2

/dev/sda2 501758 234440703 116969473 5 Extended
/dev/sda5 503806 234440703 116968449 8e Linux LVM
Look again. /dev/sda2 and /dev/sda5 are already using essentially the entire disk, leaving just a tiny slice of 944 sectors at the end unallocated.
 
Old 03-01-2016, 01:08 PM   #5
tlowk
Member
 
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 184

Rep: Reputation: 26
Yes I noticed it too late and just mentioned it not clearly enough that they already cover the disk.

I cut most of the long text away, since using more of the disk is not relevant in this case.
 
Old 03-01-2016, 01:41 PM   #6
DaveGinBoav
LQ Newbie
 
Registered: Mar 2016
Location: SW England
Distribution: Ubuntu 18.04.1 LTS
Posts: 18

Original Poster
Rep: Reputation: Disabled
Thanks for your responses.
Before attempting the code suggestions made by rknichols can I just ask whether the 2 lines

Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition table
Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table

are something to worry about and need correcting?
Will the code suggestions fix these?

Thanks again.
DaveG
 
Old 03-01-2016, 01:56 PM   #7
tlowk
Member
 
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 184

Rep: Reputation: 26
These 'disks' are logical volumes, you can think about them like partitions. A disk has a partition table, but partitions do
not have such table, they only contain a filesystem.

Greets,

Tlowk
 
Old 03-01-2016, 04:44 PM   #8
DaveGinBoav
LQ Newbie
 
Registered: Mar 2016
Location: SW England
Distribution: Ubuntu 18.04.1 LTS
Posts: 18

Original Poster
Rep: Reputation: Disabled
I think all is now solved - thank you so much.
These are the outputs I received from entering the commands. I'm assuming this is normal and was expected?
sudo pvresize /dev/sda5

Physical volume "/dev/sda5" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
$ sudo lvresize --resizefs --extents +100%FREE /dev/ubuntu-vg/root
Extending logical volume root to 109.55 GiB
Logical volume root successfully resized
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 7
The filesystem on /dev/mapper/ubuntu--vg-root is now 28719104 blocks long.

Can that on-line resizing message be ignored or is action required?
 
Old 03-01-2016, 10:26 PM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,535

Rep: Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077Reputation: 2077
Quote:
Originally Posted by DaveGinBoav View Post
I think all is now solved - thank you so much.
These are the outputs I received from entering the commands. I'm assuming this is normal and was expected?
sudo pvresize /dev/sda5

Physical volume "/dev/sda5" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
$ sudo lvresize --resizefs --extents +100%FREE /dev/ubuntu-vg/root
Extending logical volume root to 109.55 GiB
Logical volume root successfully resized
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 7
The filesystem on /dev/mapper/ubuntu--vg-root is now 28719104 blocks long.

Can that on-line resizing message be ignored or is action required?
It's just a rather poorly worded message that a mounted filesystem needs to support on-line resizing, which ext4 does. You're fine, as you can see if you run the df command to see your free space.
 
1 members found this post helpful.
Old 03-02-2016, 06:00 AM   #10
DaveGinBoav
LQ Newbie
 
Registered: Mar 2016
Location: SW England
Distribution: Ubuntu 18.04.1 LTS
Posts: 18

Original Poster
Rep: Reputation: Disabled
Thanks once more. As you say, I'm fine confirmed by df -h
Filesystem Size Used Avail Use% Mounted on
udev 994M 4.0K 994M 1% /dev
tmpfs 201M 1.1M 200M 1% /run
/dev/mapper/ubuntu--vg-root 108G 20G 84G 20% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 1004M 156K 1004M 1% /run/shm
none 100M 52K 100M 1% /run/user
/dev/sda1 236M 152M 73M 68% /boot
 
Old 03-02-2016, 07:13 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187Reputation: 3187
LVM is a god-send, and it's actually easy enough to "google it" to find out, functionally speaking, how it's done. I couldn't imagine not using it, and I chafe when using systems that don't.

Basically, the physical storage "reality" is disconnected from the logical "illusion" that the filesystems and the application programs see. If you "run out of space on '/' ," it's no problem: just add a new physical volume, add it to the appropriate logical group(s), and grow the filesystem. And so on.

Another advantage that you can grab is to spread out the physical disk activity among multiple DASDs and channels (oops... ... disks and controller-cards). "Just like the big boys do." And, you can do this transparently because you are manipulating the physical picture, which the software doesn't see.

Set yourself up a little ubuntu VM whose hard disk is "too small," be sure to specify LVM at the appropriate time, and just ... fool around with it for a few hours until you get the hang. Take permanent written notes as you do this, because you won't ... uhh ... what was I gonna say?

The commands are fairly easy to grok because they are fairly consistent. Just remember that physical refers to what the hardware layout is, while logical refers to what, to the software, the picture appears to be. The "magic" is that the two can be completely different.

Last edited by sundialsvcs; 03-02-2016 at 07:17 AM.
 
1 members found this post helpful.
Old 03-03-2016, 07:00 PM   #12
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,846

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
It's quite common to have a small \boot partition for GRUB and the boot stuff.
That way LVM isn't accessed too early on.

However, once you have set-up LVM it's very tricky/impossible to leave the LVM world.
 
  


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
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
HELP! Restoring a LVM Logical Volume Checksumfail Linux - Server 2 12-18-2012 12:07 AM
Extended LVM Volume group and Logical Volume. But space not usable linuxlover.chaitanya Linux - Server 1 11-19-2012 09:37 AM
Logical Volume Management 2 XaViaR Linux - General 5 08-20-2005 07:48 AM
Logical Volume Management jatimon Linux - General 0 04-17-2002 02:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:13 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
Open Source Consulting | Domain Registration