Linux - SoftwareThis 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
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.
How does one replace the MBR – completely? Say with a blank MBR. Even after deleting all files of the root partition the computer thinks that it is still booting to the same OS, until it finds there is nothing there. What makes it “remember” an earlier time? I'd like the computer to think that it's a virgin.
Sorry to expose my newbiness but can I just do this from a live CD terminal? Then, I assume (with typical results of assumption) that I should be able to put in a CD of the distro of my choice and it will see the partitions that are still there OR does cleaning the MBR wipe out all partitions too?
The MBR is the first 512 bytes of the drive and is independent of any other partition. The MBR contains the bootloader and the partition table.
The mbr contains the FIRST partition table....If there are more than 4 partitions, one of the entries in the first table will be an extended partition. Then, in sector 1 (mbr being sector 0), you will find the first four logical partitions.
In sector 2, you might find more logical partitions
Etc. Etc.
On my drives, it seems that the default is for sectors 0-63 to be all boot stuff and partition tables.
Do this to see the whole ugly picture:
dd if=/dev/xxx bs=512 count=65|hexdump -C >sectors
where xxx = your drive id (eg hda, sda, whatever)
This writes 65 sectors in hex format to a new file named "sectors". You can browse this with a text editor to see every nuance of what is happening. I used 65 just to go a bit past the end to be sure I see the whole thing...)
At the end of the first sector (address 1FE) you will see a "signature"--05AA hex. This appears after every partition table. Thus if sector 1 and beyond, have partition tables, this signature will show up.
...that I should be able to put in a CD of the distro of my choice and it will see the partitions that are still there...
No - absolutely not. You wipe out the MBR, you wipe out your partitions!
You were talking "virgin disk" before. A virgin disk does not have partitions on it. Wiping out your MBR will take care of that, but still won't give you a virgin disk necessarily (not that it usually matters). If you had previously "installed grub to the MBR", then you would still have leftovers in track 0 even after wiping the MBR. You would need to wipe all of track 0 to clean it up. Again, there's normally no functional reason to do this. But one example comes to mind. A few years back Intuit's TurboTax thought it would install some copy protection software to track 0. Users could reformat their disk, wipe their MBR, but the stupid copy protection stuff would STILL be there waiting for you the next time you reinstalled Windows!
Your MBR contains a couple of things, one of them being your partition table. You can replace part of your MBR, not including the partition table, if you'd like. If you remember some DOS stuff, this is exactly what "fdisk /fixmbr" did. This replaced the bootcode but not the partition table. As just mentioned, another part of your MBR is the bootcode. The bootcode installed by Linux is not exactly the same as that installed by Windows, but they both do similar things. Different versions of Windows may install different bootcode as well (but all are functionally equivalent). Bootcode reads the partition table and transfers processing to a new location based on what is in the table. With Linux, you have things like grub or lilo getting into the mix as well. The bootcode will transfer control to the bootloader (grub or lilo) and the bootloader will read your partition table. That's if you said "install grub to the MBR". If you installed grub elsewhere - up on a partition - things are a little different in the bootcode.
Grub is too big to actually fit in the bootcode area of the MBR, so saying "install to MBR" is a little bit of a white lie. A stub will be installed to the MBR bootcode area, but the meat of grub will actually be stored elsewhere on track 0 (this is technically not the MBR, which is only the first 512 bytes of track 0).
So "dd if=/dev/zero of=/dev/hda bs=446 count=1"
this will erase the bootloader but leave the existing partition table.
What I am trying to do is remove all traces of my current OS. I have tried this by deleating everything from the root partition and even deleating and recreating the partition but I'm always left with the bootloader. I don't want to hurt my /home partition.
So "dd if=/dev/zero of=/dev/hda bs=446 count=1"
this will erase the bootloader but leave the existing partition table.
What I am trying to do is remove all traces of my current OS. I have tried this by deleating everything from the root partition and even deleating and recreating the partition but I'm always left with the bootloader. I don't want to hurt my /home partition.
When you remove files, you are nowhere near "remove all traces". Removing a file only removes the link to it in the filesystem. The data is still there.
Remove all traces = a disk wipe utility
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.