Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A Adding mount points to an existing partition that already has one

Yes, bind mounts or possibly rbind mounts is most likely what you want here. You need a rbind mount if you want the contents of file systems mounted below the specified mount point to be accessibl...

posted 5mo ago by Canina‭

Answer
#1: Initial revision by user avatar Canina‭ · 2024-06-16T14:23:17Z (5 months ago)
Yes, **bind mounts** or possibly *rbind* mounts is most likely what you want here.

You need a rbind mount if you want the contents of file systems mounted below the specified mount point to be accessible in the new location as well; you need a bind mount if you don't want or need that. Given the situation you describe in your question (`/` and `/home` separate, everything else in `/`), a bind mount should be exactly what you want.

As with any operation that makes large-scale changes, making sure to refresh your backups first is a good idea.

The easiest way to set this up is if you can tolerate shutting the system down. In that case:

- boot with live media (such that there is nothing running from the file systems you're working with)
- mount both file systems *in separate locations* (let's say that you mount your current `/` at /mount/root and `/home` at /mount/home); depending on partitioning, this can also include setting up MD RAID arrays, opening LUKS containers, or other steps to make the actual file systems accessible
- move (not copy) everything from (in this case) /mount/root/var/log to, say, /mount/home/var/log, making sure to preserve the permissions from both the original /var as well as /var/log; but *leave the original directory* (/mount/root/var/log = /var/log) in place
- update /mount/root/etc/fstab (that is to say, your main system's /etc/fstab) to include an entry on the form:

      /home/var/log /var/log none bind 0 0

- repeat for each file system you want to move
- reboot when done

Take it nice and slow; this isn't terribly complex, but you can easily cause mayhem if you aren't careful in matching up old and new locations, including permissions and ownership.

The fstab entry is on the usual "what where type options" form, with the options being `bind` and the file system type being irrelevant for a bind mount. See [mount(8)](https://man7.org/linux/man-pages/man8/mount.8.html) under the "bind mount operation" heading.

Doing the equivalent on a running system is *in principle* possible in much the same way, but requires significantly greater care regarding files that are in use, particularly ones being written to. I don't recommend going that route.

I don't see any particular reason why you'd need to do something special depending on exactly which directory you're moving.