Building a file system on Flash Drive with filesystem already on...
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Building a file system on Flash Drive with filesystem already on...
I have by mistake issued "sudo mkfs.exfat -n 128.ExFAT /dev/sdc" on my 128GB
flash drive, and not noticed that I have not deleted the NTFS file system that
was there and I wanted to replace with ExFAT.
Now the flash drive can not be formatted to anything else, nor can the partition be deleted,
it shows as FAT32 on Windows 7 PC and same on Linux, I can write files to it,
but can not deleted them ...
Plus on Linux, the drive will show as FAT32, when plugged in come up with files I have managed
to write to the flash drive and then disappear see below dmesg:
[ 4513.191693] usb 3-2: new SuperSpeed USB device number 3 using xhci_hcd
[ 4513.208082] usb 3-2: New USB device found, idVendor=0781, idProduct=cffa
[ 4513.208089] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4513.208092] usb 3-2: Product: iXpand Flash Drive
[ 4513.208095] usb 3-2: Manufacturer: SanDisk
[ 4513.208097] usb 3-2: SerialNumber: SDF2F7A0A123
[ 4513.209269] usb-storage 3-2:1.0: USB Mass Storage device detected
[ 4513.209452] scsi6 : usb-storage 3-2:1.0
[ 4516.109274] scsi 6:0:0:0: Direct-Access iXpand Flash Drive PQ: 0 ANSI: 6
[ 4516.110101] sd 6:0:0:0: [sdc] 249736704 512-byte logical blocks: (127 GB/119 GiB)
[ 4516.110219] sd 6:0:0:0: Attached scsi generic sg3 type 0
[ 4516.110474] sd 6:0:0:0: [sdc] Write Protect is off
[ 4516.110481] sd 6:0:0:0: [sdc] Mode Sense: 23 00 00 00
[ 4516.110870] sd 6:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 4516.119611] sdc:
[ 4516.120755] sd 6:0:0:0: [sdc] Attached SCSI removable disk
[ 4516.288494] FAT-fs (sdc): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[ 4516.292935] FAT-fs (sdc): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 4582.005578] usb 3-2: reset SuperSpeed USB device number 3 using xhci_hcd
[ 4582.022002] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd00
[ 4582.022005] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd48
[ 4591.123779] usb 3-2: reset SuperSpeed USB device number 3 using xhci_hcd
[ 4591.140357] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd00
[ 4591.140364] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd48
[ 4595.111348] usb 3-2: reset SuperSpeed USB device number 3 using xhci_hcd
[ 4595.127867] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd00
[ 4595.127874] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd48
[ 4601.776241] usb 3-2: reset SuperSpeed USB device number 3 using xhci_hcd
[ 4601.792959] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd00
[ 4601.792968] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd48
[ 4610.115232] usb 3-2: reset SuperSpeed USB device number 3 using xhci_hcd
[ 4610.131781] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd00
[ 4610.131784] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd48
[ 4619.101512] usb 3-2: reset SuperSpeed USB device number 3 using xhci_hcd
[ 4619.117914] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd00
[ 4619.117917] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8800a4e5dd48
[ 4619.118645] sd 6:0:0:0: [sdc] Unhandled error code
[ 4619.118647] sd 6:0:0:0: [sdc]
[ 4619.118648] Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 4619.118649] sd 6:0:0:0: [sdc] CDB:
[ 4619.118650] Write(10): 2a 00 00 00 ee fe 00 00 01 00
[ 4619.118655] end_request: I/O error, dev sdc, sector 61182
[ 4619.118657] Buffer I/O error on device sdc, logical block 61182
[ 4619.118658] lost page write due to I/O error on sdc
[ 4624.151808] usb 3-2: USB disconnect, device number 3
[ 4649.480445] sd 6:0:0:0: [sdc] Unhandled error code
[ 4649.480452] sd 6:0:0:0: [sdc]
[ 4649.480455] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
[ 4649.480458] sd 6:0:0:0: [sdc] CDB:
[ 4649.480459] Write(10): 2a 00 00 00 00 01 00 00 01 00
[ 4649.480470] end_request: I/O error, dev sdc, sector 1
[ 4649.480475] Buffer I/O error on device sdc, logical block 1
[ 4649.480478] lost page write due to I/O error on sdc
[ 4649.485620] VFS: busy inodes on changed media or resized disk sdc
[ 4649.724205] usb 3-2: new SuperSpeed USB device number 4 using xhci_hcd
[ 4649.744317] usb 3-2: device descriptor read/8, error -61
[ 4649.848015] usb 3-2: new SuperSpeed USB device number 4 using xhci_hcd
[ 4649.864208] usb 3-2: device descriptor read/8, error -61
[ 4650.159736] usb 3-2: new SuperSpeed USB device number 5 using xhci_hcd
[ 4650.175934] usb 3-2: device descriptor read/8, error -61
[ 4650.279544] usb 3-2: new SuperSpeed USB device number 5 using xhci_hcd
[ 4650.295732] usb 3-2: device descriptor read/8, error -61
[ 4650.591350] usb 3-2: new SuperSpeed USB device number 6 using xhci_hcd
[ 4650.607377] usb 3-2: device descriptor read/8, error -61
[ 4650.711099] usb 3-2: new SuperSpeed USB device number 6 using xhci_hcd
[ 4650.727282] usb 3-2: device descriptor read/8, error -61
[ 4651.022804] usb 3-2: new SuperSpeed USB device number 7 using xhci_hcd
[ 4651.038902] usb 3-2: device descriptor read/8, error -61
[ 4651.142614] usb 3-2: new SuperSpeed USB device number 7 using xhci_hcd
[ 4651.158794] usb 3-2: device descriptor read/8, error -61
[ 4651.286439] usb usb3-port2: unable to enumerate USB device
Any attempt to create any partitions on the flash drive ends up
loots of error messages in dmesg:
$ sudo fsck -vcck /dev/sdb
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdb
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=2
2+0 records in
2+0 records out
2097152 bytes (2.1 MB) copied, 0.0091418 s, 229 MB/s
$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
@rtmistler: Sorry my bad, I have used the partition number it was then sdc1 .., I have managed to remove all the partitions from the drive using fdisk,
but can not create new partition .... is says Linux partition even if I select DOS partition ...
And then it will show "unknown" partition type in gnome-disk-utility
Checking now with fdisk and listing partitions I get this:
$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xd0fabe93.
Command (m for help): p
Disk /dev/sdb: 119.1 GiB, 127865192448 bytes, 249736704 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd0fabe93
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-249736703, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-249736703, default 249736703):
Created a new partition 1 of type 'Linux' and of size 119.1 GiB.
Command (m for help): p
Disk /dev/sdb: 119.1 GiB, 127865192448 bytes, 249736704 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd0fabe93
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 249736703 249734656 119.1G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
/dev/sdb: close device failed: Input/output error
When a flash drive fails, it tends to fail to READ_ONLY. I have several SDHC cards in this state atm. They have the contents they have, you cannot delete anything. It's not a user error, driver error, or anything other than failed hardware. You can try to start over with the device. Backup first if you care about the contents.
If the cmp doesn't fail at end of device, your writes didn't take. A good sign that the drive is done for. I've had a SDHC card fail with < 4 hours of usage. Just enough time to install a distro and watch about 2 hours of youtube, before... what's going on here???
Many flash drives cannot be partitioned. They come with a single pseudo partition on them and any attempt at re-partitioning will fail and may ruin the drive.
The FORMAT of the file system does not require ANY re-partitioning. The two are seperate beasts and should not be confused.
Distribution: Mainly Devuan with some Tiny Core, Fatdog, Haiku, & BSD thrown in.
Posts: 5,279
Rep:
Quote:
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xd0fabe93.
You need to do as it says, before you can create any partitions on it!
(The command to do it is 'o'.)
Quote:
Command (m for help): m
Command action
a toggle bootable flag
b edit bsd disklabel
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Many flash drives cannot be partitioned. They come with a single pseudo partition on them and any attempt at re-partitioning will fail and may ruin the drive.
i have never heard of anything like it.
i went through my share of usb drives, and every single one of them could be reformatted to fat32, after e.g. having been used for a live system.
That is probably because formatting is a different thing to partitioning. I didn't say they couldn't be formatted I said that many come with a single "partition" and cannot be partitioned with more.
You can FORMAT that single "partition" to whatever file system you want.
Last edited by dave@burn-it.co.uk; 05-18-2017 at 02:58 PM.
Many flash drives cannot be partitioned. They come with a single pseudo partition on them and any attempt at re-partitioning will fail and may ruin the drive.
The FORMAT of the file system does not require ANY re-partitioning. The two are seperate beasts and should not be confused.
Is there any "way" to spot those flash drives with "pseudo partition"?
Can you name any flash drives?
Well, I have first try to delete all partitions, then create 1, and then create file system, but on that drive it just looks it's not possible.
Is there any "way" to spot those flash drives with "pseudo partition"?
Not without actually trying it.
Quote:
Can you name any flash drives?
It is often model dependant within a make.
I'm not trying to avoid being specific, it is just that it really is hit and miss.
I have even seen different size drives in the same model range behave differently, as well as different releases of the same drive.
I have a sandisk U3 stick (2GB) from long ago that gets "fresh" contents. But only if you plug it into a windows machine. You can delete that thing a million times, but plug it into a windows box and it magically shows up for your convenience. But that device was from over a decade ago and no device I've gotten since then does that. Except maybe the eMMC on my hp stream 11 with it's odd /dev/mmcblk0boot0 and /dev/mmcblk0boot1 that persist even if I $(dd if=/dev/zero of=/dev/mmcblk0) a million times. Otherwise all my usb sticks and SDHC cards (that still work) take the /dev/zero backhand like they should.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.