如何格式化USB stick?遇"No space left on device"报错,按教程操作仍失败
Hey there, sorry to hear you're hitting this frustrating error even after following the formatting tutorial to a T. Let's break down the most likely fixes, step by step:
1. Double-check you're targeting the right device (critical!)
First, make sure you're not accidentally messing with your system drive. Run these commands to list connected storage devices:
lsblk # Or df -h
Look for your USB stick (it'll usually show up as /dev/sdb, /dev/sdc, etc.—never pick /dev/sda unless you're 100% sure that's your USB). Note the partition name too (like /dev/sdb1).
2. Unmount the USB first (it can't format if it's in use)
If the USB is mounted, formatting will fail. Unmount it with:
sudo umount /dev/sdX1
Replace sdX1 with your actual partition. If you get a "target is busy" error, close any file explorer windows open to the USB, then run:
sudo fuser -km /dev/sdX1
This forces all processes using the drive to close, then try unmounting again.
3. Wipe hidden/residual data that might be hogging space
Sometimes hidden system files, recycle bin data, or leftover partitions take up space without you seeing them. After mounting the USB again, run:
ls -la /mnt/your-usb-mount-point
Look for files starting with . (hidden) or directories like $RECYCLE.BIN (Windows) or .Trash-1000 (Linux). Delete them with:
sudo rm -rf /mnt/your-usb-mount-point/.* /mnt/your-usb-mount-point/$RECYCLE.BIN
Then unmount and try formatting again.
4. Format directly with mkfs (bypass any GUI issues)
If you were using a GUI tool, try the command line instead—it's often more reliable. For a FAT32 format (compatible with most devices):
sudo mkfs.vfat -F 32 /dev/sdX1
For a Linux-only Ext4 format:
sudo mkfs.ext4 /dev/sdX1
Wait for the process to finish—don't interrupt it!
5. Check for bad blocks or a fake (扩容) USB drive
If none of the above works, your USB might have bad sectors or be a fake "扩容" drive (where the advertised capacity is larger than the actual usable space).
- To check for bad blocks:
If bad blocks are found, you can mark them during formatting with:sudo badblocks -v /dev/sdXsudo mkfs.vfat -c /dev/sdX1 - To verify actual capacity:
Runsudo fdisk -l /dev/sdXand compare the "Disk /dev/sdX: X GiB" value to the advertised capacity. If there's a huge mismatch, it's a fake drive—you'll need to partition it to its real usable size.
6. Last resort: Rewrite the partition table
If the partition table is corrupted, wipe it and start fresh:
sudo dd if=/dev/zero of=/dev/sdX bs=512 count=1
This erases the partition table. Then use fdisk or gparted to create a new partition, then format it.
内容的提问来源于stack exchange,提问作者roy

