block devices: filter the root disk

This commit is contained in:
Girish Ramakrishnan
2025-09-10 11:40:13 +02:00
parent c8e34ac522
commit ba14d1e846
3 changed files with 20 additions and 15 deletions
+18 -12
View File
@@ -319,22 +319,28 @@ async function getLogs(unit, options) {
// this gets block devices as opposed to mounted filesystems. this is used for configuring backups and volumes in the frontend
async function getBlockDevices() {
const result = await shell.spawn('lsblk', ['--paths', '--json', '--list', '--fs', '--output', '+rota'], { encoding: 'utf8' });
const info = safe.JSON.parse(result);
const output = await shell.spawn('lsblk', ['--paths', '--json', '--list', '--fs', '--output', '+rota'], { encoding: 'utf8' });
const info = safe.JSON.parse(output);
if (!info) throw new BoxError(BoxError.INTERNAL_ERROR, `failed to parse lsblk: ${safe.error.message}`);
const devices = info.blockdevices.filter(d => d.fstype === 'ext4' || d.fstype === 'xfs');
return devices.map(function (d) {
return {
path: d.name,
size: d.fsavail || 0,
type: d.fstype,
uuid: d.uuid,
rota: d.rota, // false (ssd) true (hdd) . unforuntately, this is not set correctly when virtualized (like in DO)
mountpoint: Array.isArray(d.mountpoints) ? d.mountpoints[d.mountpoints.length-1] : d.mountpoint // we only support one mountpoint here old lsblk only exposed one via .mountpoint
};
}).filter(d => d.mountpoint !== '/boot');
const result = [];
for (const device of devices) {
const mountpoints = Array.isArray(device.mountpoints) ? device.mountpoints : [ device.mountpoint ]; // we only support one mountpoint here old lsblk only exposed one via .mountpoint
if (mountpoints.includes('/') || mountpoints.includes('/boot')) continue;
result.push({
path: device.name,
size: device.fsavail || 0,
type: device.fstype,
uuid: device.uuid,
rota: device.rota, // false (ssd) true (hdd) . unforuntately, this is not set correctly when virtualized (like in DO)
mountpoints
});
}
return result;
}
async function checkRebootRequired() {