36 lines
1.1 KiB
Plaintext

{
# parse fstab to know what fstype is root partition
my $fstype = "ext4";
my @patterns = ( qr/\s\/\s+xfs\s+/, qr/^\/dev\/main\/.*\s+xfs\s+/ );
open (RD, "</etc/fstab")
|| warn "Cannot open input file /etc/fstab: $!\n";
while (<RD>)
{
chop;
$fstype="xfs" if ( $_ ~~ @patterns );
}
close(RD);
if ( $fstype eq "xfs" ) {
# GRUB_CMDLINE_LINUX="rd.lvm.lv=main/root rd.lvm.lv=main/swap rhgb quiet"
# to GRUB_CMDLINE_LINUX="rd.lvm.lv=main/root rd.lvm.lv=main/swap rhgb quiet rootflags=uquota,pquota"
# also remove noquota
@lines = map {
/^GRUB_CMDLINE_LINUX/ && s/noquota//;
/^GRUB_CMDLINE_LINUX/ && ! /rootflags=uquota,pquota/ && s/"$/ rootflags=uquota,pquota"/;
$_
} @lines;
} else {
# if we are using ext[234] or any other fs type let's default to ...
@lines = map {
/^GRUB_CMDLINE_LINUX/ && s/noquota//;
/^GRUB_CMDLINE_LINUX/ && /rootflags=uquota,pquota/ && s/rootflags=uquota,pquota//;
$_
} @lines;
}
"";
}