Score:1

LVM: Creation difference between CentOS 7 and CentOS 6

np flag
JKC

I have CentOS 6 & 7 server and am creating 512 MB logical volumes:

CentOS 7:

sudo lvcreate -v -n lvname -L 512M rootvg && sudo mkfs.xfs -L "lvname" /dev/mapper/rootvg-lvnamee

CentOS 6:

sudo lvcreate -v -n lvname -L 512M rootvg && sudo mkfs.ext4 -L "lvname" /dev/mapper/rootvg-lvname

Now the commands work fine, but when I issue df -h /fs-name, on CentOS 7, I get Size=509M and on CentOS 6, I get Size=488M. Why does CentOS 6 take up so much space and how can I get it closer to CentOS 7's size of 509M?

cn flag
How do you measure? Could you please share the details, the output of the commands?
Criggie avatar
in flag
Aside - CentOS 6 is now well out of support and really must not be used for anything. CentOS7 is technically still supported for another ~10 months but its pretty mouldy already. Consider your exit strategy and where you want to land.
Prem avatar
cn flag
Why do you claim or assume that the Issue is due to "CentOS 7 vs CentOS 6" when you are obviously using 2 Different Commands ? If you had used the Exact Same Command on 2 machines & got Differing Sizes , then the Question would be valid. Ideally the Question should be "Why ext4 vs xfs have Differing Sizes ...." !
U. Windl avatar
it flag
Maybe show a `vgdisplay -v` and `lvdisplay` for the LVs, too. What about block sizes of underlying devices?
Score:12
in flag

The difference is mainly because you use two different filesystems:

CentOS 7: sudo lvcreate -v -n lvname -L 512M rootvg && sudo mkfs.xfs -L "lvname" /dev/mapper/rootvg-lvnamee
CentOS 6: sudo lvcreate -v -n lvname -L 512M rootvg && sudo mkfs.ext4 -L "lvname" /dev/mapper/rootvg-lvname

If you want to reduce the reserved for root space (by default 5%) use command:

mkfs.ext4 -m 0 -L "lvname" /dev/mapper/rootvg-lvname

(0 mean no reserved space)

JKC avatar
np flag
JKC
I understand but I would like to know why such difference in space consumed and if there is anything on CentOS 6 that I can do differently to reclaim space consumed.
Romeo Ninov avatar
in flag
@JKC, create on 7 to be ext4 and you will have the same size. (or on 6 to be xfs)
Score:5
cn flag

The file systems used in those commands are different, one is ext4 the other one is XFS.

See also How to Choose Your Red Hat Enterprise Linux File System

The ext4 file system is reserving 5% of disk that can be used only by root user.

JKC avatar
np flag
JKC
Thank you, is there a way we can change it so that it does not reserve that 5% or make it less?
cn flag
You can use `tune2fs -m 0 /dev/sdaX` https://man.archlinux.org/man/tune2fs.8.en#m
cn flag
The filesystem must be unmounted.
Score:0
np flag
JKC

I think I found the answer from here https://chiaforum.com/t/ext4-users-remember-to-reduce-reserved-blocks/1972

By default ext4 reserves 5% of your disk for the root user. That made sense in 1999, but that’s insane now. You can run this command (as root) to reduce reserved blocks to around 4GB. On a 16TB ext4 file-system that will free up 795GB (since the default of 5% reserved = 800GB reserved for root!).

tune2fs -r 1000000 /dev/

This instantly frees up the space. You don’t need to unmount or remount or restart or anything.

But first use “lsblk” and “df” commands to identify the ext4 file-systems to tune.

And be careful! Running any command directly against any /dev/ file as root is always dangerous. Practice on a computer/drive that’s not important first.

Romeo Ninov avatar
in flag
When creating `ext4` you can always use option `-m` to define the percentage of reserved space (can be 0 of course).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.