0

Case 1:

Let's say I mount /dev/sda3 /var and this entry is not in /etc/fstab. After unmounting /var, if /dev/sda3 is an unused partition (no entries in the fstab), if I delete it I will not lose any data, correct?

Case 2:

Again let's mount /dev/sda3 /var, however this time /dev/sda3 has a mount point at /usr in /etc/fstab - currently not mounted. If I umount /var, and now delete /dev/sda3 - noting that it is NOT mounted currently will I lose the data on /usr?

1 Answer 1

2

Case 1: Yes, you will lose whatever went into /var while /dev/sda3 was mounted there. Since various system services and other applications use that directory for permanent storage, it is probably a bad idea to either unmount it or delete the contents.

Case 2: You will not lose anything currently in /usr, but the system will probably not work as soon as you arbitrarily mount something on it. If that partition contains your real /usr, it should be mounted there at boot and never removed. If that partition does not contain your real /usr, it should never be mounted there.

To make this clear: Fooling around by mounting different partitions arbitrarily on /var and/or /usr is stupid, do not do it.

4
  • Okay - there's something I forgot to add. By default, /dev/sda1 is mounted on /, and /var is included under /. So if I umount /var and delete /dev/sda3, doesn't that mean that the existing files are still under /dev/sda1? Are you trying to say that if I performed any additional operations on /var while it was mounted under /dev/sda3 then those changes would be lost?
    – user
    Apr 25, 2015 at 12:37
  • 1
    If you mount something on a directory that contains information, that information becomes unavailable, and whatever is in the mounted partition effectively replaces it. So, if you had /var as part of a single partition mounted on /, then you mounted /dev/sda3 on it, whatever is in sda3 is now your /var. When you unmount it, /var will be exactly the same as it was before you mounted sda3 there. If you then delete sda3, you will lose anything put there while it was mounted.
    – goldilocks
    Apr 25, 2015 at 13:04
  • so in light of this, it would be a very bad idea to arbitrarily mount 'significant directories' to partitions, because some data may be written to those partitions, and if the partition was remounted on another partition, the data would be spread across two partitions, right?
    – user
    Apr 25, 2015 at 23:22
  • 1
    Yeah, you'd basically be moving information to where it can't be found. In the case of /var, it might not be immediately apparent that there are problems, but moving /usr will be a complete disaster. Presuming you have a motive for wanting to do stuff like this, the best idea is to ask specifically about it and explain the motivation, because there may be a much simpler solution to whatever your problem is.
    – goldilocks
    Apr 26, 2015 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .