I have a partition structure as follows:
/dev/sdc1 => Partition 1 ( My OS. [ Linux flavour ] )
/dev/sdc2 => Partition 2 ( This contents some data. )
/dev/sdc3 => Partition 3 ( This also contents some data. )
/dev/sdc4 => Partition 4 ( I want this as a deciding partition. )
I am trying to mount partition 2 or partition 3 dynamically depending on the file present in partition 4.
For example:- Partition 2 will be mounted if partition 4 consists of a file named two
. Partition 3 will be mounted if partition 4 consists of a file named three
.
Note:- This partition will never be mounted together i.e. if Partition 2 is mounted partition 3 will be not be mounted until partition 2 is unmounted. Thus I can use a common directory for both partitions.
As I have systemd available on my os I can write a startup script which can read from partition 4 and mount the appropriate partition at boot and write the partition record into /etc/fstab.
But according to my understanding fstab is critical file and if any failure happens or fstab get's corrupt it's going to stop the system from booting.
Question:
Now what I am trying to achieve is can I add an entry in fstab which will read dynamically partition 4 and add the entry for partition 2 or partition 3 depending on the file that exists in the partition 4.