Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
I was wondering what the 'bs' part means? Would it be better to omit that?
bs=512 is the default:
Code:
info coreutils 'dd invocation'
So if omitted it would not make any difference. It simply instructs dd how big a chunk of data to remove or place each go. Incidentally the size of the MBR is 512.
The 'bs' and 'count' options together will give us the output file size of the dd command.
And regarding the 'bs' part, as mentioned earlier it is used along with 'count' to specify the output file size.
Code:
Example :
bs=512 count=1 --> This gives us a 512 byte size file.
bs=1M count=1 --> Results in a 1MB file (1,048,576 bytes)
bs=1MB count=1 --> Resutls in a 1MB file (1,000,000 bytes)
bs=1G count=1 --> Results in a 1GB file (1,073,741,824 bytes)
bs=1GB count=1 --> results in a 1GB file (1,000,000,000 bytes)
In short, 'bs' will be multiplied 'count' number of times to decide the output file size.
NOTE: dd command to backup the MBR
Code:
dd if=/dev/sda of=/tmp/mbr.out bs=512 count=1
Regards
Last edited by vinodvb; 02-08-2011 at 08:27 AM.
Reason: Correction
So the above command should include the 'count' option, and when included will actually wipe out the MBR (master boot record) and not the entire drive.
Sorry just make this clear for me, you mean that by including the count option, the above command would wipe only the MBR, but not the rest of the device?
Last edited by clifford227; 02-08-2011 at 08:21 AM.
Sorry just make this clear for me, you mean that by including the count option, the above command would wipe the MBR, but not the rest of the device?
Sorry for the confusion. If the bs and count options are mentioned, then the output size will be limited to as specified by bs and count. If not the entire drive will be written with random data.
In short, the first 512 bytes contain the MBR and if I limit the output file size to 512 bytes, then only the MBR will be overwritten. If I don't limit the output file size, then the entire drive will be overwritten including the MBR.
Sorry just make this clear for me, you mean that by including the count option, the above command would wipe only the MBR, but not the rest of the device?
More correctly speaking, bs=512 count=1 will overwrite the first 512 bytes of the file specified by of='...'. If that file is a device node tied to a block device then it will write the first 512 bytes in that device with random bytes. If the device is partitioned using a MBR scheme then that matches the MBR. But the device could also hold meaningless stuff or be partitioned using EFI or some other thing, not necessarily an MBR scheme.
While we're on the subject, wouldn't /dev/zero work just as well as /dev/urandom, and probably be quicker?
Yes. It's just that people who are afraid that the NSA will waste their time to rescue porn from their hard drives prefer to use /dev/urandom to make it harder to recover all the porn from the drive. If you don't feel that kind of paranoia, just use /dev/zero.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.