Let's say I have a HDD with one partition at /dev/sdb1 with the following contents:
% sudo mount /dev/sdb1 /mnt
% cd /mnt
% ls
osA/ osB/
% ls *
osA:
bin boot/ dev/ etc/ home/ lib lib64 lost+found/ mnt/
opt/ proc/ root/ run/ sbin srv/ sys/ tmp/ usr/ var/
osB:
bin boot/ dev/ etc/ home/ lib lib64 lost+found/ mnt/
opt/ proc/ root/ run/ sbin srv/ sys/ tmp/ usr/ var/
I'd like to somehow have the directory osA on /dev/sdb1 mounted as / during boot through /etc/fstab (possibly) and to be able to change that later to be osB if I need that. I'd like this done on ext4 fs (if possible). Is this doable?
Another way of wording:
I'd like a partition to host multiple "root file system directories" and to be able to mount either directory to be / at boot time.
I always dedicated a whole partition to /. Not sure how to go about it when it's a subdirectory on a partition.
My current /etc/fstab entry (whole partition is dedicated to /):
UUID=0a7baeae-857d-11eb-8dcd-0242ac130003 / ext4 rw,relatime 0 1
I'm running Archlinux.
Motivation:
- Sometimes I have to reinstall the system because of problems with the package manager. Thought that perhaps this approach could be quicker than setting everything up from scratch, with a way to go back to previous setup.
- Seeing this as a possible way to try distributions and package managers by just switching what
/is mounted to - By having only one partition on
/dev/sdbI would not have to resize OS and data partitions, could just have data as a "data" folder alongside "osA" and "osB"
Edit1:
If you have suggestions on how I could ask the question more clearly - please let me know.
These questions seem somewhat related although the first one seems to delve into some unrelated things, second received no answer, checking third: 39423 374806 206493 613179
I think I'm looking to see if I can bind-mount / in /etc/fstab once /dev/sdb1 is already mounted somewhere (never done this before, don't know if it will work - can try this and post results - insights welcome).
Edit2:
Realised that to bind-mount I need a mount point first, and can't have one without the / itself.