How to create a new partitioning table on SD card from the command line ?
Solution 1
If you want to possibly * remove everything then you can do your dd
command; however, you'll still need to create a partition table.
NOTE I'm going to use /dev/sdb because that is what you have in your original question
I recommend fdisk
. So you would do something like the following:
# fdisk /dev/sdb
Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): 1
First sector (starting-ending, default starting): starting
Last sector, +sectors or +size{K,M,G} (starting-ending, default ending): ending
Command (m for help): w
You will then need to format the partition using mkfs
. If you're only going to use your SD Card in a linux box then use ext3 or ext4:
# mkfs.ext3 /dev/sdb1
Otherwise, you're probably safer off with ntfs (check with what you're going to insert the card into):
# mkfs.ntfs /dev/sdb1
Once that's done, you can then mount it:
# mount -t ext3 /dev/sdb1 /mnt
When you're finished, make sure you unmount it:
# umount /mnt
*All of the data will still be there, but for most end users this means it's as good as gone without a partition table.
Solution 2
"fdisk" and "parted" are command line commands to deal with disk partition tables. You may try with them.
Related videos on Youtube
Abdul Al Hazred
Updated on September 18, 2022Comments
-
Abdul Al Hazred over 1 year
I have tried to mount a SD card on Linux Mint, I have found the right device file and tried: mount -t vfat /dev/sdb /mnt/zauberportal ,but it failed and I tried some variations like different types of file systems after the -t option.
Now, I read, that it is quiet possible that it is because of a badly written partition table, the suggestion was to erase the whole partition table by filling the first 512 bytes of the SD card with zeros: dd if=/dev/zero of=/dev/sdb bs=512 count=1, than I should create a partitioning table using a program called gparted, but it did not work.
Is it possible to create a new partitioning table from the command line ?
-
jasonwryan about 9 years"It failed" and "it did not work" provide no useful information. Please read How To Ask Questions The Smart Way...
-
Anthon about 9 yearsWhere did you get "the suggestion" from? Did that include making a backup of the SD? Any reason why to use
gparted
(I only use that for my drives > 2TB)
-
-
Eric Sebasta over 3 yearsthis answer, while correct back in the day, is very outdated now... since all kernels give sd cards the device path /dev/mmcblk0 for the first one, and 1...etc...etc... if you have multiple readers and cards inserted. further the partitions are numbered, so partition one on your first memory card is: /dev/mmcblk0p1 /dev/mmcblk0p2 #if you have a second etc, etc. This may help people.