LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 12-21-2007, 09:59 AM   #1
alenD
Member
 
Registered: Jul 2005
Posts: 69

Rep: Reputation: 15
how to zero empty disk space


Hi
I want to create an image of my Linux machine.
I understand that I can zero empty disk space to reduce the size of the image. How can I do this?

cat /dev/zero > zero.dat ; sync ; rm -f zero.dat - is this the right command?

thnx
 
Old 12-21-2007, 01:14 PM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by alenD View Post
cat /dev/zero > zero.dat ; sync ; rm -f zero.dat - is this the right command?
That will only zero the space used by the file. It won't zero the information that was used to locate the file (directory entry and so on).

If you really want to zero a drive, I recommend running
Code:
# dd if=/dev/ones of=/dev/hda bs=1M
# dd if=/dev/zero of=/dev/hda bs=1M
# dd if=/dev/ones of=/dev/hda bs=1M
# dd if=/dev/zero of=/dev/hda bs=1M
# dd if=/dev/ones of=/dev/hda bs=1M
# dd if=/dev/zero of=/dev/hda bs=1M
where "/dev/hda" is replaced by the drive you want to zero (e.g. /dev/sda).

The reason for alternating between ones and zeros is that residual data can be read by forensics experts using special software that can peturb the head to the edge of the cylinder. If your kernel does not have "/dev/ones", you can use
Code:
# cat /dev/zero | tr '\000' '\377' | dd of=/dev/hda bs=1M
 
Old 12-21-2007, 01:17 PM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by alenD View Post
I want to create an image of my Linux machine.
I understand that I can zero empty disk space to reduce the size of the image.
If you use Partimage, you won't have to zero the empty space. It parses the file system and skips unused space automatically.
 
Old 12-21-2007, 01:20 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
David1357, when talking Forensics the zeroes and ones scheme is nice but it isn't complete enough.

Last edited by unSpawn; 12-21-2007 at 01:29 PM.
 
Old 12-21-2007, 02:15 PM   #5
alenD
Member
 
Registered: Jul 2005
Posts: 69

Original Poster
Rep: Reputation: 15
I actually wanted to zero the empty space, NOT the whole hard drive.
 
Old 12-21-2007, 02:16 PM   #6
alenD
Member
 
Registered: Jul 2005
Posts: 69

Original Poster
Rep: Reputation: 15
I dont use Partimage
 
Old 12-21-2007, 02:42 PM   #7
alenD
Member
 
Registered: Jul 2005
Posts: 69

Original Poster
Rep: Reputation: 15
strange... now when I am trying to create an .arc image of my disk the burner keeps creating endless number of 1k files until it fills the disk.
What kind of problem is that?
 
Old 12-21-2007, 03:14 PM   #8
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by alenD View Post
I actually wanted to zero the empty space, NOT the whole hard drive.
Yeah, sorry, I misread the post. Why don't you use Partimage? I've been using it for nearly two years with no problems.
 
  


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
Cedega "Disk space required for the installation exceeds available disk space" Solved Spewdemon LinuxQuestions.org Member Success Stories 1 10-18-2007 06:19 PM
Does empty directory occupy space?? rs_vijay Programming 4 12-16-2006 06:50 PM
dd empty space question ygloo Linux - Software 15 09-22-2006 12:24 PM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 03:58 PM
101% disk usage on an empty disk tsiuser Linux - Software 3 01-28-2004 06:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 09:08 PM.

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