Только что написав ответ о перемещении / usr в новый раздел , я подумал об удалении файлов после монтирования нового раздела. Чтобы использовать пример из вопроса, возможно ли смонтировать новый раздел в /usr
, а затем удалить все файлы в разделе /usr
в корневом разделе, чтобы освободить место в корневом разделе.
Не напрямую , но есть способ обойти это: mount --bind
ваш друг:
# Existing directory with a couple files in it
root@nkubuntu1004:~/test# ls testdir
bar foo
# Mount a filesystem over existing directory
root@nkubuntu1004:~/test# mount -o loop testfs testdir
root@nkubuntu1004:~/test# ls testdir
lost+found
# Bind mount root filesystem to another directory
root@nkubuntu1004:~/test# mount --bind / bindmnt
# Can now get to contents of original directory through the bind mount
root@nkubuntu1004:~/test# ls bindmnt/root/test/testdir/
bar foo
# Remove a file
root@nkubuntu1004:~/test# rm bindmnt/root/test/testdir/bar
root@nkubuntu1004:~/test# ls bindmnt/root/test/testdir/
foo
root@nkubuntu1004:~/test# ls testdir
lost+found
# Unmount filesystem
root@nkubuntu1004:~/test# umount testdir
# Observe the change having taken effect
root@nkubuntu1004:~/test# ls testdir
foo
root@nkubuntu1004:~/test#
См. Также man mount
- поиск по «bind mounts».