Protecting Dualbooting Windows from dangerous code (like rm -rf)

If you have physical access to a computer, you have the power to do anything with the files on it, including reading, corrupting or deleting them.

It's possible to make it harder to accidentally delete files, though.

If you want to read documents on your Windows 10 partition, you could mount the partition in read-only mode. You won't be able to edit Word documents, but it should be enough if you want to read PDF, listen to MP3's or watch movies on your Windows partition. Another possibility would be to create a FAT32 D: partition under Windows, which you would mount with write permissions under Ubuntu.

I could think of at least 5 short commands to destroy a Windows Partition from a Linux system, but they would all require root privileges. Be careful whenever you want to run a command starting with sudo or when a program tells you that "Authentication is required to run".

Finally, be very careful when installing Ubuntu along Windows. The installer makes it clear which partitions are resized, created or deleted but it's still possible to delete existing partitions if you ignore the warnings long enough.

To be safe, please follow @Emmet's excellent advice (be sure to backup your data).


The common basic to prevent data-loss: REMEMBER TO ALWAYS TAKE BACKUP OF YOUR FILES

It doesn't affect the windows partition, because you're running it from your Ubuntu machine.

Picture it like this

/dev/sda1 ntfs-bootfile
/dev/sda2 ntfs-win
/dev/sda5 ext4-root --> (YOUR LOCATION NOW)
/dev/sda6 ext4-swap

If you run rm -rf within your location, it would affect sda5 partition—in which your Ubuntu system reside. So it only affect Ubuntu.

Supposing you have grub boot loader to load the 2 OS (Ubuntu and Windows), if you accidentally remove GRUB file aswell, Windows would not be able to boot, but the data inside will remain intact.

However, Ubuntu tend to mount Windows partition when it available, and if you say ran rm -rf /*, Ubuntu—without hesitate will delete ALL file, this include Windows partition.

There's also infamous dd command, hence the disk destroyer nickname. This is widely used to: formatting drive, cloning disk, creating bootable usb etc.

dd has ability to dump entire main drive, dd if=/dev/zero of=/dev/sda would replacing all data on main drive with zero—and goodbye to our data !

With that being said, please be very careful when running command and always take a second look before doing execute something—it's best to prevent disaster before it happens.

I highly recommend you to learn various Linux command, this way you could tell what does the command do before you ran it.

Also, again please be elaborate when working with dd, it's common mistake to mistype sdb to sda, anything happens after that is horrible.