Creating partition table - do I need to format afterwards?
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
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.
Creating partition table - do I need to format afterwards?
After creating a prartition (83) in fdisk, is it always necessary to run the mkfs.ext3 command to format the drive (I guess this is formatting). I seem to remember deleting the partition tables and creating new ones and not always having to run the mkfs command. The reason I ask is I'm having 2 issues.
I have a 2TB drive that seemed to work find in ubuntu 12.04 but now I can't mount it as it says the superblock or partition table might be bad, the drive reads to be bigger than it actually is (by a small bit, maybe a couple megs). I NEED to get this data back so I figured I'd DD it to a RAID array before messing with the partition table.
Also, I wanted to see if I could delete the MBR/partition table of a USB drive and then recover it. It was formatted in FAT32 or NTFS, I think FAT32. I did the following:
Backup
# dd if=/dev/sdb of=/home/backup-sdb.mbr bs=512 count=1
Delete
# dd if=/dev/zero of=/dev/sdb bs=512 count=1
Restore
I had these two options:
# dd if=/home/backup-sdb.mbr of=/dev/sdb
# dd if=/home/backup-sdb.mbr of=/dev/sdb bs=1 count=64 skip=446 seek=446
After I deleted the partition tables, I fdisk'd and created a ext3 partition, wrote to disk, mounted the drive and the files were all there that were there prior to deleting the partition table. Is that normal? Would running the mkfs.ext3 command after creating the new partition delete the data? I just can't see how the data is still there after seeing that the partitions were gone and changing to a Linux fs. Any ideas?
That depends on what tool you use to do the partitioning. If you use parted or gparted to create the ext3 partition, they do the mkfs for you, and that would delete all your previous data. If you create the partition with a lower-level tool like fdisk, then you would have to run the mkfs yourself to reformat the partition, and if you did not do that the old contents would still be there.
Linux doesn't (much) care about the type code in the partition table, so it's perfectly possible to have an NTFS or FAT filesystem in a type 0x83 "Linux" partition.
Last edited by rknichols; 03-13-2014 at 12:25 PM.
Reason: add "Linux doesn't much care..."
Yes, fdisk just created a partition i.e. container with the same start and end point as the old one. The actual filesystem was not affected. In creating the new partition you also created a new partition table. So everything is back as it was.
As stated linux does not care about partition labels.
THanks for the info! I kind of had a feeling it might be something like that.
I'm having a problem with the 2TB drive which was NTFS, then I put it in the linux box, Fdsisk'd it to ext3, then mounted it & filled it. This was on ubuntu 12.04. That Os seems to handle NTFS very well. I moved it to other OS's and it isn't recognizing the FS properly. I think I actually have a NTFS format with a ext3 marker or container - does that seem plausible? Would that make me have the problems that I am having?
So I can read the drive on Ubuntu 12.04 with no additional FS support but Kali & backtrack don't see it.
What would be the best way to get these files safely into working order?
Odd how backups becomes important only after some event underscores their non-existence.
The issue with reading beyond the physical disk is an artifact of changes in the way the Linux tools now align paritions to account for 4k sector drives. Nothing has changed (in normal running) on your disk, just the reporting of it.
The easiest way to fix this is to use gparted to shrink the offending partition - don't scrimp. If it is a logical partition the extended will likewise need to be shrunk. Note that this use of gparted will not erase your data.
As stated a partition entry merely defines the extent of the area - a filesystem is separate. If you do start playing in fdisk or the like be aware that the partition and filesystem must align correctly or you will face similar issues.
IMO it's much more likely you have a filesystem error that caused the partitions to be re-checked. This may preclude the easy resizing. Make sure you have that backup before you start - it may be easier to loop-mount that to do the recovery of the data.
Looks like we were typing at the same time. Yes that can cause issues - you can change the partition type in any of the tools. Use fdisk and use the "t" subcommand to change the type to "Linux" - you can get a list from within fdisk.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.