fix(ns-storage): drop the ns_data label when releasing the storage - #1874
Open
gsanchietti wants to merge 2 commits into
Open
fix(ns-storage): drop the ns_data label when releasing the storage#1874gsanchietti wants to merge 2 commits into
gsanchietti wants to merge 2 commits into
Conversation
The storage is auto-mounted by filesystem label, but remove-storage only released the partition when it lived on the OS disk. A storage removed from a secondary drive kept its ns_data label, so once a new storage was created two partitions matched and block mount stacked both of them onto /mnt/data at boot; ns.storage get-configuration reported the wrong device for the same reason. Clear the label with tune2fs when the partition is on a secondary drive, keeping the partition itself so that its logs remain available for later inspection. Also read the partition number from sysfs instead of assuming the OS disk partition is number 3. Assisted-by: Claude Code:claude-opus-5[1m]
With no storage configured, looking up the parent disk of an empty device name made lsblk exit 32 and, under set -e, remove-storage bailed out before doing anything. ns.factoryreset runs the script unconditionally, so a factory reset silently skipped the storage teardown. Guard the lookup, the umount and the partition release on an actually mounted storage, and tolerate the missing uci sections and crontab. Assisted-by: Claude Code:claude-opus-5[1m]
Tbaile
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The persistent storage is auto-mounted by filesystem label (
fstab.ns_data.label=ns_data), butremove-storageonly released the old partition when it lived on the OS disk:A storage removed from a secondary drive therefore kept its
ns_datalabel. Once a new storage was created, two partitions matched the label andblock mountstacked both onto/mnt/dataat boot.ns.storage get-configurationreported the wrong device for the same reason.Two commits:
tune2fs -L ""and keep the partition, so its logs stay available for later inspection — the behaviour proposed in the issue. On the OS disk the partition is still deleted, but the partition number now comes from/sys/class/block/<part>/partitioninstead of the hardcoded3.lsblk -lno pkname /dev/exits 32 andset -ekilled the script before any teardown ran.ns.factoryresetinvokesremove-storageunconditionally, so a factory reset silently skipped the storage teardown entirely.No new dependencies —
partedandtune2fsare already inDEPENDS.Related issue
#1862
How to test
On a machine with the OS disk plus a second drive:
Reverse cycle (primary → delete → secondary) should leave partition 3 gone from the primary drive's GPT and the secondary partition as the only
ns_data.For the second commit, run
/usr/sbin/remove-storagewith no storage configured: it must exit 0 and leave dnsmasq, rsyslog, cron and victoria-metrics running.Verified on a dev VM (OS on
vdawith abios_grubpartition 128, secondarynvme0n1): all of the above, before and after reboot.Known limitation
Systems that are already double-mounted are not repaired automatically —
data_partresolves to two devices there. They need one manualtune2fs -L "" /dev/<stale-partition>; afterwards this fix keeps them correct.