Is it possible to mount 2 disks into one directory?
Hi, so basically I have 1 partition (sdb4) coming from sdb that is mounted to /home where all my data is suppose to be stored. I realized I was running out of storage so I decided to use my sda which is my extra disk, as my storage. So I mounted sda1 to /home and transferred all of my data to it. I was afraid that something might break if I don't remove the entry of sdb4 in /etc/fstab. So right now my sdb4 is unmounted. I'm just curious if it's actually possible to mount partitions on the same mount point from 2 different disks.
About this post
- Posted
- Archived
- Score
- 1 · 100% up
- Kind
- Text
- ID
- 1bc8acy
24 comments
No, but you could mount one to a subdirectory within the other
You can mount multiple things to the same mount point simultaneously. It just makes tracking down what the heck is happening difficult.
I see, I didn't know you could do that too.
Did you install arch? Because typically you mount a partition at /mnt and another at /mnt/boot
This isn't quite true, you can with an overlay mount. Then you'll have a lower directory, that contains what was in there, and an upper directory where any changes will be stored.
Also technically you can make one regular mount and then mount another device on the same place but it will just hide everything from the first mount; I mention it only for pedantry's sake.
Sure, but for OP's usecase that's not great
LVM is the solution to this problem.
First time I've heard of LVM, I'll try to look into that as well. Thanks a lot!
It's a good idea to set even a single-drive system up with it. That way you avoid the problem you see people repeatedly post about when they realise they didn't allocate enough space to their system partition and now want to know if they can safely resize their partitions 1: after creating the ESP and deciding whether you want a separate /boot partition, set the entire rest of the drive up for LVM, allocate just enough for each of the different things you need (/ and /home, for instance) and simply allocate extra storage from the pool to each as necessary - need an extra 100GB for /home, add it from the 400GB (if not more) at your disposal ... then, later, when you find you need an extra 20GB for the system itself, you just add it, instead of having to back up your data elsewhere, resize your partitions, cross your fingers, reboot and pray it a) worked and b) you won't have to do it all again, when you find (a few months later) that you still didn't allocate enough to the system.
___
1 The answer is always a qualified 'yes', because you can always lose data when changing the partition boundaries - it's never a 100% risk-free operation.
Seconded. If you're drives are setup as LVM physical volumes, you can just add a new drive to the logical group and expand into it.
RAID, singles or expanded volumes. The exact features available to you will depend on the filesystem used.
Thanks! I'll look into it
I currently run Mergerfs which works perfectly fine for my case. I specifically wanted a Filesystem that would not break if one disk failed, like it would for a simple spanning array in lvm.
There are also other ones: https://wiki.archlinux.org/title/File_systems#Stackable_file_systems
Here is somebody asking for some differences: https://unix.stackexchange.com/questions/382326/unionfs-vs-aufs-vs-overlayfs-vs-mhddfs-which-one-do-i-use
Not without something exotic like UnionFS.
The better strategy is simply to have your /home directory mounted on the extra disk. There's no stipulation that /home has to be the same disk as root.
For example on my system, /home does exist on my root drive, but folders like /home/Documents, /home/Pictures, etc, all link to my /mnt/Extended/Nextcloud folder, which is on a separate disk. That disk gets synced with my homeserver, so I can do data-only backup-and-wipes on a semi-regular basis.
Oh that's interesting, I'll look up UnionFS. Thanks for answering! I didn't know it was actually better to have /home directory mounted on the extra disk, at first I thought I should've just gotten a single disk with bigger storage as an alternative. Rather than mounting it to another one.
Yeah of course.
There's not really a better or worse way to do things like this, it just depends on where you want your data and how your drives are structured. If you've got a fast, small drive and a large, slow drive, mounting /home elsewhere can save a lot of space, if you generate a lot of user files.
I personally find my /home directory doesn't get that big; the vast majority of my storage these days is games. So I have my steam directory cordoned off on a separate disk.
UnionFS is deprecated - the kernel native alternative is OverlayFS.
But, as I said, LVM is a more suitable solution - as much as anything else, union filesystems leave all but the topmost later unwritable, so you won't gain any space, nor will you be able to save files to any other locations within the union (it gets complicated to maintain, if not outright messy, if you need to modify or delete anything below the topmost layer).
RAID 1?
Thanks! I'll look into it
Not simultaneously. But you definitely can mount something different, one at a time, onto the same point in your directory tree.
I see, thanks!
You can mount thing over each other simultaneously, it just does not merge the fs's.
Others have provided some good advice. I was thinking this would be a good candidate for the newer bcachefs.
You can mount one thing over another thing so if fstab mounts /dev/sda1 to /home and then mounts /dev/sdb1 to /home, you will effectively have /dev/sdb1 mounted at /home. Things get tricky if you mount one thing at /mnt open some files and then mount something else there. Unless you know what you are doing you should avoid mounting things on top of each other.