So I recently have received a 256GB SD Card on eBay for pretty cheap, but turns out that the factory part number printed on the back plastic was listed as an 8GB card.
It was modified from the seller to appear to hold 256GB and not its actual size.
I found out that there is a software in Linux called 'mkdosfs' (that also has a Windows compiled version, which is the one I am using, but essentially the same).
I applied the default script to the SD Card but that actually reduced the size read to 4GB.
I further investigated to find that actually while running there is an error, that appears for half a second before closing, I managed to grab a screenshot of this error:
This is the script I am using to run mkdosfs on Windows (where H: is the drive letter of the SD card)
mkdosfs -n "8GB" -v H: 8386900Can anyone tell me how to change the script to output an 8GB disk as the result (I am pretty sure it is something to do with the last number)
Thanks, your help is greatly appreciated.
11 Answer
If you bought a drive advertised to be able to hold 256 GB but that can only hold up 8 GB, you should return it and get a refund from the seller because they didn't sell the promised product. If the seller and/or manufacturer were willing to defraud you based on the size of the drive, who knows what other defects or dormant faults the drive has. I wouldn't trust it with anything even in the first 8 GB.
For a technical solution, instead of fumbling around with file system tools you should instead repartition the drive so that it's partition(s) only cover(s) the first 8 GB (or whatever size is working), then format the resulting partition(s) with whatever file system(s) you like. The respective file system tools will create file systems that span the entire target partition by default.
You can use your favourite partition manager (e. g. Gnome Disks, KDE Partition Manager, GParted) to repartition the drive. I'll give you two command-line based examples below because they're easy to reproduce. Let's assume that the drive in question has the kernel name /dev/sdz.
Using fdisk
Start
fdiskand point it to the drive:sudo fdisk /dev/sdzReplace the partition table with a new one (menu option
o).Create a new partition (
n),- make it a primary partition (
p), - make it the first partition (
1), - choose the first sector at the suggested offset of 1 MiB (
2048or no entry), - choose the desired size of 8 GiB (= 8192 MiB) minus the 1 MiB from above (
+8191M),
- make it a primary partition (
(optionally) print the resulting partition table to verify you did as intended (
p),(optionally) set the partition type to "W95 FAT32 (LBA)"1 (
t, thenc)write the new partition table to the device (
w),ask the Linux kernel to reread the partition table:
sudo partprobe /dev/sdz
Using sfdisk
If you don't want to go through a bunch of menus you can also use sfdisk to specify a partition table (set size_gb to the desired size in GiB):
size_gb=8
sudo sfdisk /dev/sdz <<EOF
unit: sectors
: start=2048, size=$((($size_gb << 21) - (1 << 11))), Id=c
EOFLike with fdisk you need to ask the kernel to reread the partition table:
sudo partprobe /dev/sdz1 The default partition type for new partitions created with fdisk is "Linux" but both types should be fine. All major operating systems (Linux, Windows and OS X) will recognise the partition content correctly with either partition type. There are some corner cases with third-party tools that choose to expect a particular partition type for whatever reason.