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.
All you have done is copy one sector, then write the same data back. Why would you think that would affect your files (or the filesystem) that exist elsewhere on the disk ?. The partition table merely defines the start and length of each partition - nothing more.
According to my understanding of the dd FM
I would have an empty pen drive with the same NTFS part, but the files are still here.
After this dd command, the first 512 bytes of the disk have exactly the same content as before the command. In other words, the disk's content hasn't changed. Why do you expect that your files disappear?
Quote:
Normaly I should use :
Code:
# dd if=mbr.img of=/dev/sdb bs=512 conv=notrunc
to get this result.
I think I understand your reasoning now. If /dev/sdb were a regular file, it would be truncated. But it is a device file, which can't be truncated.
The files are still there because you haven't altered the part of the disk they are on. You've only rewritten the MBR. And since the new MBR is identical to the old one, the partition table inside it will still allow the kernel to find out where the first partition starts and so find the files.
After this dd command, the first 512 bytes of the disk have exactly the same content as before the command. In other words, the disk's content hasn't changed. Why do you expect that your files disappear?
I think I understand your reasoning now. If /dev/sdb were a regular file, it would be truncated. But it is a device file, which can't be truncated.
OK! I understand that.
But there is no mention of such behaviour in the FM
Is there other kinds of exception that basic user should be aware ?
this is not an exception, this is how things work.
If you write a file (in a filesystem) the size will be determined based on the data you write into it. dd, copy and a lot of other tools will remove your original file and create a new one (= overwrite).
But if you write data directly onto a physical device you cannot remove/overwrite files but simply overwrite blocks on the device. Obviously non-touched blocks will not be affected.
It is your own decision [a basic user should be aware of] if you dd into a file on a filesystem or on a device - without using any filesystem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.