Restore the size of USB drive in Linux
1 min readMar 16, 2020
- Run lsblk command to find outUSB partition. In this case you see the USB flash drive is sdb so you VERY CAREFULLY run:
#sudo dd if=/dev/zero of=/dev/sdb count=100
- Create a new partition table in the format you like:
#dd if=/dev/zero of=/dev/sdb bs=32k count=1
- Create mounting point:
#sudo mkdir /media/external - Mount the Drive: We can now mount the drive. Let’s say the device is /dev/sdb1, the filesystem is FAT16 or FAT32 (like it is for most USB flash drives), and we want to mount it at /media/external (having already created the mount point):
#sudo mount -t vfat /dev/sdb /media/external -o uid=1000,gid=1000,utf8,dmask=027,fmask=137 - OR
- If the device is formatted with NTFS, run:
#sudo mount -t ntfs-3g /dev/sdb1 /media/external
Note: You must have the ntfs-3g driver installed - Unmounting the Drive:
#sudo umount /dev/sdb - ENJOY