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

Tries to wipe a directory - dd: failed to open '/dev/disk/by-id/': Is a directory #108

Closed
nobuto-m opened this issue Mar 27, 2023 · 6 comments
Assignees

Comments

@nobuto-m
Copy link
Contributor

$ snap list microceph
Name       Version        Rev  Tracking       Publisher   Notes
microceph  0+git.6208776  220  latest/stable  canonical✓  -

By following the tutorial:
https://canonical-microceph.readthedocs-hosted.com/en/latest/tutorial/add_osds/
microceph tried to wipe a directory.

$ sudo microceph disk add /dev/vdc --wipe
Error: Failed adding new disk: Failed to wipe the device: Failed to run: dd if=/dev/zero of=/dev/disk/by-id/ bs=4M count=10 status=none: exit status 1 (dd: failed to open '/dev/disk/by-id/': Is a directory)
@nobuto-m
Copy link
Contributor Author

nobuto-m commented Mar 27, 2023

It may be a corner case of using virtio disks only. But I think if disk.DeviceID is not found, it shouldn't proceed further like executing dd at least.

path = fmt.Sprintf("/dev/disk/by-id/%s", disk.DeviceID)

@sabaini
Copy link
Collaborator

sabaini commented Mar 27, 2023

I agree there needs to be better handling for the case where there's no /dev/disk/by-id/x

OTOH I'm also curious on why that disk wasn't found (using virtio shouldn't be a problem) -- if that disk indeed does exist?

If so, would you be able to provide some diagnostics @nobuto-m ?

sudo lsblk -f
sudo blkid /dev/vdc

@nobuto-m
Copy link
Contributor Author

It was a virtio disk instead of SATA/SCSI.

ubuntu@test:~$ sudo lsblk -f
sudo blkid /dev/vdc
NAME    FSTYPE   FSVER            LABEL           UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0   squashfs 4.0                                                                         0   100% /snap/core20/1822
loop1   squashfs 4.0                                                                         0   100% /snap/lxd/24322
loop2   squashfs 4.0                                                                         0   100% /snap/snapd/18357
vda                                                                                                   
├─vda1  ext4     1.0              cloudimg-rootfs 9a7ad317-1eac-4f04-8300-403eacd3bd76   13.9G     9% /
├─vda14                                                                                               
└─vda15 vfat     FAT32            UEFI            59D5-47E7                              98.3M     6% /boot/efi
vdb     iso9660  Joliet Extension cidata          2023-03-27-08-40-10-00                              
vdc                                                                                                   


ubuntu@test:~$ sudo blkid /dev/vdc


ubuntu@test:~$ ll /dev/disk/by-*/
/dev/disk/by-label/:
total 0
drwxr-xr-x 2 root root 100 Mar 27 08:40 ./
drwxr-xr-x 6 root root 120 Mar 27 08:40 ../
lrwxrwxrwx 1 root root  11 Mar 27 08:40 UEFI -> ../../vda15
lrwxrwxrwx 1 root root   9 Mar 27 08:40 cidata -> ../../vdb
lrwxrwxrwx 1 root root  10 Mar 27 08:40 cloudimg-rootfs -> ../../vda1

/dev/disk/by-partuuid/:
total 0
drwxr-xr-x 2 root root 100 Mar 27 08:40 ./
drwxr-xr-x 6 root root 120 Mar 27 08:40 ../
lrwxrwxrwx 1 root root  11 Mar 27 08:40 0fd15b0f-2a30-4875-b285-1e41c719261c -> ../../vda14
lrwxrwxrwx 1 root root  10 Mar 27 08:40 4f2db25b-897b-4eff-9cc2-0aa17f8e4b4b -> ../../vda1
lrwxrwxrwx 1 root root  11 Mar 27 08:40 b3140944-0cf3-48e0-8732-4977793e18a5 -> ../../vda15

/dev/disk/by-path/:
total 0
drwxr-xr-x 2 root root 280 Mar 27 08:40 ./
drwxr-xr-x 6 root root 120 Mar 27 08:40 ../
lrwxrwxrwx 1 root root   9 Mar 27 08:40 pci-0000:04:00.0 -> ../../vda
lrwxrwxrwx 1 root root  10 Mar 27 08:40 pci-0000:04:00.0-part1 -> ../../vda1
lrwxrwxrwx 1 root root  11 Mar 27 08:40 pci-0000:04:00.0-part14 -> ../../vda14
lrwxrwxrwx 1 root root  11 Mar 27 08:40 pci-0000:04:00.0-part15 -> ../../vda15
lrwxrwxrwx 1 root root   9 Mar 27 08:40 pci-0000:05:00.0 -> ../../vdb
lrwxrwxrwx 1 root root   9 Mar 27 08:40 pci-0000:06:00.0 -> ../../vdc
lrwxrwxrwx 1 root root   9 Mar 27 08:40 virtio-pci-0000:04:00.0 -> ../../vda
lrwxrwxrwx 1 root root  10 Mar 27 08:40 virtio-pci-0000:04:00.0-part1 -> ../../vda1
lrwxrwxrwx 1 root root  11 Mar 27 08:40 virtio-pci-0000:04:00.0-part14 -> ../../vda14
lrwxrwxrwx 1 root root  11 Mar 27 08:40 virtio-pci-0000:04:00.0-part15 -> ../../vda15
lrwxrwxrwx 1 root root   9 Mar 27 08:40 virtio-pci-0000:05:00.0 -> ../../vdb
lrwxrwxrwx 1 root root   9 Mar 27 08:40 virtio-pci-0000:06:00.0 -> ../../vdc

/dev/disk/by-uuid/:
total 0
drwxr-xr-x 2 root root 100 Mar 27 08:40 ./
drwxr-xr-x 6 root root 120 Mar 27 08:40 ../
lrwxrwxrwx 1 root root   9 Mar 27 08:40 2023-03-27-08-40-10-00 -> ../../vdb
lrwxrwxrwx 1 root root  11 Mar 27 08:40 59D5-47E7 -> ../../vda15
lrwxrwxrwx 1 root root  10 Mar 27 08:40 9a7ad317-1eac-4f04-8300-403eacd3bd76 -> ../../vda1

@sabaini
Copy link
Collaborator

sabaini commented Mar 27, 2023

Thanks @nobuto-m . Is the output of the ll /dev/disk/by-*/ truncated? Seems it's missing the by-id folder?

@nobuto-m
Copy link
Contributor Author

No, that was the full output. There is no by-id folder unless I attach a SATA device to a VM for example.

@sabaini sabaini self-assigned this Mar 27, 2023
sabaini added a commit to sabaini/microceph that referenced this issue Mar 27, 2023
Don't assume all disks have a /dev/disk/by-id entry when looking for a
stable path, this is not necessarily the case e.g. for virtio disks (cf.
systemd/systemd#17670).

Fix issue canonical#108

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
@nobuto-m
Copy link
Contributor Author

Fixed by #114

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

3 participants