Answers:
为了从驱动器中弹出磁盘(无论是CD还是DVD),请打开终端并简单地执行eject
命令。
sudo
。
eject
为我工作,然后停止工作,并出现以下错误:“弹出:/ dev / cdrom:找不到具有给定名称的安装点或设备”。执行后eject /dev/sr0
,我可以再次使用eject
,eject -T
等等
命令:
eject
eject -t
alias opentray='eject'
弹出驱动器时会出现一些问题。有时它们不希望弹出,因为它们已安装等。您可以使用eject -l /media/mountpoint
或(/mnt/mountpoint
)覆盖它们。我编写了一个函数,只需opentray
在命令行中键入即可调用。
仅当
/dev/sr0
(与相同/dev/cdrom
,只是在符号上链接到/dev/sr0
)function opentray ()
{
mountdir="/media/DVD"
if [ -d "${mountdir}" ] # If directory ${mountdir} exists
then
if [ $(mount | grep -c "${mountdir}") = 1 ] # If drive is mounted, then
then
echo "/dev/sr0 is now mounted to ${mountdir}. I'll try to unmount it first and eject/open the tray."
umount -l "${mountdir}"
rm -r "${mountdir}"
sysctl -w dev.cdrom.autoclose=0 # Ensure drive doesn't auto pull tray back in.
eject
exit
else
echo "/dev/sr0 is not mounted. Opening the tray should be easy. Ejecting/opening now."
rm -r "${mountdir}"
sysctl -w dev.cdrom.autoclose=0 # Ensure drive doesn't auto pull tray back in.
eject
exit
fi
else
echo 'The directory "${mountdir}" does not exist. Ejecting/opening the tray.'
sysctl -w dev.cdrom.autoclose=0 # Ensure drive doesn't auto pull tray back in.
eject
exit
fi
}
为了完整起见,您可以将此别名添加到您的.bashrc
(或.bash_aliases
文件)中,以从命令行将托盘拉回。您不需要是root。
alias closetray='eject -t'
在应用程序“终端”中,输入:
eject
eject --force
eject --force
→eject: unrecognized option '--force'
eject -F