-1

Lets say i want this directory structure on a SD card:

SD
├── log -> var/log
├── dbs -> var/db
└── desktop -> home/desktop

(its just an example)

This is so everytime a file goes into /var/log instead it goes to SD/var/log, how could i do that? i'm thinking about symbolic links but im not really sure and i didn't want to break my system.

I am right now using Ubuntu 22.04.3 LTS but if theres a solution for it and other Unix-like / linux systems please let me know. Im using it for everyday personal use (e.g. work, school, media, to learn programming, etc)

if you need any more info please ask in the comments and ill add that into the question

1 Answers1

1

This is so everytime a file goes into /var/log instead it goes to SD/var/log, how could i do that? I'm thinking about symbolic links but I'm not really sure and i didn't want to break my system.

If you mean on the system's level, then that's a very bad idea and it will break your system ... Some essential applications like e.g. APT will consider some symbolic links at e.g. /var/log as insecure/dangerous and will refuse to follow them thus resulting in errors or even not working at all.

Bind mounts on the other hand should work in most cases but again that might be acceptable on the user-space level but requires special care on the system level with e.g. /var/log and even though might still cause problems due to availability/connectivity/filesystem of your SD card so not advised and will affect all users and services system-wide as well which might yield unexpected results.

... So, bottom line, the above is not recommended and will in most cases break your system.

However, in your own userspace, you can modify/bind VFS mounts as you like with no effects on the other users/services by creating a filesystem namespace in a user-space (without sudo or root privileges) like e.g.:

bwrap --die-with-parent --bind / / --dev-bind /dev /dev --bind /SD/var/log /var/log \
--bind /SD/desktop /home/desktop --bind /SD/dbs /var/db -- /bin/bash

For more info, please see I want /ts to reference ~/.local/ts without root/admin privileges?

Raffa
  • 34,963