Closed unc0 closed 9 years ago
What did you do here? By reading the log it seems that you're trying to unmount an already unmounted device (which was brutally removed from all those Buffer I/O errors). Regarding #14, ldm mounts a device only when udev dispatches a "add" event, so only god knows why the hell udev thinks that a freshly unplugged device is new. This error seems to happen only on NTFS drives though, I suspect there's something wrong with ntfs-3g.
What did you do here?
start ldm.service then pumount -D /mnt/2TB_CETA
.
Regarding #14, ldm mounts a device only when udev dispatches a "add" event, so only god knows why the hell udev thinks that a freshly unplugged device is new. This error seems to happen only on NTFS drives though, I suspect there's something wrong with ntfs-3g.
But ldm -r
or sudo umount
won't suspend that USB controller.
If I use pumount -D
unmount a device, restart ldm.service won't remount this device(suspended?), ldm will mount that device unless you re-plug in it.
This pumount -D
will disconnect the USB device as if you plug out the USB device after normal ldm -r
. I'm using udev-block-notify to notify this kind of event from udev.
I feel a bit lost... Does ldm unmount the device if run with -R ? Does ldm complain/remount the disk if you run pumount (with or without -D) ? (I'm talking about vanilla ldm)
Does ldm unmount the device if run with -R ?
Yes, if that device is NTFS ldm will remount it.
Does ldm complain/remount the disk if you run pumount (with or without -D) ?
Some disk I/O complain in journalctl, ldm won't remount that device. You will have to unplug that device, plug in again, ldm will mount it.
pumount's -D argument is an addon by pumount-safe-removal package. It mimics Windows "Safely remove devices from your computer".
I don't know whether this "safely removal" action is important to Linux/MacOSX. But before I met this pumount-safe-removal, I already broke some multi-card reader under Linux. ldm mounted that vfat without flush option at that time, so Linux copying those files in light speed, but those files were in cache...And that card reader has no led indicator, I cannot tell whether it finish sync copying data, I was using original pumount to unmount that card reader, without "safely removal" I got data loss, then finally that card reader is broken.
We should understand first why udev sends an "add" event only when NTFS disks are unmounted. The "safe removal" thing turns off the device so it's a sort of work around the issue.
The "safe removal" thing turns off the device so it's a sort of work around the issue.
It's a work around to #14, it is also good for "no led indicator" USB devices(Android devices' USB disk mode also lack of "I/O indicator"). Because it sync(), unbind device, suspend it, so you can safely remove device with confident.
I just tried this in ntfs-3g sources:
$ ag -i udev -B 2 -A 2
ntfs-3g_ntfsprogs-2013.1.13AR.3/libfuse-lite/fusermount.c
566- }
567- } else if (errno == ENODEV ||
568: errno == ENOENT) /* check for ENOENT too, for the udev case */
569- return -2;
570- else {
ntfs-3g_ntfsprogs-2013.1.13/libfuse-lite/fusermount.c
566- }
567- } else if (errno == ENODEV ||
568: errno == ENOENT) /* check for ENOENT too, for the udev case */
569- return -2;
570- else {
Does FUSE cause #14?
I don't really know as I don't have any NTFS formatted disk at the moment. Anyway, the unmount command takes care of flushing the cache, don't really know about ntfs-3g binary. ldm shouldn't disable the device as it's only task is to mount/unmount partitions and beside the adherence to the KISS principle there's no 1:1 mapping of filesystems to devices. Guess what happens if you disable a device that has another partition mounted somewhere else?
OK, I will continue use pumount -D on NTFS disk, ldm -r on the others.
The latest commit fixes #14. Please let me know if the commit helped in your case too.
A 2.5'' USB(2.0)-powered HDD with 1 vFAT, 2 NTFS partition works great with latest commit.
Syslog got this line ntfs-3g[15558]: [32B blob data]
after executing ldm -r /mnt/xxx
.
But my 3.5'' USB3.0 HDD bay(with power adapter) with 1 NTFS partition doesn't work.
journalctl -f
got nothing new after executing ldm -r /mnt/2TB_CETA
, but it can be unmounted using pumount -D
.
Hrm, does the latter HDD get mounted by ldm ? Can you show me your mtab before using pumount and after ? I suspect that libmount doesn't trigger the mtab refresh making the data in the table stale.
Hrm, does the latter HDD get mounted by ldm ?
Yes.
Before ldm auto mount:
rootfs / rootfs rw 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=8194256k,nr_inodes=2048564,mode=755 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
/dev/sdc2 / ext4 rw,relatime,discard,data=ordered 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/bfqio cgroup rw,nosuid,nodev,noexec,relatime,bfqio 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=35,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
systemd-1 /boot autofs rw,relatime,fd=43,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
systemd-1 /home autofs rw,relatime,fd=45,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
tmpfs /tmp tmpfs rw 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/sdc1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,flush,tz=UTC,errors=remount-ro 0 0
/dev/sdc3 /home ext4 rw,relatime,discard,data=ordered 0 0
/dev/sda1 /var ext4 rw,relatime,data=ordered 0 0
/dev/sda2 /home/unco/data ext4 rw,relatime,data=ordered 0 0
/dev/sda3 /home/unco/win_e fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb1 /home/unco/win_1t fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
After ldm automount:
rootfs / rootfs rw 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=8194256k,nr_inodes=2048564,mode=755 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
/dev/sdc2 / ext4 rw,relatime,discard,data=ordered 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/bfqio cgroup rw,nosuid,nodev,noexec,relatime,bfqio 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=35,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
systemd-1 /boot autofs rw,relatime,fd=43,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
systemd-1 /home autofs rw,relatime,fd=45,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
tmpfs /tmp tmpfs rw 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/sdc1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,flush,tz=UTC,errors=remount-ro 0 0
/dev/sdc3 /home ext4 rw,relatime,discard,data=ordered 0 0
/dev/sda1 /var ext4 rw,relatime,data=ordered 0 0
/dev/sda2 /home/unco/data ext4 rw,relatime,data=ordered 0 0
/dev/sda3 /home/unco/win_e fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb1 /home/unco/win_1t fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdd2 /mnt/2TB_CETA fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
After pumount -D:
rootfs / rootfs rw 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=8194256k,nr_inodes=2048564,mode=755 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
/dev/sdc2 / ext4 rw,relatime,discard,data=ordered 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/bfqio cgroup rw,nosuid,nodev,noexec,relatime,bfqio 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=35,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
systemd-1 /boot autofs rw,relatime,fd=43,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
systemd-1 /home autofs rw,relatime,fd=45,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
tmpfs /tmp tmpfs rw 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/sdc1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,flush,tz=UTC,errors=remount-ro 0 0
/dev/sdc3 /home ext4 rw,relatime,discard,data=ordered 0 0
/dev/sda1 /var ext4 rw,relatime,data=ordered 0 0
/dev/sda2 /home/unco/data ext4 rw,relatime,data=ordered 0 0
/dev/sda3 /home/unco/win_e fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb1 /home/unco/win_1t fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
And I guess that after ldm -r the mtab stays unchanged, right ?
I rebooted then ldm -r
works fine on this device. Maybe pumount -D
caused some problem in the last session. Thanks for your help, I think this issue can be closed now.
I was using that USB HDD bay with my 2TB_CETA ntfs partition today after reboot, ldm auto mounted it as usual. But after I finished copy files, ldm -r
doesn't work again, I can unmount it with pumount
by the way.
Does it fail without any error? Did you check with lsof if something was operating on the disk? This is a curse heh
No error in journalctl. I will check lsof and paste result here tomorrow.
I opened a movie so lsof show something on the mountpoint, then do ldm -r
, I think that's why ldm won't unmount it. Will you add a syslog on this thing and a return code on ldm -r
. I can use that return code in my notify script when ldm -r
failing to unmount because file locks.
I've notice that if file locks happened and ldm -r
failed, ldm -r
will never works again on this mountpoint even I killed all related processes and lsof shows nothing.
ldm should alreasy print out to syslog if something went wrong when unmounting the device.
In my case, it print out nothing.
~ ❯❯❯ lsof /mnt/2TB_CETA
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
zathura 16672 unco cwd DIR 8,50 8192 5 /mnt/2TB_CETA
zathura 16672 unco 14r REG 8,50 7864970 40769 /mnt/2TB_CETA/ACPIspec50.pdf
The return code is 0.
~ ❯❯❯ ldm -r /mnt/2TB_CETA
~ ❯❯❯ echo $?
0
~ ❯❯❯ sudo journalctl -b | grep ldm
Feb 18 08:56:05 unco-new ldm[239]: ldm 0.4.3
Feb 18 08:56:05 unco-new ldm[239]: Starting up...
Feb 18 08:56:05 unco-new ldm[239]: Entering the main loop
Feb 18 18:42:55 home ldm[26093]: Error while unmounting /dev/sdc1 (Device or resource busy)
Feb 18 18:42:56 home ldm[26093]: Error while unmounting /dev/sdc1 (Device or resource busy)
Feb 18 18:42:57 home ldm[26093]: Error while unmounting /dev/sdc1 (Device or resource busy)
Feb 18 18:43:03 home ntfs-3g[26096]: Unmounting /dev/sdc1 ()
Works fine for me, there's something wrong on your end. Are you using the latest git version ? Is the device mounted by ldm? It won't unmount devices mounted before starting it. If it's related to locking a solution might be doing a lazy unmount, but that's pretty dangerous for the HDD. Nice ACPI doc you have there :)
Are you using the latest git version ?
- local/ldm-git 20140214.101-1
- local/ntfs-3g-ar 2013.1.13AR.3-1
- local/systemd 208-11
Is the device mounted by ldm? It won't unmount devices mounted before starting it.
The ldm.service started at moring(08:56) after I booted. I was doing ldm -r
at night.
If it's related to locking a solution might be doing a lazy unmount, but that's pretty dangerous for the HDD.
I checked pmount sourcecode, I think they are using lazy unmount.
Nice ACPI doc you have there :)
I was installing a hackintosh on Acer notebook few years ago, doing lots of DSDT patch, this document helps alot.
I mount that HDD today, I locks some files the same way, ldm -r
still report nothing.
-- Reboot --
Feb 19 09:08:22 unco-new systemd[1]: Starting lightweight device mounter...
Feb 19 09:08:22 unco-new systemd[1]: Started lightweight device mounter.
Feb 19 09:08:22 unco-new ldm[244]: ldm 0.4.3
Feb 19 09:08:22 unco-new ldm[244]: Starting up...
Feb 19 09:08:22 unco-new ldm[244]: Entering the main loop
Feb 19 11:41:12 unco-new ntfs-3g[9694]: Version 2013.1.13AR.3 external FUSE 29
Feb 19 11:41:12 unco-new ntfs-3g[9694]: Mounted /dev/sdd2 (Read-Write, label "2TB_CETA", NTFS 3.1)
Feb 19 11:41:12 unco-new ntfs-3g[9694]: Cmdline options: rw,uid=1000,gid=100,utf8
Feb 19 11:41:12 unco-new ntfs-3g[9694]: Mount options: rw,utf8,allow_other,nonempty,relatime,default_permissions,fsna
Feb 19 11:41:12 unco-new ntfs-3g[9694]: Global ownership and permissions enforced, configuration type 7
Feb 19 11:45:23 unco-new systemd[1]: Stopping lightweight device mounter...
Feb 19 11:45:23 unco-new ldm[244]: Terminating...
Feb 19 11:45:23 unco-new systemd[1]: Starting lightweight device mounter...
Feb 19 11:45:23 unco-new systemd[1]: Started lightweight device mounter.
Feb 19 11:45:23 unco-new ldm[10357]: ldm 0.4.3
Feb 19 11:45:23 unco-new ldm[10357]: Starting up...
Feb 19 11:45:23 unco-new ldm[10357]: Entering the main loop
~ ❯❯❯ lsof /mnt/2TB_CETA
~ ⏎1 ❯❯❯ ldm -r /mnt/2TB_CETA # lsof return 1
~ ❯❯❯ #ldm return 0
This is related to #14 . I'm using a 3.5'' HDD USB bay with power adapter.
I'm using pmount-safe-removal to solve #14 , although ldm will show some warning when I
pumount -D some ntfs partition
:Using this pmount command, the power light of my HDD bay will go red as I safely remove this in Windows. It will stop the HDD, so I can turn it off without breaking it.
According to pmount-safe-removal author's blog post. We need these steps to safely remove an USB device:
I tried to patch ldm to get this safely remove feature, but it won't trigger those udev events like pumount. This is my gist: https://gist.github.com/unc0/8916528#file-ldm-safely-remove-patch-L100 .