[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: clearing data from partitions





Andrew Schulman wrote:
I have a large hard drive divided into many partitions so that I
can try new distros. Two large partitions hold Sarge and Unstable.

Grub picks up everything and I have a quite large menu.lst file.
I want to find the safest way to 'clear' the contents of partitions
that I no longer need.

I know I can use fdisk or cfdisk to delete each partition, immediately
recreate and then format with say ext3.
Is there any simple way to accomplish what I want?

John.

P.S. I've tried deletions in the menu.lst file, but the next time
try another distro, grub picks up everything again.

One quick, but kludgy way to do it would be say..

cat /dev/zero to each of the partitions for a few seconds.
that will murder the partition, and it will end up basically broken.
at that point, youd want to mke2fs or something on each one.

If you make a text list of all the partitions you want to do this to
you can script it!

something like..

bash#  for i in `cat partitions.txt`; do dd if=/dev/zero of=$i bs=1024
count=50; mke2fs $i; done

that should go through the textfile, overwrite the first ~50k of each
partition with zeroes
then mke2fs it.


Whew.  A few comments (mixed to OP and replier):

(1) There is no need to delete, then recreate a partition before running
mke2fs.  You can just run mke2fs.  Or, just delete all of the files on the
existing file system.

Right, point taken, but I was putting the file system on from cfdisk.

(2) grub doesn't have any autodetection routines.  Either the installers for
the other distros are modifying that menu.lst file (which would actually be
pretty smart of them, although maybe not what you want), or else grub is
using a different menu.lst file than you think.

I don't have enough knowledge to fully follow what you say. What I do know, is that when I edit the menu.lst file to clearly show what distros I have available (e.g. grub says 'Linux' when I want it to show 'Knoppix', 'Debian testing/unstable' for both Sarge and Sid when I want it to say 'Sarge' for the former and 'Sid' for the latter). The moment I put another distro on the drive and select Grub for the bootloader, it goes back to the 'confused' state and I have to look up my hand written notes to see what I put in which partition - and I don't always make such a note!!

(3) If somehow there is some autodetection going on, then it will probably
"refind" your partition anyway if it has a file system on it.  If you want
to avoid that then you'll have to destroy the file system.  The suggested
method will work just fine for that.  But:

If it 'refinds' partitions with only filesystems on them, then I'm back to square one. I wonder if there is any way to have just an empty partition (as I had when I intially set up the hard drive).

(4) Be extremely careful with that shell code.  You will destroy a lot of
data in a hurry, probably beyond recovery.  Take a long, hard look at the
contents of partitions.txt before you pull that trigger.

I would only deal with one partition at a time and then by hand. It was kind of Dan to offer the script but I remain wary of them and will do so until my knowledge improves (assuming it ever does).

Good luck,
Andrew.

P.S. Please reply below a quoted response, not above.  It allows other
readers to follow the conversational thread.

Didn't think I did.

I'm grateful for your response - many thanks.			John.




Reply to: