Quality of life update - Ram selection

bovinethunder

New Member
Dec 13, 2025
1
0
1
Hi All

Preface - ive been chatting with a friend who may have set an LXC up with 8mb of ram rather than what he intended and I may have had indulged in a bit too much silly joice in an attempt to stop them being foolish in the future.. but with the aid (or lets not be daft here, complete abuse of...) Gemini I have come up with the below script. Could maybe something like the below be implemented in the future for aid of setting for both RAM and main storage? Obvs do not run this in the main shell without readiing and im sure there are people out there who could make it more efficient etc but with the aid of the dreaded AI I managed to get the image at the bottom to work and it provides the relevant amount fo ram without needing to know the numbers or use a calculator?


cat << 'EOF' > /tmp/install-gb-buttons.sh
#!/bin/bash
cat << 'INNER_EOF' > /usr/share/pve-manager/js/gb-memory-helper.js
// --- NATIVE EXTJS PROXMOX GB MEMORY PATCH ---
Ext.define('PVE.qemu.MemoryInputPanel.GBHelper', {
override: 'PVE.qemu.MemoryInputPanel',

initComponent: function() {
var me = this;
me.callParent();

var options = [
{ text: '1 GB', value: 1024 },
{ text: '2 GB', value: 2048 },
{ text: '4 GB', value: 4096 },
{ text: '8 GB', value: 8192 },
{ text: '16 GB', value: 16384 },
{ text: '32 GB', value: 32768 },
{ text: '48 GB', value: 49152 },
{ text: '64 GB', value: 65536 }
];

var buttonContainer = Ext.create('Ext.container.Container', {
layout: 'hbox',
margin: '10 0 0 0',
defaults: {
xtype: 'button',
margin: '0 5 0 0',
handler: function(btn) {
var memField = me.down('numberfield[name=memory]');
if (memField) {
memField.setValue(btn.memoryValue);
}
}
},
items: options.map(function(opt) {
return {
text: opt.text,
memoryValue: opt.value
};
})
});

me.add(buttonContainer);
}
});
INNER_EOF

if ! grep -q "gb-memory-helper.js" /usr/share/pve-manager/index.html.tpl; then
sed -i '/pvemanagerlib.js/a \ <script type="text/javascript" src="/pve2/js/gb-memory-helper.js?v=2"></script>' /usr/share/pve-manager/index.html.tpl
fi

systemctl restart pveproxy.service
echo "Proxmox GB Memory buttons installed successfully!"
EOF


1784069410462.png
 
Sorry, but I don't see the benefit. Even if it takes a little longer to find a calculator and type in the numbers or do the math in my head, it still takes less than a minute. And if you're creating a large number of virtual machines, wouldn't it be faster to use a machine with the same settings as a template?

I don't think it's because having a button makes it safe and easy (so you don't have to do the math) that you don't make mistakes; I think you make mistakes because you don't double-check.
 
Last edited:
Also, nothing will break if you enter 1000 instead of 1024 or 3000 instead of 3072. The applications in the container won't care, as long as the number is roughly the same as what you actually need. And you can always change it later if you realise you've made a mistake or find that you need more or less RAM.

So, while clicking a button is more convenient and prevents errors such as allocating only 8 MiB, it is also more limiting. What if you want 1.5 GB, 1.75 GB, 1.25 GB or any other number that isn't a preset option? ;)
 
Last edited:
  • Like
Reactions: Johannes S
I'm not a fan of empty boxes where I'm needing to enter both a value and units together. This requires more sanitization of the input in the code and me having to guess what units are acceptable, as well as the formatting. M/MB/MBytes/Megabytes? What about MiB/Mebibytes? Or even Mb/Megabits? If I type "8gb", does it read my mind and make it 8 Gigabytes, be more strict and go with 8 Gigabits, or reject it completely?

Simple fix for all parts of PVE seems to be to have a box for the value, then a pull-down to the right with MB/GB/TB, with MB for RAM, GB for disk and etc. as the default so as to not disrupt the status quo.
 
  • Like
Reactions: proxuser77
That's a good point. A drop-down menu would indeed be better.

On the other hand, while I think it would be nice to have the option to choose the unit, it would still be more of a nice touch than a necessity, because, as others have mentioned, entering 'x * 1024' into the calculator doesn't take much time, and even if you don't do that, it's unlikely you'll encounter any actual problems if you enter 8000 instead of 8192 MiB. ;)

Also, neither of these solutions would actually prevent the problem the OP is trying to solve, i.e. someone entering 8 instead of 8192, unless GiB were the default unit. But then you could just as easily end up with someone accidentally configuring 512 GiB when they actually meant 512 MiB.
 
Last edited:
  • Like
Reactions: Johannes S