- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我怎样才能让 Linux 在不弹出 CDROM 的情况下更新它对 CDROM 大小的想法?换句话说,如何在不先弹出的情况下安装新刻录的 CDROM?
我正在对 CDROM 进行无人值守的增量备份。 my script 每天都使用“wodim -msinfo”和“genisoimage -C”生成一个图像,并使用“wodim -multi”附加到 CDROM。然后我的脚本安装 CDROM 以检查是否正确附加了新文件。只有在挂载之前更新了 Linux 对 CDROM 大小的想法,脚本才能读取新文件。大小在/sys/block/sr2/size 和/proc/partitions 中。以前我的脚本使用“eject”然后“eject -t”让 Linux 重新读取 CDROM。 “eject -t”在我的新 CDROM 刻录机上不起作用。如何在不弹出 CDROM 的情况下更新/proc/partitions?
似乎“wodim -msinfo”和“genisoimage -C”步骤还要求 CDROM 自上次刻录到 CDROM 后已弹出,否则我会收到消息“genisoimage:无效参数。在旧图像上查找错误".
有人在 2003 年问过这个问题,但他们收到的答案并没有为我更新 CDROM 大小。 http://compgroups.net/comp.os.linux.questions/rescan-cdrom-frm-command-line/456190
#include <fcntl.h>
#include <stdio.h>
#include <linux/cdrom.h>
int main(void)
{
int i = 0;
int fd = open("/dev/cdrom", O_RDWR);
if (fd == -1)
{
perror("Could not open cdrom");
return 1;
}
if (ioctl(fd, CDROM_MEDIA_CHANGED)) perror("ioctl");
if (ioctl(fd, CDROMRESET)) perror("ioctl CDROMRESET");
if (ioctl(fd, CDROM_NEXT_WRITABLE, &i))
perror("ioctl CDROM_NEXT_WRITABLE,");
else
printf("CDROM_NEXT_WRITABLE %d\n", i);
if (ioctl(fd, CDROM_LAST_WRITTEN, &i))
perror("ioctl CDROM_LAST_WRITTEN,");
else
printf("CDROM_LAST_WRITTEN %d\n", i);
return 0;
}
这正是我创建新 CDROM 时发生的情况。我必须弹出它,然后将其推回以使其安装。
% genisoimage -r -V archive -input-charset ASCII -quiet /usr/lib/vlc > /tmp/libvlc.iso
% grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 2 sr2
4
% wodim driveropts=burnfree -tao -data dev=/dev/sr2 /tmp/libvlc.iso
wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK limits.
Device type : Removable CD-ROM
Version : 0
Response Format: 2
Capabilities :
Vendor_info : 'TSSTcorp'
Identification : 'CDDVDW SE-S084C '
Revision : 'TU00'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
Driver flags : MMC-3 SWABAUDIO BURNFREE
Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R
Speed set to 1764 KB/s
Starting to write CD/DVD at speed 10.0 in real TAO mode for single session.
Last chance to quit, starting real write in 0 seconds. Operation starts.
Track 01: Total bytes read/written: 17078272/17078272 (8339 sectors).
% grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 2 sr2
4
% sudo mount /dev/sr2 /mnt
mount: /dev/sr2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sr2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
% grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 2 sr2
4
% sudo mount /dev/sr2 /mnt
mount: /dev/sr2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sr2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
% sudo eject /dev/sr2
% #push CDRW back in
% grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 16682 sr2
33364
% sudo mount /dev/sr2 /mnt
mount: /dev/sr2 is write-protected, mounting read-only
我已经尝试了各种 hdparm 选项,但它们都不起作用,它们也不会改变内核对 CDROM 大小的想法或允许它被挂载。
:; sudo hdparm -z /dev/sr2
/dev/sr2:
re-reading partition table
BLKRRPART failed: Invalid argument
:; sudo hdparm -F /dev/sr2
/dev/sr2:
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
:; sudo hdparm -Y /dev/sr2
/dev/sr2:
issuing sleep command
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
:; sudo hdparm -w /dev/sr2
/dev/sr2:
resetting drive
HDIO_DRIVE_RESET failed: Invalid argument
:; grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 2 sr2
4
:; sudo mount /dev/sr2 /mnt
mount: /dev/sr2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sr2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
指定文件系统的类型没有帮助。
:; grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 2 sr2
4
:; sudo mount -t iso9660 /dev/sr2 /mnt
[sudo] password for root:
(pam_mount.c:365): pam_mount 2.14: entering auth stage
mount: /dev/sr2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sr2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
(pam_mount.c:133): clean system authtok=0x7f0a33b97450 (1073741824)
:; grep -H sr2 /proc/partitions ; cat /sys/block/sr2/size
/proc/partitions: 11 2 2 sr2
4
我从 dmesg(1) 得到的信息是
[1209552.092616] isofs_fill_super: bread failed, dev=sr2, iso_blknum=16, block=16
最佳答案
我在使用 BD 驱动器时遇到了同样的问题。对我有用的是解除绑定(bind)(断电)设备并再次重新绑定(bind)。大致步骤如下
通过“lsscsi -v”找到USB设备
[11:0:0:0] cd/dvd TSSTcorp BDDVDW SE-506AB TS01 /dev/sr1
dir: /sys/bus/scsi/devices/11:0:0:0 [/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/host11/target11:0:0/11:0:0:0]
关闭设备/准备断开连接
sudo bash -c "echo 2-1.2 | tee /sys/bus/usb/drivers/usb/unbind"
重新启动设备/连接
sudo bash -c "echo 2-1.2 | tee /sys/bus/usb/drivers/usb/bind"
解除绑定(bind)/绑定(bind)是重置许多 USB 设备的好方法......
关于linux - 如何在不弹出 CDROM 的情况下在 Linux 中更新 CDROM 大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28517124/
我怎样才能让 Linux 在不弹出 CDROM 的情况下更新它对 CDROM 大小的想法?换句话说,如何在不先弹出的情况下安装新刻录的 CDROM? 我正在对 CDROM 进行无人值守的增量备份。 m
有谁知道在 Windows 2000 或更高版本上以编程方式关闭 CD 托盘的方法?打开 CD 托盘存在,但我似乎无法关闭它,尤其是在 W2k 下。 如果可能的话,我特别想从批处理文件中寻找一种方法来
我尝试使用 DeviceIoControl 函数(Win32 API 函数)弹出我的 CDROM 驱动器,当我的 CDROM 驱动器没有磁盘时它工作正常,但是在插入磁盘后,Marshal .GetLa
我需要在 Linux 上用 C 语言编写函数来访问所有安装的 CDROM 并执行一些操作。 我可以在 BSD 上使用 count = getmntinfo(&buf, 0); 并在所有设备上循环并检查
我正在构建一个 docker 镜像,其中还涉及一个小的 yum install .我目前在防火墙和访问控制使docker pull 的位置。 , yum install等非常慢。 在我的例子中,它是一
当用户在 Linux 平台上插入或取出 CD 时,是否有一种干净的方法来检测或接收事件? 最佳答案 udev 监控硬件并将事件转发给 dbus。你只需要一些 dbus 监听器。使用 dbus-moni
我正在尝试使用 Python 模块(准确地说是 python-dvdvideo)来克隆 ISO 镜像。如果我将我的计算机上已有的 ISO 文件的文件路径传递给它,所提供的类工作正常,但如果我尝试将我的
我正在寻找一个在 Linux 上运行的 C++ 中创建的函数,如果 CDRom 媒体是 DVD,则返回 true,如果是其他任何媒体(例如音频 CD),则返回 false。 我一直在使用 ioctl
在 Linux 中检测 CDROM 介质移除和插入的最简单方法是什么?我想写一些简单的代码来处理这个问题。例如,只需为媒体插入绑定(bind)一个事件并实现处理程序。 谢谢! 最佳答案 尝试man u
2017 年 10 月 4 日更新:请参阅下面我的回答。感谢 DanielB,因为如果没有 Daniel 的帮助我无法解决问题,所以我将接受他的回答而不是我自己的回答。 我是 libvirt 和系统管
我尝试使用 PyGame 在带有 python3 的 Raspberry Pi4 上播放旧的音频 cd 收藏。 据我所知,cd audio 的数据结构与声音或流媒体不同,并且音频 CD 不像数据 CD
我是一名优秀的程序员,十分优秀!