Do fdisk or parted zero out a partition when it's created or deleted?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Do fdisk or parted zero out a partition when it's created or deleted?
Hello,
I'm almost positive that the answer to this is no, but I want to get an answer from someone who knows Linux's fdisk better than I do.
Does fdisk zero out a newly created partition?
Some background information. I took apart a DirecTV GenieGo and found that it had an eUSB drive. (I don't want to clutter up this post, but if people want more information I'll provide it.) I hooked it up to a USB port on a regular computer and saw this:
Quote:
Command (m for help): p
Disk /dev/sdc: 14.9 GiB, 16013852672 bytes, 31277056 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: 0xc3072e18
Device Boot Start End Sectors Size Id Type
/dev/sdc1 8064 31277055 31268992 14.9G c W95 FAT32 (LBA)
It turns out that the partition was really XFS, not FAT32. Now I noticed that the partition started at sector 8064, which seemed odd given most of the other computers I've looked at have partitions that start at sector 2048 (one had a partition starting at sector 63
I wanted to look at the data before /dev/sdc1 so I created a partition from sector 2048 to 8063. Linux didn't recognize any type of filesystem. So I then used parted to delete the partition I created:
Quote:
Using /dev/sdc
(parted) print
Model: USB DISK 2.0 (scsi)
Disk /dev/sdc: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
2 1049kB 4129kB 3080kB primary
1 4129kB 16.0GB 16.0GB primary xfs lba
(parted) rm 2
(parted) q
Information: You may need to update /etc/fstab.
Now I copied the first 8063 sectors using dd. I don't have a record of the command, but it was something like:
Quote:
dd if=/dev/sdc of=./eUSB.img bs=512 count=8063
I know I should have done this first, but I didn't think that anything I did would have erased data. Is that the case? I ask because the file from dd is almost entirely zeros. There's the MBR and then this: (
And that's pretty much it. I paged through about a fourth of the dd file and did spot checks for the rest and they were all zeros. I was hoping that the device booted from this eUSB device and that we could figure out what instruction set was being used. The main chip is an MPEG encoder/decoder, and I don't think there's a separate CPU (there doesn't seem to be anything anywhere big enough).
You are correct the answer is no. A partition is nothing more then a container and creating the partition just defines the container. In addition, creating a filesystem does not zero it out anything either.
In addition, creating a filesystem does not zero it out anything either.
When it says creating superblocks what does it mean? I thought the output when you make a new fs listed the superblocks in case your file system was difficult to recover.
Creating a file system overwrites the metadata but the files remain. It does make recovery difficult but not impossible. Utilities like test examine the the disk on a byte for byte process to recover files. Encrypting makes recovery very difficult if not impossible.
That is only true if the parameters are the same. For example if a blksize is changed the meta-data changes may overwrite what was user data. If you always use default attributes and the size of the partition wasn't changed, what michaelk states is true in my experience.
Note my sigline tho'...
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,499
Rep:
Quote:
Originally Posted by gjarboni
Thanks! But I'm confused about one thing:
When it says creating superblocks what does it mean? I thought the output when you make a new fs listed the superblocks in case your file system was difficult to recover.
I think it only overwites those particular sectors where they place the superblocks, everything else remains, until over written by new data. if you want a 'clean' disk, you need to run shred, or similar, on the disk.
You are correct the answer is no. A partition is nothing more then a container and creating the partition just defines the container. In addition, creating a filesystem does not zero it out anything either.
Except for the I-node table, root directory and journal, of course, apart FROM the spare superblocks. So after a mkfs the disk will look empty, but no actual file data has been overwritten.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.