Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create a partition #115

Open
antmoveh opened this issue Apr 2, 2022 · 1 comment
Open

Failed to create a partition #115

antmoveh opened this issue Apr 2, 2022 · 1 comment

Comments

@antmoveh
Copy link

antmoveh commented Apr 2, 2022

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

@smoser
Copy link
Collaborator

smoser commented Jan 12, 2024

Huh. sorry for the very slow reply.
In order to make the system aware of the new partition, we create a change uevent to tell udev to re-read name/id/guid on a partition type. 24cae51

its strange that that would be read-only though. i guess you're in a container?

(i realize this is 2 years old and you're probably long moved on. sorry).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants