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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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
dd if=/dev/sda of=/tmp/mbr.out bs=512 count=1
Last edited by vinodvb; 02-08-2011 at 08:27 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.