Is it possible to boot from a symlink?

1

My experience was that I can make a symlink of a program's installation directory, which would allow me a virtual copy that could be altered without changing the original.

Can I do this with a bootable partition?

My intention is to install an OS to one partition, make it read-only, and run the OS from a second partition which is simply a symlink to the read-only installation.

Would this work?

Edit:

The wiki that provided the instructions, has been closed. But here is another place talking about the use of "junctions" in windows with the game client.

https://oldforums.eveonline.com/?a=topic&threadID=1093545

Konner Rasmussen

Posted 2018-01-18T04:03:11.387

Reputation: 449

"Would this work?" - No – Ramhound – 2018-01-18T05:04:40.667

Answers

6

There's an important misunderstanding in what symlinks do. Specifically, symlinks do not do this:

which would allow me a virtual copy that could be altered without changing the original.

[...]

My intention is to install an OS to one partition, make it read-only, and run the OS from a second partition which is simply a symlink to the read-only installation.

Even if you could boot across a symlink, it would not provide this "copy on write" feature.

Symlinks are nothing more than aliases to be used when following a path; e.g. you could place a symlink at C:\foo which tells the OS "look at D:\bar instead". That's it. Once the symlink is followed, all operations – whether reads or writes or deletions – will affect the original file equally.

(Hardlinks do even less. A "hard link" is literally just a file with two names (or more); for this reason, hardlinks cannot even cross a disk. And likewise, using any name will still alter the original file, without making a special copy. Only certain Linux filesystems support copy-on-write "reflinks".)


Instead, to have a read-only base, you could use one of the following:

  • Volume Shadow Copies are copy-on-write snapshots. The "System Restore" feature in Windows will allow restoring the OS to an old snapshot. (Unfortunately, there's no command to revert to a snapshot in full.)

  • There are third-party programs to "freeze / thaw" the OS, usually by using a special driver; they are popular in schools and libraries. They redirect all writes elsewhere so that you get a fresh OS after every reboot.

  • You can install the OS in a virtual machine; many VM software have support either for simple snapshots, or "differential disks", allowing you to revert the OS to an earlier state.

  • If you have two disks, just clone the whole thing – it doesn't take that long to copy ~20 GB of a Windows installation.

user1686

Posted 2018-01-18T04:03:11.387

Reputation: 283 655

Thank you for such an outstanding answer. So if I understand correctly, a symlink is very like a pointer in C++? I don't understand. My experience with symlinks it's through the game Eve. To run 2 accounts simultaneously on different screens and on a single machine it is necessary to have 2 installations. One set to default to display 1 and the other, display 2. The developers instruct to create a symlink of the game directory and set the configuration via in game menus. This contradicts what you have told me as it appeared the files that were changed were the bulk of the folders data size – Konner Rasmussen – 2018-01-18T13:52:37.253

Yes, it's exactly like a pointer. (Except dereferencing a dangling symlink doesn't make anything crash.) As for the game: a) If it saves configuration inside its game directory, then a symlink of that directory is useless. Although you could symlink each individual item (skipping config files) rather than whole directory at once. b) It is possible that the game saves its config elsewhere, but the config path is somehow based on the game path. Then a symlink would work. But it sounds somewhat unlikely. – user1686 – 2018-01-18T14:34:13.863

I looked through the forum posts, and EVE indeed does what I described in "b)" – it keeps the data/cache elsewhere, but decides the location based on where EVE itself was installed. So the method with junctions or symlinks works, but only because EVE was specifically written to accomodate it. – user1686 – 2018-01-18T14:36:11.743

Interesting. I am curious. Do you know of any way to produce the described effect short of manufacturing the hard drives myself? – Konner Rasmussen – 2018-01-18T14:57:22.887

For an entire OS? See the 2nd half of my post... – user1686 – 2018-01-18T15:59:56.760