Skip to content

Failed to create a partition #115

Description

@antmoveh

Hi, hello

The following error was reported when I created the partition

failed to write 'change' to /sys/class/block/loop4p5/uevent: open /sys/fs/class/block/loop4p5/uevent: read-only file system

On the server

[root@192 loop0p5]# ll -l
total 0
-r--r--r-- 1 root root 4096 Apr 2 09:27 alignment_offset
-r--r--r-- 1 root root 4096 Apr 2 09:27 dev
-r--r--r-- 1 root root 4096 Apr 2 09:27 discard_alignment
drwxr-xr-x 2 root root 0 Apr 2 09:01 holders
-r--r--r-- 1 root root 4096 Apr 2 09:27 inflight
-r--r--r-- 1 root root 4096 Apr 2 09:27 partition
drwxr-xr-x 2 root root 0 Apr 2 09:01 power
-r--r--r-- 1 root root 4096 Apr 2 09:27 ro
-r--r--r-- 1 root root 4096 Apr 2 09:27 size
-r--r--r-- 1 root root 4096 Apr 2 09:27 start
-r--r--r-- 1 root root 4096 Apr 2 09:27 stat
lrwxrwxrwx 1 root root 0 Apr 2 09:01 subsystem -> ../../../../../class/block
drwxr-xr-x 2 root root 0 Apr 2 09:01 trace
-rw-r--r-- 1 root root 4096 Apr 2 09:01 uevent
[root@192 loop0p5]# cat uevent MAJOR=259
MINOR=4
DEVNAME=loop0p5
DEVTYPE=partition

I found the following code

func genPartChangeUEvent(d disko.Disk, pSet disko.PartitionSet) error {
if isBlk, err := blockDeviceExists(d.Path); err != nil {
return err
} else if !isBlk {
return nil
}
for _, p := range pSet {
uePath := fmt.Sprintf("/sys/class/block/%s/uevent", GetPartitionKname(d.Name, p.Number))
if err := ioutil.WriteFile(uePath, []byte("change"), 0600); err != nil && os.IsNotExist(err) {
return fmt.Errorf("%s did not exist: %v", uePath, err)
} else if err != nil {
return fmt.Errorf("failed to write 'change' to %s: %v", uePath, err)
}
}
return nil
}

I wonder, why do I need to write this file

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions