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

Feature: eject without root #78

Open
Nidrop opened this issue Apr 21, 2021 · 3 comments
Open

Feature: eject without root #78

Nidrop opened this issue Apr 21, 2021 · 3 comments

Comments

@Nidrop
Copy link

Nidrop commented Apr 21, 2021

Eject requires root privilegies. It will be nice if ldmc take care of ejecting device without root. It is relevant for external HDD's to spin-down the drive

@LemonBoy
Copy link
Owner

What's the output of eject -v /dev/whatever?
Adding the whole code of eject.c into ldm is a no-go and you can't use the callback facility as the scripts are not executed as root... I'll have to think of how to implement this.

@Nidrop
Copy link
Author

Nidrop commented Apr 22, 2021

I don't have HDD with me now, but there is output from USB stick if needed:

user@user-pc:~$ sudo eject -v /dev/sdc
eject: имя устройства - '/dev/sdc'
eject: /dev/sdc: не примонтирован
eject: /dev/sdc: is whole-disk device
eject: /dev/sdc: trying to eject using CD-ROM eject command
eject: CD-ROM eject command failed
eject: /dev/sdc: trying to eject using SCSI commands
eject: SCSI eject succeeded

Also the author of pmount wrote the article about how he implements safe removal feature long time ago, maybe it helps

@Nidrop
Copy link
Author

Nidrop commented Jun 28, 2021

now I have 2 external HDDs: Seagate: ST1000LM048-2E7172 and Western Digital: WD5000LMVW-11VEDS2. Both works differently.
Also I found that hdparm can change power mode: -S for active/idle, -y for standby, -Y for sleeping.

Seagate
after eject it left in lsblk output and in active/idle power state:

[user@user-pc ~]$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    1  14,4G  0 disk 
├─sda1         8:1    1   150M  0 part 
└─sda2         8:2    1  14,3G  0 part 
sdb            8:16   0 931,5G  0 disk 
└─sdb1         8:17   0 931,5G  0 part 
mmcblk0      179:0    0  29,1G  0 disk 
├─mmcblk0p1  179:1    0   300M  0 part /boot/efi
├─mmcblk0p2  179:2    0     4G  0 part [SWAP]
└─mmcblk0p3  179:3    0  24,8G  0 part /
mmcblk0boot0 179:8    0     4M  1 disk 
mmcblk0boot1 179:16   0     4M  1 disk 
[user@user-pc ~]$ sudo eject -v /dev/sdb
eject: имя устройства - `/dev/sdb'
eject: /dev/sdb: не примонтирован
eject: /dev/sdb: is whole-disk device
eject: /dev/sdb: trying to eject using CD-ROM eject command
eject: CD-ROM eject command failed
eject: /dev/sdb: trying to eject using SCSI commands
eject: SCSI eject succeeded
[user@user-pc ~]$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    1  14,4G  0 disk 
├─sda1         8:1    1   150M  0 part 
└─sda2         8:2    1  14,3G  0 part 
sdb            8:16   0 931,5G  0 disk 
└─sdb1         8:17   0 931,5G  0 part 
mmcblk0      179:0    0  29,1G  0 disk 
├─mmcblk0p1  179:1    0   300M  0 part /boot/efi
├─mmcblk0p2  179:2    0     4G  0 part [SWAP]
└─mmcblk0p3  179:3    0  24,8G  0 part /
mmcblk0boot0 179:8    0     4M  1 disk 
mmcblk0boot1 179:16   0     4M  1 disk 
[user@user-pc ~]$ sudo hdparm -C /dev/sdb

/dev/sdb:
 drive state is:  active/idle

switching power states works fine:

[user@user-pc ~]$ sudo hdparm -S 0 /dev/sdb

/dev/sdb:
 setting standby to 0 (off)
[user@user-pc ~]$ sudo hdparm -C /dev/sdb

/dev/sdb:
 drive state is:  active/idle
[user@user-pc ~]$ sudo hdparm -y /dev/sdb

/dev/sdb:
 issuing standby command
[user@user-pc ~]$ sudo hdparm -C /dev/sdb

/dev/sdb:
 drive state is:  standby

Also when sleeping mode is active, it takes 10-15 seconds to wake it up with -C command. After waking up it is in standby mode.

Western Digital
eject does not work:

[user@user-pc ~]$ sudo eject -v /dev/sdb
eject: имя устройства - `/dev/sdb'
eject: /dev/sdb: не примонтирован
eject: /dev/sdb: is whole-disk device
eject: /dev/sdb: trying to eject using CD-ROM eject command
eject: CD-ROM eject command failed
eject: /dev/sdb: trying to eject using SCSI commands
eject: SCSI eject failed
eject: /dev/sdb: trying to eject using floppy eject command
eject: floppy eject command failed
eject: /dev/sdb: trying to eject using tape offline command
eject: tape offline command failed
eject: невозможно извлечь

hdparm output looks unpromising but works mostly ok:

[user@user-pc ~]$ sudo hdparm -C /dev/sdb

/dev/sdb:
SG_IO: bad/missing sense data, sb[]:  70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 drive state is:  unknown
[user@user-pc ~]$ sudo hdparm -y /dev/sdb

/dev/sdb:
 issuing standby command
SG_IO: bad/missing sense data, sb[]:  70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[user@user-pc ~]$ sudo hdparm -Y /dev/sdb

/dev/sdb:
 issuing sleep command
SG_IO: bad/missing sense data, sb[]:  70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

I heard the disk stop in standby mode. Sleeping mode takes time to wake up but it seems it can't completely wake up after that, subsequent commands with this drive take more time to execute.

Summary
Eject can't spin-down the drive. I suggest using standby power mode. I'm not sure about sleeping mode, who knows how it will work with other devices.

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