Habiendo escrito una respuesta sobre moviendo/usr a una nueva partición Me preguntaba si borrar archivos una vez que se haya montado una nueva partición. Para usar el ejemplo de la pregunta, ¿es posible montar una nueva partición en /usr
y luego eliminar todos los archivos debajo de /usr
en la partición raíz para liberar espacio en la partición raíz.
No directamente, pero hay una forma de evitar eso: mount --bind
es tu amigo:
# Existing directory with a couple files in it
[email protected]:~/test# ls testdir
bar foo
# Mount a filesystem over existing directory
[email protected]:~/test# mount -o loop testfs testdir
[email protected]:~/test# ls testdir
lost+found
# Bind mount root filesystem to another directory
[email protected]:~/test# mount --bind / bindmnt
# Can now get to contents of original directory through the bind mount
[email protected]:~/test# ls bindmnt/root/test/testdir/
bar foo
# Remove a file
[email protected]:~/test# rm bindmnt/root/test/testdir/bar
[email protected]:~/test# ls bindmnt/root/test/testdir/
foo
[email protected]:~/test# ls testdir
lost+found
# Unmount filesystem
[email protected]:~/test# umount testdir
# Observe the change having taken effect
[email protected]:~/test# ls testdir
foo
[email protected]:~/test#
Vea también man mount
- busque "monturas de enlace".