LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-23-2018, 11:10 AM   #1
gjarboni
LQ Newbie
 
Registered: Aug 2009
Posts: 13

Rep: Reputation: 3
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: (

Quote:
x00000200 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 | |
x00000210 33 2e 32 36 2e 30 41 20-30 37 20 32 30 31 32 2d |3.26.0A 07 2012-|
x00000220 31 32 2d 33 31 00 00 00-00 00 00 00 00 00 00 00 |12-31 |
x00000230 30 35 2f 30 34 2f 31 31-00 00 00 00 00 00 00 00 |05/04/11 |
x00000240 30 32 3a 32 37 3a 34 33-00 00 00 00 00 00 00 00 |02:27:43 |
x00000250 31 2e 31 2e 34 36 2e 30-00 00 00 00 00 00 00 00 |1.1.46.0 |
x00000260 38 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |8 |
x00000270 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 | |
x00000280 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 | |
x00000290 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 | |
x000002a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 | | v
mqqq view 270h/624 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
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).

Thanks for reading. I appreciate all replies.

Jason M.
 
Old 04-23-2018, 12:00 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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.
 
1 members found this post helpful.
Old 06-15-2019, 06:13 PM   #3
gjarboni
LQ Newbie
 
Registered: Aug 2009
Posts: 13

Original Poster
Rep: Reputation: 3
Thumbs up What about superblocks?

Thanks! But I'm confused about one thing:

Quote:
Originally Posted by michaelk View Post
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.
 
Old 06-15-2019, 06:42 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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.

Last edited by michaelk; 06-15-2019 at 06:43 PM.
 
Old 06-15-2019, 08:03 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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'...
 
Old 06-16-2019, 07:53 AM   #6
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,479

Rep: Reputation: Disabled
Quote:
Originally Posted by gjarboni View Post
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.
 
Old 06-16-2019, 11:13 AM   #7
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by michaelk View Post
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.
 
Old 06-16-2019, 08:16 PM   #8
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,311
Blog Entries: 28

Rep: Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137
The traditional Linux tool for zeroing out a partition is dd: https://wiki.archlinux.org/index.php...y_wipe_disk#dd
 
  


Reply

Tags
fdisk, partitioning



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using fdisk or parted, is there a way to split a partition easily? slacker_ Linux - Newbie 2 09-03-2013 06:26 PM
Partition management: lvm? fdisk? parted? (on RAID) emailbuilder88 Linux - General 1 04-30-2010 10:59 PM
cannot use 100% of hard disk, fdisk / parted / partition question lucastic Linux - Hardware 5 12-02-2005 08:58 PM
partition resizing using parted...bad memories of fdisk rextor Linux - General 1 07-30-2005 10:34 AM
What app can REALLY delete a partition? (not fdisk, parted, etc...) kornerr Linux - General 4 05-28-2005 12:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration