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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
02-05-2016, 10:49 AM
|
#1
|
LQ Newbie
Registered: Aug 2015
Posts: 17
Rep:
|
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:
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 :
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
|
|
|
02-05-2016, 11:22 AM
|
#2
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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 11:33 AM.
|
|
|
02-05-2016, 10:47 PM
|
#3
|
Senior Member
Registered: Jan 2004
Posts: 1,420
Rep:
|
In addition to the following command:
You can issue the following commands that report information on physical volumes, volume groups and logical volumes.
In my mind, a helpful way to easy into LVM.
|
|
|
02-07-2016, 11:04 PM
|
#4
|
Member
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Rep:
|
Quote:
Originally Posted by ITareliteralyMyInitials
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.
|
|
|
02-08-2016, 08:05 AM
|
#5
|
LQ Newbie
Registered: Aug 2015
Posts: 17
Original Poster
Rep:
|
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 ,
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 ?
|
|
|
02-08-2016, 09:11 AM
|
#6
|
Senior Member
Registered: Jan 2004
Posts: 1,420
Rep:
|
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.
|
02-08-2016, 09:22 AM
|
#7
|
LQ Newbie
Registered: Aug 2015
Posts: 17
Original Poster
Rep:
|
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 :
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 ?
|
|
|
02-08-2016, 10:20 AM
|
#8
|
Senior Member
Registered: Jan 2004
Posts: 1,420
Rep:
|
|
|
1 members found this post helpful.
|
02-08-2016, 10:29 AM
|
#9
|
LQ Newbie
Registered: Aug 2015
Posts: 17
Original Poster
Rep:
|
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
|
|
|
|
02-08-2016, 10:57 AM
|
#10
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,789
|
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.
|
02-08-2016, 11:19 AM
|
#11
|
LQ Newbie
Registered: Aug 2015
Posts: 17
Original Poster
Rep:
|
Thanks all for the valuable information, I choose to go with 'rknichols''s solution , Thanks a lot for the impeccable explanation !!
|
|
|
All times are GMT -5. The time now is 12:00 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|