LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2015, 09:24 AM   #1
ltkenbo
LQ Newbie
 
Registered: May 2006
Posts: 8

Rep: Reputation: 0
Erasing a disk before writing and expanding a fs image


I'm writing a small ext4 image I've built to a block device in Linux using the dd utility.

i.e.
Code:
dd if=/root/ext4image.img of=/dev/'blockdevice'
After this, I delete the partition on the device with fdisk and recreate it to use the rest of the disk. I then run fsck to check the disk and then finally resize2fs to resize the file system. This works for me just fine.

My main question with this method is, is it necessary to erase the disk first?

i.e.
Code:
dd if=/dev/zero of=/dev/'blockdevice'
Are there any consequences to not erasing it first?
 
Old 07-06-2015, 09:28 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Not from an ext4 standpoint. It will recognize the additional space you give it with the resize2fs.

Since you're using a partition you'd have to make sure you see the additional space at OS level before you did the resize2fs of the filesystem. (e.g. After the change use fdisk -l or parted to verify the OS sees the additional space.
 
Old 07-06-2015, 09:30 AM   #3
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
If you do not erase the disk completly, the data in the area, which was not overwritten by the image, will be kept.
 
Old 07-06-2015, 10:19 AM   #4
ltkenbo
LQ Newbie
 
Registered: May 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Keruskerfuerst View Post
If you do not erase the disk completly, the data in the area, which was not overwritten by the image, will be kept.
So let's say I have a full device with an ext4 file system. I then perform my method of writing this smaller image, then re-partitioning and expanding. It is than possible that the files from the previous full file system are still present in this new one? Where would they be, in lost+found?
 
Old 07-06-2015, 10:30 AM   #5
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
It is only possible to access the data in the not-overwritten area directly.
 
1 members found this post helpful.
Old 07-06-2015, 10:33 AM   #6
ltkenbo
LQ Newbie
 
Registered: May 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Oh ok. So I needn't worry about this affecting my "new" file system correct? (This is all I care about)
 
Old 07-06-2015, 10:36 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,739

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
"Kept" only in the sense of still available for forensic recovery. If you ever do run into a problem where you have to resort to recovery tools like testdisk and photorec, it can be a bit confusing to have them discovering that old data. Other than that and privacy concerns, there's no need to erase the disk.

That said, I generally do zero a hard disk or flash drive (though probably not an SSD) before re-using it.
 
1 members found this post helpful.
Old 07-06-2015, 10:53 AM   #8
ltkenbo
LQ Newbie
 
Registered: May 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Alright guys thanks this is exactly the info I was needing!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
My disk erasing procedures -- do you think that's enough? Da_Nuke Linux - Security 6 03-09-2012 03:40 PM
DoD 5220.22-M for disk erasing frente69 Linux - Security 4 07-15-2009 10:29 AM
problems writing disk image dapsyn Linux - Distributions 2 08-06-2007 03:54 AM
Having trouble writing disk image to floppy flycast Linux - Software 7 01-23-2007 08:42 AM
Increase disk space without erasing data stranger_6_7 Linux - Newbie 8 12-01-2006 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:18 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