Skip to content

Commit

Permalink
fix: skip ram disks
Browse files Browse the repository at this point in the history
Fixes siderolabs/go-blockdevice#113

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Oct 16, 2024
1 parent a9bff3a commit 39fe285
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/app/machined/pkg/controllers/block/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ func (ctrl *DiscoveryController) Run(ctx context.Context, r controller.Runtime,
for iterator := devices.Iterator(); iterator.Next(); {
device := iterator.Value()

if device.TypedSpec().Major == 1 {
// ignore ram disks (/dev/ramX), major number is 1
// ref: https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
// ref: https://github.com/util-linux/util-linux/blob/c0207d354ee47fb56acfa64b03b5b559bb301280/misc-utils/lsblk.c#L2697-L2699
continue
}

allDevices[device.Metadata().ID()] = struct{}{}

if device.TypedSpec().Parent != "" {
Expand Down
7 changes: 7 additions & 0 deletions internal/app/machined/pkg/controllers/block/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func (ctrl *DisksController) Run(ctx context.Context, r controller.Runtime, logg
continue
}

if device.TypedSpec().Major == 1 {
// ignore ram disks (/dev/ramX), major number is 1
// ref: https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
// ref: https://github.com/util-linux/util-linux/blob/c0207d354ee47fb56acfa64b03b5b559bb301280/misc-utils/lsblk.c#L2697-L2699
continue
}

if lastObserved, ok := lastObservedGenerations[device.Metadata().ID()]; ok && device.TypedSpec().Generation == lastObserved {
// ignore disks which have some generation as before (don't query them once again)
touchedDisks[device.Metadata().ID()] = struct{}{}
Expand Down

0 comments on commit 39fe285

Please sign in to comment.