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.
Background: I want to sell an old harddisk. I have deleted all with dd if=/dev/zero of=/dev/hda bs=512. After that I have started fdisk to rewrite an empty dos partition table. But I know that it is impossible to install windows on it due to a valid MBR. I dont't want to make a floppy only for using fdisk /mbr. So my question which Linux command can do it?
But I know that it is impossible to install windows on it due to a valid MBR.
How do you "know" this ?.
The disk is fine as-is; in fact you would be better not to write the partition table at all. Just zero it, and sell it.
During an install Windows will recognise it as an unformatted disk, and offer to format as part of the install.
I do this regularly with XP when testing disk (particularly MBR/partition table) recovery.
Not sure how Windows reacts if it's simply an extra disk (i.e. not being installed onto) - I haven't bothered testing that.
I want to sell an old harddisk. I have deleted all with dd if=/dev/zero of=/dev/hda bs=512
You have not "deleted all". You have only overwritten your MBR, a paltry 512 bytes of your disk. If you think this makes all your previous data unrecoverable, think again. You're probably still sitting at a 99+% chance of COMPLETE RECOVERY right now. You need to overwrite the entire disk, and do so multiple times with varying patterns of one's and zero's.
If you didn't have anything sensitive on the disk you may not want to go to the trouble. On the other hand, if you had something very sensitive I wouldn't sell it, I'd destroy it. Sledgehammers, electric drill holes, dissassembly and scratching up the platters with a grinding wheel are steps to take. Then break the platters into little bitty pieces and take them down to your local hospital for a visit with their MRI scanner (you probably wouldn't be too popular with the hospital staff after that one!)
You have not "deleted all". You have only overwritten your MBR, a paltry 512 bytes of your disk. If you think this makes all your previous data unrecoverable, think again. You're probably still sitting at a 99+% chance of COMPLETE RECOVERY right now. You need to overwrite the entire disk, and do so multiple times with varying patterns of one's and zero's.
Hmmmmm---dd will keep going to the end of the file/device if there is no count specified. OP's command will--in fact---write zeros to the whole drive.
As already pointed out, just writing zeros is not really secure. For security , you need something like DBAN: http://dban.sourceforge.net/
I always thought that you could "wipe" a drive and then install Windows......
You have not "deleted all". You have only overwritten your MBR, a paltry 512 bytes of your disk. If you think this makes all your previous data unrecoverable, think again. You're probably still sitting at a 99+% chance of COMPLETE RECOVERY right now. You need to overwrite the entire disk, and do so multiple times with varying patterns of one's and zero's.
If you didn't have anything sensitive on the disk you may not want to go to the trouble. On the other hand, if you had something very sensitive I wouldn't sell it, I'd destroy it. Sledgehammers, electric drill holes, dissassembly and scratching up the platters with a grinding wheel are steps to take. Then break the platters into little bitty pieces and take them down to your local hospital for a visit with their MRI scanner (you probably wouldn't be too popular with the hospital staff after that one!)
I think you are wrong! There is no count and it will write zeros until the end of the disk is reached. But the topic was no "how to erase", it was how to restore MBR after erasing! But thanks for your answer.
You are right. I am wrong! I guess I've seen that dd command so many times, with "count=1" added to the end of it, that I just ASSUMED it was there in the original example. Oops!
I agree, the entire drive was wiped. A single pass wipe using only zeros is good enough to obliterate things from normal people. If the NSA or somebody like that got ahold of the drive they could probably recover some stuff. But having the NSA grab your disk is not really a high probablility for most of us (I hope!)
I always thought that you could "wipe" a drive and then install Windows......
I've done that before. Never seemed to make any difference on future installs if the MBR was totally zeroed out or not. I'm not sure what the variations might be that make some people have trouble doing so.
Quote:
Originally Posted by RGummi
Windows installs fine but it can not boot from this disk. After I used the Windows recovery console and doing fixmbr it works!
If Windows installed, but then wouldn't boot until you did a manual fixmbr, that almost sounds like it has to be a defect in the Windows installer. Otherwise, it would appear that Windows was EXPECTING something to preexist on the harddrive, which doesn't sound like something an operating system would expect.
Quote:
Originally Posted by RGummi
But the topic was no "how to erase", it was how to restore MBR after erasing!
I understand this and wasn't trying to hijack the thread. I made an error and did not correctly interpret what you had done with dd. My mistake left me thinking that you had not done the wiping you thought you had. I pointing this out to you with the noblest of intentions - to save you possible grief later if your personal data was stolen. I am sorry that I made a mistake.
Defect in the Windows installer: Only in the installer ;-)
Quote:
it would appear that Windows was EXPECTING something to preexist on the harddrive, which doesn't sound like something an operating system would expect
It would be intersing to look at a new disk, what there is already on it. I think each sector ends normally with 0x55 0xAA. Perhaps this is the reason why windows does not install a MBR.
Defect in the Windows installer: Only in the installer ;-)
It would be intersing to look at a new disk, what there is already on it. I think each sector ends normally with 0x55 0xAA. Perhaps this is the reason why windows does not install a MBR.
The 55AA signature is the last two bytes of a partition table. It does not appear on a sector with no partition table.
Close - it's a disk "signature".
Last 2 bytes of the first sector - after the partition table.
Older versions of [c]fdisk used to explicitly check for the presence of these two bytes prior to opening a disk. I was surprised to see such code.
I think if you have an old knoppix (3.3 maybe ???), you would see fdisk fail to open such a formatted disk.
Quote:
I have tried it! Windows installs fine but it can not boot from this disk. After I used the Windows recovery console and doing fixmbr it works!
Don't understand this - never seen it happen (with XP).
To sell it now (i.e. without windows) use "skip=1" on the dd command.
Save you (and the rest of us ) a heap of grief.
First, all partition table records (sectors) have the same format. This includes the partition table record at LBA 0 (cylinder 0, head 0, sector 1) -- what is known as the Master Boot Record (MBR). The last 66 bytes of a partition table record contain a partition table and a 2 byte signature. The first 446 bytes of these sectors usually contain a program but only the program in the MBR is ever executed (so extended partition table records could contain something other than a program in the first 466 bytes). See Master Boot Record.
Yes, the signature is after the actual partition table--and is the last two bytes of a partition table record. It can appear many times on one disk if there are a lot of extended partitions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.