LinuxQuestions.org
Review your favorite Linux distribution.
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 02-05-2016, 11:49 AM   #1
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Rep: Reputation: Disabled
what is a logical partitions and group partitions and how to check disk space on a partition


Hi all ,

I have just started to organize ideas in my mind about 'Physical disks' 'logical partition groups' and 'logical partitions'
and 'real partitions'

I understood from a couple of reads-up that we have real partitions expl : (dev/sda1 , dev/sda2...), we have 'Group partitions' exp: (vg0), and then the logical partitions as of (/var, /home ...)

What i don't understand is:
  • Why and what is the use of logical partitions?
  • What is the use of partition groups ?
  • Can I think of 'dev/sda1' as (C,D partitions on windows) ? or is that more like the logical partitions ?
  • How can I list the files-by-their-size contained in a logical partition ?

The reason that brings me to this point is that if I use this command:

Code:
df -h
I get something like this (1) :

Quote:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-Root 2.0G 1.8G 123M 94% /
/dev/mapper/vg0-Local
2.0G 647M 1.3G 35% /local
/dev/mapper/vg0-Var 2.0G 258M 1.6G 14% /var
/dev/mapper/vg0-VarLog
2.0G 109M 1.8G 6% /var/log
/dev/mapper/vg0-Home 992M 183M 759M 20% /home
/dev/mapper/vg0-Opt 47G 12G 33G 27% /opt
/dev/sda1 494M 42M 427M 9% /boot
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 7.9G 148K 7.9G 1% /tmp
And I see that i have a problem in disk space on 'Root' '/' , but don't know how to solve it because then if I go to :
Code:
cd /
The folder '/var' is inside '/' but its also in an other 'logical partition',
Does the output (1) means that when i check for problematic files i have to exclude the ones that are on other logical partitions ?

If someone gets my struggle please guide me, Any help is appreciated
 
Old 02-05-2016, 12:22 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137
In LVM, physical volumes (partitions on a disk) are added to a group, called a volume group (VG). A VG is just a collection of physical partitions available for use. This group is then used as a larger bin, that can then be subdivided into individual partitions (called logical volumes). It's not dissimilar to grouping your disks into a RAID 0 array, and then partitioning that array as needed.

LVM is optional, there's no requirement to use it. The point of it is easy re-sizing and moving of volumes, since they're no longer physically tied to hardware, they're only tied to a "group" of disks, that can be added to or subtracted from (I think) as needed.

If you don't use LVM, then you can just use regular partitions on regular disks. sda1 would be partition 1 on device A, which might be like your C: drive. sda2 would be partition 2 on device A, which might be like your D: drive. sdb1 would be partition 1 on device B, which might be like your E: drive, and so on.

With LVM, both disks A and B would be added to a VG, and then that VG could be subdivided into three individual LVs, which might be like your C:, D:, and E: drives. The point is these three VGs could be sized as needed without worrying about individual disk boundaries.


Now as for your second question, that comes down to the Linux filesystem, and is independent of LVM. With Windows, every disk has its own tree that starts at "My Computer". From there you pick your disk/partition, and then go into it. The entire OS is always on C:, programs are usually on C: but can usually be installed on a different one at the time of installation, and data can be put wherever you like. C:, D:, E: all have independent trees, that don't mix.

On Linux, there is ONE tree, that starts at /. Everything is located inside this one tree. Drives/partitions (or LVs) are mounted in subdirectories of /, as needed. Take your system for example, you have a separate filesystem (an LV called vg0-Home) which is mounted at /home. When that filesystem is mounted, everything that is placed inside /home or a subdirectory of /home, goes on that LV. If you were to unmount that LV, you'd find that /home is now empty. Anything placed in /home at that point would go on the filesystem that holds the parent, in this case /, or your LV vg0-Root. If you were to then re-mount your vg0-Home LV, the contents of /home would be replaced with what's in that filesystem, and the files you just created in /home on vg0-Root would be covered up. They would still exist, but you wouldn't be able to access them until vg0-Home was unmounted again.

Instead of each filesystem having its own, independent tree, in Linux all filesystems share a single tree. This makes it trivially easy to move data transparently between disks, without affecting anything on the system. This is also why I feel LVM is a bit over-rated. Having a big flexible bucket that you can use to resize LVs and move them around is all well and good if the Linux tree was rigid and unflexible like Windows. But as it is, I don't really see the need for LVM, since you can move directories between filesystems all you want without affecting the behavior of the system. If a filesystem fills up, just offload a few of the big directories to a different one and re-mount them in place, there's no need to go out of your way to shrink other partitions or LVs to make room to expand the full one.

Last edited by suicidaleggroll; 02-05-2016 at 12:33 PM.
 
Old 02-05-2016, 11:47 PM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,301
Blog Entries: 4

Rep: Reputation: 148Reputation: 148
In addition to the following command:

Code:
df -ha
You can issue the following commands that report information on physical volumes, volume groups and logical volumes.

Code:
pvs ; vgs ; lvs
In my mind, a helpful way to easy into LVM.
 
Old 02-08-2016, 12:04 AM   #4
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 49
Quote:
Originally Posted by ITareliteralyMyInitials View Post
Hi all ,

I have just started to organize ideas in my mind about 'Physical disks' 'logical partition groups' and 'logical partitions'
and 'real partitions'
You need to decide if your partitions continually get big or small with data and thus need to be changed in size in a fluid way. This may be useful for a server.
If this is not your case, then you don't need LVM, imo. Go for a normal partitioning scheme like everyone else.
That way, your partitioning problems will be similar to more people.
 
Old 02-08-2016, 09:05 AM   #5
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi All ,

Thank you for your explanations above , the thing is that i am in no position right now to not use LVM , As it is not a Lab Environment i am working on .
I had a look at this documentation https://www.turnkeylinux.org/blog/extending-lvm , and I understood that in my case there is no free space Left for VG or Physical partition, and that to resolve my issue i would need to extend the physical partition which i can't since if i run ,
Quote:
pvdisplay
I get :
Quote:
--- Physical volume ---
PV Name /dev/sda2
VG Name vg0
PV Size 59.50 GB / not usable 30.20 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 1903
Free PE 0
Allocated PE 1903
PV UUID QpvPb6-1QWT-qfyc-Ycev-fOPH-E1kf-OmvOre
In that Link above it is stated that i would need to extend the underlying device , but what other options do i have .
-Can I borrow space from other VPs ? lets say from (/dev/mapper/vg0-Opt) , If that is possible can you please show me how ?
 
Old 02-08-2016, 10:11 AM   #6
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,301
Blog Entries: 4

Rep: Reputation: 148Reputation: 148
Is this a server? Laptop or desktop? VM? Just wondering.

If you have the free space, you could create a new partition, say /dev/sdc1 with either fdisk or parted.

And do the following;

Code:
pvcreate /dev/sdc1 ; vgextend vg0 /dev/sdc1 ; lvextend +L(size here) /dev/vg0/(logical volume here) ; resize2fs /dev/mapper/vg0/(logical volume here)
Be sure to backup all of your data first before doing this.
 
1 members found this post helpful.
Old 02-08-2016, 10:22 AM   #7
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi JockVSJock , It is a server and a VM .

Thanks for your output ,
I tried to use this command to check how much disk space is unused on disk self :

Quote:
fdisk /dev/sda
and then clicked v

The result was that i have '8102 unallocated sectors' which means I cannot create an other partition on that disk , any other suggestion ?
 
Old 02-08-2016, 11:20 AM   #8
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,301
Blog Entries: 4

Rep: Reputation: 148Reputation: 148
Post the output of the following commands:

Code:
fdisk -l /dev/sda

df -haT
Also, here are a few ULRs to read up on LVM that has helped me.

http://ryandoyle.net/posts/expanding...g-drive-space/

http://www.howtogeek.com/howto/40702...ent-in-ubuntu/

http://blog.pluralsight.com/resize-vmware-linux-drives

http://blog.frands.net/linux-lvm-how-to-182/

http://www.datadisk.co.uk/html_docs/redhat/rh_lvm.htm

http://www.unixarena.com/2015/08/how...-linux-vm.html
 
1 members found this post helpful.
Old 02-08-2016, 11:29 AM   #9
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi again!
Thanks for the references above.

This is the outputs :
Quote:
fdisk -l /dev/sda

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 7832 62388427+ 8e Linux LVM
Quote:
df -haT Filesystem Type Size Used Avail Use Mounted on
/dev/mapper/vg0-Root
ext3 2.0G 1.8G 123M 94 /
proc proc 0 0 0 - /proc
sysfs sysfs 0 0 0 - /sys
devpts devpts 0 0 0 - /dev/pts
/dev/mapper/vg0-Local
ext3 2.0G 647M 1.3G 35% /local
/dev/mapper/vg0-Var
ext3 2.0G 258M 1.6G 14% /var
/dev/mapper/vg0-VarLog
ext3 2.0G 110M 1.8G 6% /var/log
/dev/mapper/vg0-Home
ext3 992M 183M 759M 20% /home
/dev/mapper/vg0-Opt
ext3 47G 12G 33G 27% /opt
/dev/sda1 ext3 494M 42M 427M 9% /boot
tmpfs tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs tmpfs 7.9G 148K 7.9G 1% /tmp
none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
mpp-748.netapp06.mjk.bas.net:/http_dev
nfs 700G 500G 201G 72% /www/mpp
 
Old 02-08-2016, 11:57 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,360

Rep: Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001
The most straightforward approach would be to have the host assign more disk space to your VM, either by enlarging the existing disk or assigning a new one. Then you would have more space for extending volume group vg0 and logical volume vg0-Root.

If you can't do that, then perhaps you could take away a couple of GB from vg0-Opt (currently 27% full, 33G available) and use that to enlarge vg0-Root. Shrinking vg0-Opt would require that the filesystem there be unmounted temporarily, which would require stopping any processes using files there. Assuming the vg0-Opt is a filesystem that can be shrunk (xfs cannot) and that vg0-Root is a filesystem that permits online expansion (most do), the steps would be:
Code:
umount -v /opt
fsck -f /dev/mapper/vg0-Opt
lvresize --resizefs --size -2G /dev/mapper/vg0-Opt
mount -v /opt
lvresize --resizefs --extents +100%FREE /dev/mapper/vg0-Root
Do not omit the "--resizefs" on those commands. Shrinking an LV before resizing the filesystem in it will cause damage.

Note that expanding or (especially) shrinking a filesystem is inherently a risky operation. Having good, current backups is important.
 
1 members found this post helpful.
Old 02-08-2016, 12:19 PM   #11
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thanks all for the valuable information, I choose to go with 'rknichols''s solution , Thanks a lot for the impeccable explanation !!
 
  


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
[SOLVED] cfdisk : FATAL ERROR: Bad logical partition 10: enlarged logical partitions overlap riller Fedora 8 05-31-2012 09:17 AM
Change primary partitions to logical partitions AND migrate their data? chickenlinux Linux - Hardware 10 04-04-2010 05:31 PM
how do I add partitions to drives that have Logical Volume (LVM) partitions? The MJ Linux - Software 5 08-17-2006 07:15 PM
Partition Problems: Bad primary partition 1: logical partitions overlap rovitotv Slackware 6 01-08-2006 07:55 PM
Partition Magic & converting to logical partitions lawsonrc Linux - General 2 10-28-2003 07:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:05 PM.

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