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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
01-03-2006, 01:53 PM
|
#1
|
Member
Registered: Dec 2005
Location: NC, USA
Distribution: (K)ubuntu
Posts: 139
Rep:
|
Erasing MBR from USB stick
I'm playing around with Linux distros that will run from a USB memory stick and will finction as a complete OS, as if running from an HDD. One that I tried installed the bootloader to the stick's MBR. I have since formatted the stick, so the OS is gone, but the bootloader is still there pointing to it.
I need to get rid of the MBR bootloader so that when my laptop boots to the USB stick, the syslinux file points it to the right OS. How do I clear the MBR?
|
|
|
01-03-2006, 02:49 PM
|
#2
|
Member
Registered: Aug 2004
Distribution: LFS
Posts: 350
Rep:
|
You can re-install the MBR onto the USB Stick with syslinux, for a stick connected as /dev/sda the following will reinstall the MBR, adjust the device name to suit your setup.
Code:
syslinux -s /dev/sda
HTH
Mad.
|
|
|
01-03-2006, 02:55 PM
|
#3
|
Senior Member
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460
Rep:
|
Erase the MBR using "dd if=/dev/zero of=/dev/sda bs=512 count=1" assuming the USB stick is sda of course
|
|
|
01-03-2006, 05:02 PM
|
#4
|
Member
Registered: Dec 2005
Location: NC, USA
Distribution: (K)ubuntu
Posts: 139
Original Poster
Rep:
|
OK, I ran that command to clear the MBR, but it seems that when it did, it also removed all partition s from the memory stick as well. How do I put a partition on there from the command line?
|
|
|
01-03-2006, 06:16 PM
|
#5
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,437
|
That was a poor decision. Not knowing syslinux, I would have thought the solution offered by madluther would be the best place to start.
What the dd command actually did was also remove the partition table; although the data in the partitions hasn't been touched.
Not only that, it removed the signature bytes on the disk - which means fdisk and cfdisk won't open the disk. These two utilities are the normal way to create partitions.
testdisk probably will do the job although I haven't looked at the code - maybe parted as well.
Probably gparted as well, if you have a GUI available.
oneandoneis2, I suggest you not offer this advice to anyone else.
|
|
|
01-03-2006, 07:15 PM
|
#6
|
Senior Member
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151
Rep:
|
spiffytech: As syg00 pointed out, the parted rescue feature usually does a good job of recovering primary partitions. How to use the rescue option is explained here: http://www.gnu.org/software/parted/m...ted.html#SEC24
..........
Regarding the “dd” command:
Once upon a time, a salesman locked himself out of his car in Manhattan. A kid walked up and said “Hey mister, I’ll open your car for $10, but I want the money up front.” So the salesman gave him $10 and the kid picked up a brick and broke the side window. “Hey mister, you didn’t ask me how I was going to do it.”
|
|
|
01-04-2006, 05:09 AM
|
#7
|
Senior Member
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460
Rep:
|
The OP says the drive has been formatted, implying there was no valuable data on the drive, or I wouldn't have recommended the dd method.
I've never had any problems repartitioning a flash drive that's been dd'd in the manner I mentioned. I forget if I used fdisk or cfdisk, but those are the only partitioners I have installed, so I know for a fact that at least one of them works just fine.
Under the cirumstances, as a simple way of clearing the MBR of a blank disk, I believe the dd method is a good one.
YMMV.
|
|
|
01-09-2006, 05:27 PM
|
#8
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,437
|
Apologies are in order to oneandoneis2.
I just had the opportunity to zero a hard-disk prior to the laptop being returned to the leasing company.
fdisk opened and created partitions even with the zero'd MBR just fine.
Didn't work the last time I tried it, did with this version of Knoppix (3.9 - kernel 2.6.11).
Live and learn.
|
|
|
01-09-2006, 08:52 PM
|
#9
|
Member
Registered: Nov 2003
Location: South Jersey
Distribution: Slackware, Raspbian, Manjaro
Posts: 826
Rep:
|
I'm glad dd got the respect it deserves! It's the coolest command out there!
|
|
|
01-10-2006, 05:38 PM
|
#10
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,437
|
dd was never the issue - merely it's use.
Given the wide variety of kernel versions out there, my preference is to use
Code:
dd if=/dev/zero of=/dev/sda bs=446 count=1
This clears the entire code section of the MBR, but leaves the partition table and signature bytes intact.
|
|
|
All times are GMT -5. The time now is 10:29 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|