如何显示USB设备世代号?
我需要确认usb存储设备是usb 3.0。是否可以在命令行上确认 USB 设备生成?不是端口,端口已经通过 lsusb 和 lsusb -t、颜色等确认为 3.0。
试图使用 gnome 磁盘基准测试确定 USB 驱动器设备是 3.0 还是 2.0
样本大小:10.0 MB
平均读取速率:13.5 MB/s(100 个样本)
平均访问时间:0.53 毫秒(1000 个样本)
如何显示USB设备世代号?
我需要确认usb存储设备是usb 3.0。是否可以在命令行上确认 USB 设备生成?不是端口,端口已经通过 lsusb 和 lsusb -t、颜色等确认为 3.0。
试图使用 gnome 磁盘基准测试确定 USB 驱动器设备是 3.0 还是 2.0
样本大小:10.0 MB
平均读取速率:13.5 MB/s(100 个样本)
平均访问时间:0.53 毫秒(1000 个样本)
警告:我在一个没有任何内容的驱动器上使用了这些命令(
/dev/sdb
)。不要在带有任何重要内容的驱动器上尝试此操作。
我正在尝试一些,我发现以下工作:
$ printf 'hi\n' | sudo tee /dev/sdb
hi
$ sudo head -n 1 /dev/sdb
hi
$
整洁的。这就是我感到困惑的地方。我再次尝试了cat
(第一个命令是相同的,我用 . 替换了第二个命令sudo cat /dev/sdb
。它打印hi
了 ,后跟一个换行符,然后挂起。做Ctrl+C并不能阻止它。真糟糕。
我推断也许最后cat
需要一个 null ( \0
) 字符。所以我再次尝试(printf 'hi\n\0' | sudo tee /dev/sdb
),并head
像以前一样工作,但cat
仍然挂起。cat
直接写入 USB 驱动器时如何才能不挂起?我不是在问这是否是个好主意(不是)。我很清楚我可以格式化驱动器并使用文本文件,但我很好奇为什么这没有按预期工作。
我正在使用带有 2 GB 闪存驱动器 ( /dev/sdb
) 的 Debian 11。
重新启动时,插入 USB 记忆棒后,TPM 将不允许无密码启动服务器。使用插入的 USB HDD 可以无密码启动服务器。
我们的服务器运行 Centos 8.3,Linux 内核版本为 4.18.0-240。TPM2 模块与 LVM 组的 LUKS 版本 1 加密一起使用,该 LVM 组由多个分区组成,包括 / /home 交换等。LUKS 标头插槽 0 用于密码,插槽 1 用于 TPM。
LUKS 标头插槽 1 绑定到 PCR 值 0、1、2 和 3。因此 BIOS (0)、BIOS 配置 (1)、Options ROM (2) 和 Options ROM 配置 (3)。
从我读到的选项 ROM 包含在 POST 启动过程中加载的固件。如果在签署 TPM 时系统状态发生任何更改,TPM 将不允许系统在没有密码的情况下启动。由于 U 盘的固件可能会在启动过程中加载,我最初认为只绑定到 PCR 值 0 和 1,即没有选项 ROM,可以解决问题。这没有用。
任何关于为什么它不能从带有 USB 记忆棒的 TPM 引导的建议将不胜感激。
当我启动我的 Linux 并开始写入 USB 支持的块设备时,前几次一切正常。
之后,如果我再次写信,dd
报告的传输速率非常高(2.9 GB/s,这是不可能的),而且看起来很成功。但是当我将它插入任何其他计算机时,我可以清楚地看到它保存着旧数据。然而,即使重新插入(选中xxd
),我的 Linux 也会报告新数据!这应该意味着它将数据保存在缓存中,而不是刷新它。只有在重新启动时,它才最终再次起作用。
我尝试了许多不同的事情:运行、sync
传递、、、conv=sync
写入3 、很好地关闭 USB 、等待 30 秒、尝试用 写入零等,但它们最终都没有做任何事情。conv=fdatasync
oflag=direct
/proc/sys/vm/drop_caches
udisksctl
cat
我什至将我的 Linux 系统切换到其他系统(我几乎从不这样做),因为之前的系统无论如何都是一团糟,但是,不出所料,Linux 是一团糟。这是一个全新的 1 天旧 Debian 11。
有任何想法吗?
我有一个自系统崩溃以来受到写保护的 USB 闪存驱动器。在dmesg中,设备写保护先关闭,再开启。
这是dmesg:
sd 2:0:0:0: [sdb] 60566016 512-byte logical blocks: (31.0 GB/28.9 GiB)
sd 2:0:0:0: [sdb] Write Protect is off
sd 2:0:0:0: [sdb] Mode Sense: 2b 00 00 08
sd 2:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
sdb: sdb1 sdb2 sdb3 sdb4
sd 2:0:0:0: [sdb] Write Protect is on
sd 2:0:0:0: [sdb] Mode Sense: 2b 00 80 08
sd 2:0:0:0: [sdb] Attached SCSI removable disk
EXT4-fs (sdb3): INFO: recovery required on readonly filesystem
EXT4-fs (sdb3): write access unavailable, cannot proceed (try mounting with noload)
/dev/sdb4: Can't open blockdev
这是命令的结果hdparm /dev/sdb
:
/dev/sdb:
multcount = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
geometry = 29573/64/32, sectors = 60566016, start = 0
我也在badblocks
/deb/sdb 上运行过,它没有发现坏块。
我尝试了该命令hdparm -r0 /dev/sdb
,但没有成功。hdparm 安全命令不再成功,例如:
hdparm --security-mode m --user-master m --security-unlock p /dev/sdb
这个命令说:
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
hdparm -I /dev/sdb
给出以下结果:
/dev/sdb:
ATA device, with non-removable media
Standards:
Likely used: 1
Configuration:
Logical max current
cylinders 0 0
heads 0 0
sectors/track 0 0
--
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 0 MBytes
device size with M = 1000*1000: 0 MBytes
cache/buffer size = unknown
Capabilities:
IORDY not likely
Cannot perform double-word IO
R/W multiple sector transfer: not supported
DMA: not supported
PIO: pio0
有没有办法关闭写保护,或者我的 USB 闪存驱动器肯定丢失了?
我有一个 2GB 的 USB,我想在上面制作 MS-DOS 的东西,所以我需要在 FAT12 上转换它。我绝对不知道该怎么做,因为 FAT12 是一个非常古老的文件系统。感谢您阅读我的帖子!
PS:我为什么要在 UNIX 论坛上发帖?因为我没有看到“文件系统”堆栈交换站点,而且我的计算机上只有 Mac OS 11 和 Debian 11(没有 Windows)。
Linux 如何确定 USB 驱动器上的分区号 (/dev/sdX**#**)?
有一个品牌的 USB 驱动器在插入 Linux 时不使用分区号安装。例如,它们显示为/dev/sdb而不是/dev/sdb1。驱动器已格式化,我可以手动挂载并写入 /dev/sdb。问题是自动挂载不起作用。我的 udev 规则用来KERNEL=="sd[a-z]*[0-9]*", SUBSYSTEMS=="usb", ACTION=="add",RUN...
触发我的挂载规则,它永远不会触发(我确实只用 sd[az]* 单独尝试过)。
当我运行 blkid 时,它缺少 ID_PART 参数。
$ sudo blkid -o udev -p /dev/sdb
ID_FS_UUID=EED9-8A61
ID_FS_UUID_ENC=EED9-8A61
ID_FS_VERSION=FAT32
ID_FS_TYPE=vfat
ID_FS_USAGE=filesystem
我见过的所有其他 USB 驱动器都是这样的:
ID_FS_UUID=932A-E6F0
ID_FS_UUID_ENC=932A-E6F0
ID_FS_VERSION=FAT32
ID_FS_TYPE=vfat
ID_FS_USAGE=filesystem
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_TYPE=0xc
ID_PART_ENTRY_NUMBER=1
ID_PART_ENTRY_OFFSET=32
ID_PART_ENTRY_SIZE=30031840
ID_PART_ENTRY_DISK=8:16
什么设置 ID_PART 值?它是关于 USB 本身的信息还是由驱动程序生成的?该制造商是否未遵循某些规范,或者这是格式化驱动器的可接受方式?我想知道我是否需要花时间解决这个问题,或者我是否可以告诉用户我的应用程序根本不支持该驱动器,因为它是如此罕见的边缘情况。
我目前正在运行 Ubuntu 18.04 最低... Linux 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux,但我在所有系统上都看到了这个回到 Ubuntu 14 的方法。
这是我测试用于此驱动器的规则时的输出。它最后运行的东西(unshare & hdparm)不是我的规则的一部分。
$ sudo udevadm test $(sudo udevadm info -q path -n /dev/sdb)
calling: test
version 237
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
Load module index
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
Reading rules file: /lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /lib/udev/rules.d/40-vm-hotadd.rules
Reading rules file: /lib/udev/rules.d/50-apport.rules
Reading rules file: /lib/udev/rules.d/50-firmware.rules
Reading rules file: /lib/udev/rules.d/50-udev-default.rules
Reading rules file: /lib/udev/rules.d/55-dm.rules
Reading rules file: /lib/udev/rules.d/55-ippusbxd.rules
Reading rules file: /lib/udev/rules.d/60-block.rules
Reading rules file: /lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /lib/udev/rules.d/60-crda.rules
Reading rules file: /lib/udev/rules.d/60-drm.rules
Reading rules file: /lib/udev/rules.d/60-evdev.rules
Reading rules file: /lib/udev/rules.d/60-gnupg2.rules
Reading rules file: /lib/udev/rules.d/60-input-id.rules
Reading rules file: /lib/udev/rules.d/60-libgphoto2-6.rules
Reading rules file: /lib/udev/rules.d/60-libsane1.rules
Reading rules file: /lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /lib/udev/rules.d/60-sensor.rules
Reading rules file: /lib/udev/rules.d/60-serial.rules
Reading rules file: /lib/udev/rules.d/61-gnome-settings-daemon-rfkill.rules
Reading rules file: /lib/udev/rules.d/61-persistent-storage-android.rules
Reading rules file: /lib/udev/rules.d/64-btrfs.rules
Reading rules file: /lib/udev/rules.d/64-xorg-xkb.rules
Reading rules file: /lib/udev/rules.d/65-libwacom.rules
Reading rules file: /lib/udev/rules.d/66-snapd-autoimport.rules
Reading rules file: /lib/udev/rules.d/69-cd-sensors.rules
Reading rules file: /lib/udev/rules.d/69-libmtp.rules
Reading rules file: /lib/udev/rules.d/69-wacom.rules
Reading rules file: /lib/udev/rules.d/70-joystick.rules
Reading rules file: /lib/udev/rules.d/70-mouse.rules
Reading rules file: /lib/udev/rules.d/70-power-switch.rules
Reading rules file: /lib/udev/rules.d/70-printers.rules
Reading rules file: /lib/udev/rules.d/70-touchpad.rules
Reading rules file: /lib/udev/rules.d/70-uaccess.rules
Reading rules file: /lib/udev/rules.d/71-power-switch-proliant.rules
Reading rules file: /lib/udev/rules.d/71-seat.rules
Reading rules file: /lib/udev/rules.d/73-seat-late.rules
Reading rules file: /lib/udev/rules.d/73-special-net-names.rules
Reading rules file: /lib/udev/rules.d/73-usb-net-by-mac.rules
Reading rules file: /lib/udev/rules.d/75-net-description.rules
Reading rules file: /lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib/udev/rules.d/77-mm-cinterion-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-dell-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-ericsson-mbm.rules
Reading rules file: /lib/udev/rules.d/77-mm-fibocom-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-haier-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-huawei-net-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-longcheer-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-mtk-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-nokia-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
Reading rules file: /lib/udev/rules.d/77-mm-qdl-device-blacklist.rules
Reading rules file: /lib/udev/rules.d/77-mm-sierra.rules
Reading rules file: /lib/udev/rules.d/77-mm-simtech-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-telit-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-ublox-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-usb-device-blacklist.rules
Reading rules file: /lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
Reading rules file: /lib/udev/rules.d/77-mm-x22x-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-zte-port-types.rules
Reading rules file: /lib/udev/rules.d/78-graphics-card.rules
Reading rules file: /lib/udev/rules.d/78-sound-card.rules
Reading rules file: /lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /lib/udev/rules.d/80-drivers.rules
Reading rules file: /lib/udev/rules.d/80-iio-sensor-proxy.rules
Reading rules file: /lib/udev/rules.d/80-libinput-device-groups.rules
Reading rules file: /lib/udev/rules.d/80-mm-candidate.rules
Reading rules file: /lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /lib/udev/rules.d/80-udisks2.rules
Reading rules file: /lib/udev/rules.d/84-nm-drivers.rules
Reading rules file: /lib/udev/rules.d/85-hdparm.rules
Reading rules file: /lib/udev/rules.d/85-nm-unmanaged.rules
Reading rules file: /lib/udev/rules.d/85-regulatory.rules
Reading rules file: /lib/udev/rules.d/90-console-setup.rules
Reading rules file: /lib/udev/rules.d/90-libinput-model-quirks.rules
Reading rules file: /lib/udev/rules.d/90-pulseaudio.rules
Reading rules file: /lib/udev/rules.d/95-cd-devices.rules
Reading rules file: /lib/udev/rules.d/95-dm-notify.rules
Reading rules file: /lib/udev/rules.d/95-upower-csr.rules
Reading rules file: /lib/udev/rules.d/95-upower-hid.rules
Reading rules file: /lib/udev/rules.d/95-upower-wup.rules
Reading rules file: /lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /etc/udev/rules.d/99-automount-usb.rules
Reading rules file: /lib/udev/rules.d/99-systemd.rules
rules contain 393216 bytes tokens (32768 * 12 bytes), 32795 bytes strings
24061 strings (201804 bytes), 21012 de-duplicated (172059 bytes), 3050 trie nodes used
GROUP 6 /lib/udev/rules.d/50-udev-default.rules:56
IMPORT builtin 'usb_id' /lib/udev/rules.d/60-persistent-storage.rules:47
/sys/devices/pci0000:00/0000:00:15.0/usb1/1-4/1-4:1.0: if_class 8 protocol 6
LINK 'disk/by-id/usb-General_UDisk-0:0' /lib/udev/rules.d/60-persistent-storage.rules:52
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-storage.rules:73
LINK 'disk/by-path/pci-0000:00:15.0-usb-0:4:1.0-scsi-0:0:0:0' /lib/udev/rules.d/60-persistent-storage.rules:75
IMPORT builtin 'blkid' /lib/udev/rules.d/60-persistent-storage.rules:90
probe /dev/sdb raid offset=0
LINK 'disk/by-uuid/EED9-8A61' /lib/udev/rules.d/60-persistent-storage.rules:93
RUN '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/%k' /lib/udev/rules.d/66-snapd-autoimport.rules:3
RUN '/lib/udev/hdparm' /lib/udev/rules.d/85-hdparm.rules:1
handling device node '/dev/sdb', devnum=b8:16, mode=0660, uid=0, gid=6
preserve permissions /dev/sdb, 060660, uid=0, gid=6
preserve already existing symlink '/dev/block/8:16' to '../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fusb-General_UDisk-0:0'
creating link '/dev/disk/by-id/usb-General_UDisk-0:0' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-id/usb-General_UDisk-0:0' to '../../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:00:15.0-usb-0:4:1.0-scsi-0:0:0:0'
creating link '/dev/disk/by-path/pci-0000:00:15.0-usb-0:4:1.0-scsi-0:0:0:0' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-path/pci-0000:00:15.0-usb-0:4:1.0-scsi-0:0:0:0' to '../../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-uuid\x2fEED9-8A61'
creating link '/dev/disk/by-uuid/EED9-8A61' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-uuid/EED9-8A61' to '../../sdb'
ACTION=add
DEVLINKS=/dev/disk/by-uuid/EED9-8A61 /dev/disk/by-id/usb-General_UDisk-0:0 /dev/disk/by-path/pci-0000:00:15.0-usb-0:4:1.0-scsi-0:0:0:0
DEVNAME=/dev/sdb
DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-4/1-4:1.0/host2/target2:0:0/2:0:0:0/block/sdb
DEVTYPE=disk
ID_BUS=usb
ID_FS_TYPE=vfat
ID_FS_USAGE=filesystem
ID_FS_UUID=EED9-8A61
ID_FS_UUID_ENC=EED9-8A61
ID_FS_VERSION=FAT32
ID_INSTANCE=0:0
ID_MODEL=UDisk
ID_MODEL_ENC=UDisk\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_MODEL_ID=1234
ID_PATH=pci-0000:00:15.0-usb-0:4:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_00_15_0-usb-0_4_1_0-scsi-0_0_0_0
ID_REVISION=5.00
ID_SERIAL=General_UDisk-0:0
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=General
ID_VENDOR_ENC=General\x20
ID_VENDOR_ID=abcd
MAJOR=8
MINOR=16
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=1863301153
run: '/usr/bin/unshare -m /usr/bin/snap auto-import --mount=/dev/sdb'
run: '/lib/udev/hdparm'
Unload module index
Unloaded link configuration context.
`
我的系统盘是一个外部 USB 设备,这里没有显示(它是一个 240GB 的 San 盘)。
➤ lsusb
Bus 004 Device 005: ID 05ac:8242 Apple, Inc. Built-in IR Receiver
Bus 004 Device 008: ID 05ac:828a Apple, Inc.
Bus 004 Device 004: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Blueto
Bus 004 Device 003: ID 0424:2512 Standard Microsystems Corp. USB 2.0 Hub
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 004: ID 174c:5106 ASMedia Technology Inc. ASM1051 SATA 3Gb/s bridge
Bus 002 Device 003: ID 04f2:0408 Chicony Electronics Co., Ltd USB Keyboard
Bus 002 Device 002: ID 4e53:5407 USB OPTICAL MOUSE
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 004: ID 08bb:2912 Texas Instruments PCM2912A Audio Codec
Bus 005 Device 006: ID 256c:006e
Bus 005 Device 005: ID 046d:09a6 Logitech, Inc. QuickCam Vision Pro
Bus 005 Device 003: ID 0424:2504 Standard Microsystems Corp.
Bus 005 Device 002: ID 04e8:5f06 Samsung Electronics Co., Ltd Samsung STORY Station
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
也许这是一个空行?但是,我感兴趣的是,它是否作为 USB-3 磁盘访问。我怎么能测试呢?
如果闪存驱动器上的文件系统损坏,并且我将文件传输到计算机或另一个 USB,那么以后这些文件出现问题的可能性有多大?像损坏的文件...