local diskpart = require "diskpart" local rtfs = require "rtfs" local tA = {...} local fsname,fname = fs.resolve(tA[1]) local drive, part = fs.address(tA[1]):match("([%x%-]+)/(%d)") part=tonumber(part) print(drive,part,fname) local m = rtfs.mount(drive.."/"..part) local np = {fname, "boot", 0, 0} for i, tp, ex, st, sl, n in m:allIEntries() do if tp == 9 and n == fname then assert(ex == 0, "boot file cannot be fragmented") np[3], np[4] = st, math.ceil(sl/512) end end local allparts = diskpart.getPartitions(drive) local pindex = #allparts+1 np[3] = np[3] - (allparts[part][3] - 1) for k,v in ipairs(allparts) do if v[2] == "boot" then pindex = k break end end allparts[pindex] = np for k,v in ipairs(allparts) do print(k, table.unpack(v)) end diskpart.setPartitions(drive, allparts)