Last edited:
No, but I would expect that instead of the fixed MB, I can insert either 512M or 4G or 1T.There are a lot of use cases for <1GB of RAM in VMs. Would you expect 1GB of RAM to be the minimum you can assign?
That is not really an argument. PHP is just a programming language that parses the input. This can be done in any programming language you want.Just like with PHP
Just add a select with "MiB", "GiB" after the input.There are a lot of use cases for <1GB of RAM in VMs. Would you expect 1GB of RAM to be the minimum you can assign?
I have some VMs with 512 MiB...768 MiB:But honestly I dont know any guest OS that runs fine on sub 1 GB RAM - but that may be my shortcoming.
$ lsb_release -a; free
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 13 (trixie)
Release: 13
Codename: trixie
gesamt benutzt frei gemns. Puffer/Cache verfĂĽgbar
Speicher: 475560 280936 19584 296 187844 194624
Swap: 808956 17256 791700
4096M but 4G instead.After a few decades you know them by heart or are just a nerd how can simple calculate them in the head.Right know, I have to calculate "hmm... 1GB is 1024MB. So that means * 2 * 2 = 4096 gives me a 4GB machine.
Windows? No .... but I have hundreds of Linux VMs running with such a low memory amount. If you're e.g. just running VPNs or do some kind of network routing, it's totally fine. I had to increase it over the years from 128M to kno 384 MB with Debian Trixie, yet you cannot install it with such low memory footprint, but it'll run without swap flawlessly.But honestly I dont know any guest OS that runs fine on sub 1 GB RAM - but that may be my shortcoming.
I have many CTs, Some running with less than 128MB RAM. Host has only 32GB RAM total. So quite like to specify guest memory in MB!I have some VMs with 512 MiB...768 MiB:
Cool! That's (of course) the positive aspect of containers.I have many CTs, Some running with less than 128MB RAM.
yes that ^Of course, and I would even say obviously (but seems not so), it is not about replacing the MiB option with GiB, but having a GiB option additionally...
that is what i meant sorry.up for additing GB/TB option and leaving MB in place still
In general or about your feature request? Those are tracked at bugzilla: https://bugzilla.proxmox.com/show_bug.cgi?id=3760 . I don't see any developer assigned yet.any hope for a soon pve manager update?
ah ok thanks for explaining thatIn general or about your feature request? Those are tracked at bugzilla: https://bugzilla.proxmox.com/show_bug.cgi?id=3760 . I don't see any developer assigned yet.
#!/bin/bash
cat > /usr/local/share/pve-unit-dropdown.js <<'EOF'
/* pve-unit-dropdown:begin v1 */
(function () {
if (typeof Ext === 'undefined' || !Ext.form || !Ext.form.field || !Ext.form.field.Number) {
return;
}
// [unit, size in base units]; base is MiB for memory/swap and GiB for disks
const UNITS = {
MiB: [['MiB', 1], ['GiB', 1024], ['TiB', 1024 * 1024]],
GiB: [['GiB', 1], ['TiB', 1024]],
};
function attach(field, baseUnit) {
if (!field || field.pveUnitAttached || !field.isFormField) {
return;
}
field.pveUnitAttached = true;
const units = UNITS[baseUnit];
const factors = {};
units.forEach((u) => { factors[u[0]] = u[1]; });
const intBase = field.allowDecimals === false;
const prec = field.decimalPrecision > 0 ? field.decimalPrecision : 3;
const origStep = field.step || 1;
const baseLabel = String(field.fieldLabel || '').replace(/\s*\([^()]*\)\s*$/, '');
field.pveUnit = baseUnit;
const factor = () => factors[field.pveUnit];
const show = (v) => String(parseFloat((v / factor()).toFixed(6)));
// typing decimals (1.5 GiB) must be possible: rebuild the key mask
if (intBase) {
field.allowDecimals = true;
field.setMinValue(field.minValue);
}
// value stays in base units everywhere; only the text is scaled
field.rawToValue = function (raw) {
const n = parseFloat(String(raw).replace(this.decimalSeparator, '.'));
if (isNaN(n)) {
return raw || null;
}
const base = n * factor();
return intBase ? Math.round(base) : parseFloat(base.toFixed(prec));
};
field.valueToRaw = function (value) {
const n = typeof value === 'number'
? value
: parseFloat(String(value).replace(this.decimalSeparator, '.'));
if (isNaN(n)) {
return '';
}
return show(n).replace('.', this.decimalSeparator);
};
field.getSubmitValue = function () {
const v = this.getValue();
return v === null || v === undefined ? '' : String(v);
};
field.getErrors = function (value) {
const me = this;
value = arguments.length > 0 ? value : me.processRawValue(me.getRawValue());
const errors = Ext.form.field.Text.prototype.getErrors.call(me, value);
if (value.length < 1) {
return errors;
}
const s = String(value).replace(me.decimalSeparator, '.');
if (isNaN(s)) {
errors.push(Ext.String.format(me.nanText, s));
return errors;
}
const num = me.rawToValue(value);
const disp = (v) => `${show(v)} ${me.pveUnit}`;
if (me.minValue === 0 && num < 0) {
errors.push(me.negativeText);
} else if (num < me.minValue) {
errors.push(Ext.String.format(me.minText, disp(me.minValue)));
}
if (num > me.maxValue) {
errors.push(Ext.String.format(me.maxText, disp(me.maxValue)));
}
return errors;
};
const syncStep = () => {
field.step = factor() > 1 ? factor() : origStep;
};
const renderLabel = () => {
if (!field.rendered || !field.labelTextEl) {
return;
}
const style = 'cursor:pointer;text-decoration:underline dotted;';
field.labelTextEl.dom.innerHTML =
`${Ext.String.htmlEncode(baseLabel)} (<a href="#" class="pve-unit-sel" ` +
`style="${style}">${field.pveUnit} ▾</a>)${field.labelSeparator || ''}`;
};
const setUnit = (unit) => {
if (unit === field.pveUnit) {
return;
}
const cur = field.getValue(); // base units, using the old unit
field.pveUnit = unit;
syncStep();
renderLabel();
if (typeof cur === 'number') {
field.setRawValue(field.valueToRaw(cur));
}
field.validate();
};
const showMenu = (anchor) => {
if (!field.pveUnitMenu) {
field.pveUnitMenu = Ext.create('Ext.menu.Menu', {
items: units.map((u) => ({
text: u[0],
checked: false,
group: `pveunit-${field.id}`,
handler: () => setUnit(u[0]),
})),
});
field.on('destroy', () => field.pveUnitMenu.destroy());
}
field.pveUnitMenu.items.each((item) => {
item.setChecked(item.text === field.pveUnit, true);
});
const xy = anchor.getXY();
field.pveUnitMenu.showAt(xy[0], xy[1] + anchor.getHeight());
};
field.on('afterrender', () => {
renderLabel();
if (field.labelEl) {
field.labelEl.on('click', (e) => {
const t = e.getTarget('.pve-unit-sel');
if (!t) {
return;
}
e.preventDefault();
if (!field.disabled && !field.readOnly) {
showMenu(Ext.get(t));
}
});
}
});
}
function hook(name, fn) {
const cls = Ext.ClassManager.get(name);
if (!cls) {
console.warn(`pve-unit-dropdown: class ${name} not found`);
return;
}
const orig = cls.prototype.initComponent;
Ext.override(cls, {
initComponent: function () {
orig.apply(this, arguments);
try {
fn(this);
} catch (e) {
console.warn('pve-unit-dropdown:', e);
}
},
});
}
hook('PVE.form.MemoryField', (f) => attach(f, 'MiB'));
hook('PVE.lxc.MemoryInputPanel', (p) => {
['memory', 'swap'].forEach((n) => attach(p.down(`field[name=${n}]`), 'MiB'));
});
hook('PVE.form.DiskStorageSelector', (p) => attach(p.getComponent('disksize'), 'GiB'));
})();
/* pve-unit-dropdown:end */
EOF
cat > /usr/local/sbin/pve-unit-patch.sh <<'SH'
#!/bin/bash
F=/usr/share/pve-manager/js/pvemanagerlib.js
JS=/usr/local/share/pve-unit-dropdown.js
[ -f "$JS" ] || exit 0
grep -q 'pve-unit-dropdown:begin' "$F" && exit 0
for c in PVE.form.MemoryField PVE.lxc.MemoryInputPanel PVE.form.DiskStorageSelector; do
grep -q "Ext.define('$c'" "$F" || { echo "pve-unit-patch: $c not found, not patching" >&2; exit 0; }
done
v=$(dpkg-query -W -f='${Version}' pve-manager)
cp -n "$F" "/root/pvemanagerlib.js.orig-$v"
printf '\n' >> "$F"
cat "$JS" >> "$F"
systemctl restart pveproxy.service
echo "pve-unit-patch: applied"
exit 0
SH
chmod +x /usr/local/sbin/pve-unit-patch.sh
echo 'DPkg::Post-Invoke { "/usr/local/sbin/pve-unit-patch.sh || true"; };' > /etc/apt/apt.conf.d/99-pve-unit-patch
apt-get check && /usr/local/sbin/pve-unit-patch.sh
We use essential cookies to make this site work, and optional cookies to enhance your experience.