我有一个想要格式化的 USB 密钥,但是无法进行:
- 在命令行中格式化:
结果:
$ sudo mkfs.ext2 /dev/sdb
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
mkfs.ext2: Permission denied while trying to determine filesystem size
$ sudo mkfs.ext2 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Could not stat /dev/sdb1 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
- 创建分区:
结果:
$ sudo fdisk /dev/sdb
fdisk: unable to open /dev/sdb: No medium found
在 GParted 或 USB Stick Formatter 中查看
查看分区
ls -l /dev/sd*
结果:
$ ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 Jan 4 14:43 /dev/sda
brw-rw---- 1 root disk 8, 1 Jan 4 12:07 /dev/sda1
brw-rw---- 1 root disk 8, 2 Jan 4 14:43 /dev/sda2
brw-rw---- 1 root disk 8, 5 Jan 4 11:22 /dev/sda5
brw-rw---- 1 root disk 8, 16 Jan 4 12:30 /dev/sdb
- 读它
结果:
$ sudo dd if=/dev/sdb of=/tmp/xxx bs=512 count=1
dd: failed to open ‘/dev/sdb’: No medium found
$ sudo dmesg | tail
[22002.140008] usb 2-1.4: new high-speed USB device number 12 using ehci-pci
[22002.238743] usb 2-1.4: New USB device found, idVendor=090c, idProduct=3000
[22002.238748] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[22002.238750] usb 2-1.4: Product: SM3252A MEMORY BAR
[22002.238752] usb 2-1.4: Manufacturer: Silicon Motion,Inc.
[22002.239190] usb-storage 2-1.4:1.0: USB Mass Storage device detected
[22002.239430] scsi37 : usb-storage 2-1.4:1.0
[22003.238585] scsi 37:0:0:0: Direct-Access USB MEMORY BAR 1000 PQ: 0 ANSI: 0 CCS
[22003.241074] sd 37:0:0:0: Attached scsi generic sg2 type 0
[22003.246714] sd 37:0:0:0: [sdb] Attached SCSI removable disk
- 使用以下方法查找
fdisk
:
结果:
$ sudo fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x2aa8f047
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 362375167 181186560 7 HPFS/NTFS/exFAT
/dev/sda2 362378205 823732874 230677335 f W95 Ext'd (LBA)
Partition 2 does not start on physical sector boundary.
/dev/sda5 362378268 823732874 230677303+ 7 HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
fdisk -l /dev/sdb
$ sudo fdisk -l /dev/sdb
Cannot open /dev/sdb
- 看看
sudo cat /proc/partitions
结果 :
$ sudo cat /proc/partitions
major minor #blocks name
7 0 1548652 loop0
8 0 488386584 sda
8 1 181186560 sda1
8 2 1 sda2
8 5 230677303 sda5
11 0 1593088 sr0
- 查找任何错误
dmesg | tail
:
结果:
$ sudo dmesg | tail
[ 5519.189351] usb 2-1.4: new high-speed USB device number 10 using ehci-pci
[ 5519.288491] usb 2-1.4: New USB device found, idVendor=090c, idProduct=3000
[ 5519.288498] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5519.288502] usb 2-1.4: Product: SM3252A MEMORY BAR
[ 5519.288505] usb 2-1.4: Manufacturer: Silicon Motion,Inc.
[ 5519.289008] usb-storage 2-1.4:1.0: USB Mass Storage device detected
[ 5519.289150] scsi35 : usb-storage 2-1.4:1.0
[ 5520.292225] scsi 35:0:0:0: Direct-Access USB MEMORY BAR 1000 PQ: 0 ANSI: 0 CCS
[ 5520.292771] sd 35:0:0:0: Attached scsi generic sg2 type 0
[ 5520.294124] sd 35:0:0:0: [sdb] Attached SCSI removable disk
但我看到了有关它的所有正确信息(制造商,......)。
有什么建议么?
答案1
对于 fdisk 和 mkfs,您需要使用sudo
。另外,如果您需要格式化,则首先需要创建分区。为此,无法安装该棒。
- 对于你来说,使用 GUI 可能是最简单的:
gksudo gparted
命令行
为你的棒子找到 /dev/sdX
sudo fdisk -l
清空棍子
sudo dd if=/dev/zero of=/dev/sdX bs=4k && sync
创建主分区
sudo fdisk /dev/sdX
然后按 n - primary - w
格式化分区
sudo mkfs.vfat /dev/sdX1
答案2
首先,您可能应该以 root 身份运行命令,因为这可能是问题的一部分。(看到您的权限被拒绝错误了吗?)
我注意到
/dev/sdb is entire device, not just one partition!
这意味着您的设备已被检测到,但它没有逻辑分区。
fdisk 只显示分区。你应该使用 parted
root@hostname~# parted
(parted) print all
这将显示所有存储设备,而不仅仅是带有分区的设备。
要在设备上创建分区,您可以使用 gparted,如果没有桌面环境,也可以在命令行中使用 parted。
确保您的设备已卸载
root@hostname~# umount /dev/sdb
开始分开
root@hostname~# parted
列出设备
(parted) print all
选择您的设备
(parted) select /dev/sdb
创建新分区
(parted) mkpart
它会出现并询问不同的内容。为了确保与所有系统(而不仅仅是 Linux)兼容,我建议将分区类型设置为 fat32 而不是 ext。
创建新分区后,即可退出 parting
(parted) q
然后你就可以挂载你的新分区
root@hostname~# mount /dev/sdb1 /mnt/
希望这可以帮助!