Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Format a USB thumb drive

  1. #1
    Join Date
    Jun 2008
    Location
    USA
    Posts
    1,423

    Default Format a USB thumb drive

    This should be easy but I can't get it to work. I have a 2 GB usb drive with Linux Mint on it. I want to recover the drive for storing files. I first tried deleting files, just to make room. That didn't work, even using shift+delete. Next I tried to format the drive via yast but that didn't work. I don't have the error copied to show, but I next tried to format via the terminal. That failed too. Here is the output:
    Code:
    DESKTOP-3006QM4:/home/prexy # umount /dev/sdc1
    DESKTOP-3006QM4:/home/prexy # mkfs.vfat /dev/sdc1
    mkfs.fat 4.2 (2021-01-31)
    mkfs.vfat: unable to synchronize /dev/sdc1:Input/output error
    
    
    Checking properties, this is listed as a read-only file system. I tried, via a dialog box, to change the properties to include write. I get no error message but I still cannot delete any files. I have not tried gparted because it is not installed and if yast and the cli didn't work, I don't think gparted will either.
    Any sufficiently advanced technology is indistinguishable from magic. - Arthur C. Clarke

  2. #2
    Join Date
    Sep 2013
    Location
    Norfolk, UK
    Posts
    1,888

    Default Re: Format a USB thumb drive

    use "dd" to clear the start of the usb stick - ensure you have the correct device as sd(X)

    Code:
    dd if=/dev/zero of=/dev/sd(X) bs=1024 count=1024
    Then partition/format the stick as you want it.
    Regards, Paul

  3. #3
    Join Date
    Jun 2008
    Location
    USA
    Posts
    1,423

    Default Re: Format a USB thumb drive

    Quote Originally Posted by tannington View Post
    use "dd" to clear the start of the usb stick - ensure you have the correct device as sd(X)

    Code:
    dd if=/dev/zero of=/dev/sd(X) bs=1024 count=1024
    Then partition/format the stick as you want it.
    dd seemed to work but I still cannot delete files or partition the drive.
    Code:
    dd if=/dev/zero of=/dev/sdc1 bs=1024 count=1024    
    1024+0 records in
    1024+0 records out
    1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.196349 s, 5.3 MB/s
    
    
    The mkfs command gave the same error as I showed previously. I tried to partition via yast and got an error that leads me to believe the drive is just defective.I tried to format as FAT and this message box popped up.
    Code:
    command '/usr/sbin/parted --script '/dev/sdc' mklabel gpt' failed:
    
    stderr:
    Error: Input/output error during write on /dev/sdc
    
    
    exit code:
    1
    Knowing why this won't work is more important to me than the little drive itself. Could the fact that it has an iso of Mint on it be the source of the problem? In any case, thanks for trying to help.
    Any sufficiently advanced technology is indistinguishable from magic. - Arthur C. Clarke

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,142

    Default Re: Format a USB thumb drive

    What you did is not what was suggested. Suggested was (in this case I have filled in the c, because that seems to be the correct device, at least in your posts above):
    Code:
    dd if=/dev/zero of=/dev/sdc bs=1024 count=1024
    What you did was:
    Code:
    dd if=/dev/zero of=/dev/sdc1 bs=1024 count=1024
    So the suggestion was to erase over the partition table).
    What you did was erasing the begin of partition 1, which has destroyed crucial information of the file system on it (when there was one on it).

    Please try to understand the difference between a mass-storage device and the eventual partitions on them (defined in the partition table at the begin of the device).

    Also it is not clear to me while you are trying to remove files from the file system on sdc1, when you want to create a new file system there. Creating a new file system on a container destroys all that was on it before.

    I may understand you wrong, but I have the idea that what you want is:

    • forget (because you are not interested in) what is now on the device;
    • create a fresh file system (of a type to be decide upon by you) on the device, or
    • alternatively partition the device into one (or more) partitions and using at least one partition for a file system of your choice.
    Henk van Velden

  5. #5
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    31,739
    Blog Entries
    15

    Default Re: Format a USB thumb drive

    Quote Originally Posted by Prexy View Post
    dd seemed to work but I still cannot delete files or partition the drive.
    Code:
    dd if=/dev/zero of=/dev/sdc1 bs=1024 count=1024    
    1024+0 records in
    1024+0 records out
    1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.196349 s, 5.3 MB/s
    
    
    The mkfs command gave the same error as I showed previously. I tried to partition via yast and got an error that leads me to believe the drive is just defective.I tried to format as FAT and this message box popped up.
    Code:
    command '/usr/sbin/parted --script '/dev/sdc' mklabel gpt' failed:
    
    stderr:
    Error: Input/output error during write on /dev/sdc
    
    
    exit code:
    1
    Knowing why this won't work is more important to me than the little drive itself. Could the fact that it has an iso of Mint on it be the source of the problem? In any case, thanks for trying to help.
    Hi
    Blow away the partition table and start again, MAKE SURE YOU PICK THE RIGHT DISK!!!

    Code:
    wipefs -a /dev/sdc1
    wipefs -a /dev/sdc
    Use gdisk or fdisk to create a new partition.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  6. #6
    Join Date
    Jun 2008
    Location
    The English Lake District. UK - GMT/BST
    Posts
    36,857
    Blog Entries
    20

    Default Re: Format a USB thumb drive

    Tumbleweed_KDE
    My Articles Was I any help? If yes: Click the star below

  7. #7
    Join Date
    Jun 2008
    Location
    USA
    Posts
    1,423

    Default Re: Format a USB thumb drive

    I have tried, in turn, all of these suggestions. All fail with the error that sdc is a read-only file system
    Code:
    dd if=/dev/zero of=/dev/sdc bs=1024 count=1024
    dd: failed to open '/dev/sdc': Read-only file system
    
    wipefs -a /dev/sdc                             
    wipefs: error: /dev/sdc: probing initialization failed: Read-only file system
    
    fdisk /dev/sdc
    
    Welcome to fdisk (util-linux 2.36.2).                                                           
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    fdisk: cannot open /dev/sdc: Read-only file system
    
    
    I also tried yast again. I have been trying to make a FAT partition but the suggested choice is always XFS. I accepted that and got the identical error as FAT:
    Code:
    command '/sbin/mkfs.xfs -q -f  '/dev/sdc'' failed:
    
    stderr:
    mkfs.xfs: cannot open /dev/sdc: Read-only file system
    
    
    exit code:
    1
    I wonder if running it across a giant magnet would work. Once again, thanks to all.
    Any sufficiently advanced technology is indistinguishable from magic. - Arthur C. Clarke

  8. #8
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,142

    Default Re: Format a USB thumb drive

    So, let us concentrate on the first error message and try to solve that instead of doing wilder and wilder actions.

    To begin with, as is adsked many times in many threads, please copy/paste complete. Specially the line with the command. We now have the command and the output, but NOT the prompt. So we can not check WHO did those commands.

    Please show
    Code:
    ls -l /dev/sdc*
    And also
    Code:
    ls -l /dev/disk/* | grep sda*
    and
    Code:
    mount | grep ro,
    Henk van Velden

  9. #9
    Join Date
    Sep 2013
    Location
    Norfolk, UK
    Posts
    1,888

    Default Re: Format a USB thumb drive

    Additionally:

    Probably worth looking at 'dmesg' to see if any relevant output shows up when the drive is plugged in, specifically relating to 'write protect'.

    Possibly the usb stick is failing and it's internal controller has set the SWP bit.

    Also worth checking, it (the usb stick) isn't one of the very odd few that have a physical write protect switch. (I've only ever seen one of those and don't recall what brand it was).
    Regards, Paul

  10. #10
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,142

    Default Re: Format a USB thumb drive

    I agree. It is worthwhile to check if it isn't the whole stick that is read-only.
    Henk van Velden

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •