1

This should be a general question. This Q sprung my mind yesterday late evening because I accidentally deleted files from another partition rather than from the partition I was intending to do.

I'm working on Ubuntu 13.04. From launcher I clicked on the '2nd from top' icon (named files). There I clicked on 2 GB flash drive and it got mounted. I was intending to delete all the files here. Before that I was doing some other tasks on other windows. Then I returned back on the 'Files' window. Rather than clicking on the 2 GB flash drive I clicked on the 40 GB drive which was directly above the flash drive. This 40 GB was of Windows 7. Then I pressed 'ctrl-a' & 'shift-del'. Before this mistake stroked my mind, it had already deleted 7 GB of data (luckily other 33 GB was secure).

Now, I'm very much concerned of how to secure my partitions/files & everything on my laptop. The solution should include the below point:

On the files window, all partitions are listed & its only a matter of clicking on it to mount it. It should be that whenever it is clicked it should mount automatically on read only mode so that no accidental deletion occurs.

I expect a general solution for securing my laptop.

One thing I would like to add that I have taken backup of my Ubuntu partitions (/, /boot & /home) & so my Ubuntu data are safe but I can't take for all partitions because of lack of space.

  • You could look btrfs or zfs and their snapshot and roll back features. – replay Jan 5 '14 at 8:08
  • The suggestion I generally make is as follows. For your actual work, which is probably text, you should use distributed version control (git or mercurial are the most common these days) and push to a remote location frequently. That way, even if your laptop explodes, you don't lose that much of importance. If you aren't already using distributed version control, you should be. I'll also add this has worked well for me in the past. My machine has died three times, and each time I was immediately able to switch to another machine and continue working. – Faheem Mitha Jan 5 '14 at 8:08
  • 5
    Offsite backups, tested regularly, is the only strategy that qualifies as a backup. If you are not doing that, you are essentially gambling with your data. – jasonwryan Jan 5 '14 at 8:12
  • 3
    Ummm... there is already a solution to this, isn't there? When you press Del files are moved to the trash, so you can recover them if you make a mistake. Instead, you pressed Shift-Del, overriding the safety... – derobert Jan 5 '14 at 8:15
  • What about double-checking you're on the correct partition before performing a delete -- or any other risky operation? – dr01 Jun 14 '17 at 13:28
1

In /etc/fstab, modify the line that mounts the windows partition and set it to read-only (ro). Your fstab file will be different but such a line might look like:

/dev/sda3  /mnt/windows     ntfs    defaults,ro 0 0

You can also similarly make /boot read-only (except when doing system upgrades). You can do the same for / after you migrate /tmp and /var to a read-write partition and handle a few other stray files. Instructions with all the details for mounting / read-only on a Debian-like system are here.

If you are using ext3 or similar, you can also set the immutable bit for files you want to protect: see man chattr. (Remove this bit for system files while doing system upgrades.)

You mentioned making backups of linux data. You should have two copies, one local and one remote, to handle fire, theft, etc.

I also use @FaheemMitha's approach of version control to a remote repository on important work files.

  • Yes this worked but one note: the partitions are mounting read only but they aren't visible on the 'Files' window. On devices section, they aren't present. I need GUI for these. – Ravi Jan 5 '14 at 8:44
  • O.K. I got it. As the partitions are included in fstab, they won't be visible under Devices heading in Files window. I need to access (GUI) them via Computer option under Devices. – Ravi Jan 5 '14 at 13:31
  • If I do the same for / then won't it hinder installation of new s/w or won't it hinder system upgrades? Because other that /var & /tmp, I think /etc is also affected? – Ravi Jan 7 '14 at 2:25
  • @Ravi Yes, it would hinder system upgrades. While doing system upgrades, you have to turn the safetys off. Before a system upgrades begins, one would have to (1) remount the partition read-write (sudo mount -o rw ...) and (2) reset the immutable bits (sudo chattr -R -i /). After system upgrade, change back to the safe settings. – John1024 Jan 7 '14 at 2:46
  • @Ravi Your mention of /etc jogged my memory. Thanks. I added a link that covers what stray files need to be worked on before mounting / read-only. – John1024 Jan 7 '14 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.