Make the existing /srv/data tree visible at /opt/app/data without moving or copying it.
Use a bind mount for the directory tree.
Which command is appropriate?
mount --bind OLDDIR NEWDIR exposes the same directory tree at another mount point. It is not a copy, so both paths see the same content.
Detailed explanation
mount --move /srv/data /opt/app/dataIncorrect. --move relocates a mount rather than adding a second view.
Incorrect. --move relocates a mount rather than adding a second view.
mount --make-shared /srv/data /opt/app/dataIncorrect. --make-shared changes propagation properties and is not the bind operation.
Incorrect. --make-shared changes propagation properties and is not the bind operation.
mount --bind /srv/data /opt/app/dataCorrect. mount --bind /srv/data /opt/app/data creates the second view.
Correct. mount --bind /srv/data /opt/app/data creates the second view.
mount --all /srv/data /opt/app/dataIncorrect. --all processes fstab entries and does not take two directory arguments this way.
Incorrect. --all processes fstab entries and does not take two directory arguments this way.
Try it yourself
An example you can run in a temporary verification environment.
mount --fake --bind /srv/data /opt/app/dataExpected result
fake指定により実際にはbind mountせず予定処理を確認するKey points
- It is not a copy
- Both paths show the same data
- Use --bind
Notes
- Environment: util-linux mount 2.39以降
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.