Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
Is it possible to merge two HDDs together without losing data or it depend on the partitioning types (LVM or...)?
Thank you.
Sort of.
It depends on what you are trying to do.
Linux has what is called an "overlay" file system (overlayfs), that allows the appearance of a merger of two filesystems.
The end result LOOKS like a single filesystem, but any new data goes to the upper most filesystem (the one that overlays the other).
I haven't used that one - but have used one similar (unionfs), and found it very handy for migrating from one filesystem to a newer/larger one. Any file modified or updated is copied to the top level filesystem, and the older file left on the original (it can even be mounted read only). So over time files used move to the upper filesystem. Older files remained on the base filesystem. In my case, after some days of using it, any older files could then be manually transferred to the upper filesystem (for busy filesystems, there wouldn't be many of these), thus saving time by not removing access until the transfer is finished.
True (although "shortcut" is a Windows term, not UNIX or Linux), but it can be used for combining the content of two disk drives. If you want different answers, clarify what you mean by "merge".
And there's me thinking cant you copy contents of Drive A to Drive C and then copy Drive B to Drive C, which gives you a third drive containg the files from A and B. Instead of complicating the answer.
If you start using different filesystems, make sure you have good backups prior to the operation. Using a high tech solution isn't always the best way.
This might be even easier. Rsync Drive B to Drive A. Merges everything onto Drive A, avoids overwriting (almost) everything, and does not require a 3rd drive.
No matter how it is done, the merge is done on the file system and contents contained on the drive, not on the drive itself.
Thank you.
With the UnionFS file system, Can I merge two HDDs and see them as a single drive?
As has already been stated, merging the drive is not what will happen and really cannot be done. Merging the content of the filesystem is simple and commands to do so has already been given.
The way I picture it, your request to merge a drive would be similar to using LVM and adding a physical drive to the VG so there was additional space available to use for a filesystem / partition to grow. LVM sees the VG as one larger virtual drive that may have one or many actual physical disks and the VG then has LVs seen as partitions to contain the file systems.
Another way to "merge" drives could be to use a raid array so the array is seen as a "new" larger device.
Neither of those methods can be done from scratch while keeping existing data intact on the drive, although once the "new" device is created the data can be put back. Expanding the virtual device, either LVM or some types of raid can usually be done without harm to the data, but creating new cannot.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,813
Rep:
Quote:
Originally Posted by n00b_noob
Hello,
Is it possible to merge two HDDs together without losing data or it depend on the partitioning types (LVM or...)?
Thank you.
If you're thinking of a solution that treats the two disks as a single physical device (one that only requires a single entry in /etc/fstab) you'd need to combine the disks by creating a RAID0 (striped) device. However, and I can't stress this strongly enough, this would destroy any data on the disks---you'd need to backup both disks to additional devices before proceeding. I do not recommend this.
If you're looking for a solution that lets you do something like issue a simple "find" command and have it hit both disks, I'd suggest setting up a symbolic link for each device in your home directory (or wherever you like). Example: You have a disk configuration like:
and you want to be able to see the "mydata" and "otherdata" as part of "/home/n00b_noob", simply issue:
Code:
$ cd
$ ln -s /mydata .
$ ln -s /otherdata .
$ file mydata otherdata
mydata: symbolic link to /mydata
otherdata: symbolic link to /otherdata
Once those symbolic links are in place, the contents of "/mydata" and "/otherdata" appear to be in subdirectories under $HOME.
NOTE: Depending on what's on those two devices, you may run into permissions problems when trying to access/modify directories and files under $HOME/mydata and/or $HOME/otherdata. Just because those symbolic links live under your home directory doesn't give you blanket access to the filesystems they point to.
IMHO, this is the simplest means of accessing the data on those two disks as though they were part of a single device. And it a.) can be done in less than a minute and b.) places no danger to the contents of either device. Careful, though: You can modify/delete the data on those device now that they appear to be part of the filesystem in which you've created the symbolic links.
As opposed to continually asking for more clarification for each possible answer, I think you ought to be far more detailed and clear about your needs and intentions.
If these are two entirely data disks, then that's one thing. If these two disks contain system files, then there probably will be repercussions to any merge action, unless you are cognizant of this fact and do not intend to necessarily use an outcome as a system disk.
An example for data drives would have some details like:
Two different Linux installs.
Two user accounts, same or different names.
Data from those accounts that you wish to merge.
Possible scenario:
User trees are usually similar, Documents, Downloads, and etc.
A graphical file manager, and certainly a cp or rsync command can copy from A to C, and then next from B to C with A and B being the two sources and C being the destination.
When you perform the B to C copy, you can specify to skip duplicates, or overwrite duplicates.
A possible issue is that you do have duplicate file names where the actual files have different contents.
But if it's all about pictures, videos, audio, downloaded content, I'd wager that any intersections would be pure duplicates.
But the open-ended question here is not helpful. And just to remind, but this subject has been brought up before from either Jeremy or another moderator. Please try to be more descriptive and provide better updates when you form questions and add replies to them. Also be cognizant that running any command without fully understanding what it can do to your system is not the first, best idea.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.