LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-30-2021, 03:18 AM   #1
n00b_noob
Member
 
Registered: Sep 2020
Posts: 436

Rep: Reputation: Disabled
Post Merge two HDDs without losing data.


Hello,
Is it possible to merge two HDDs together without losing data or it depend on the partitioning types (LVM or...)?

Thank you.
 
Old 01-30-2021, 04:09 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 970

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
No.
 
Old 01-30-2021, 04:26 AM   #3
n00b_noob
Member
 
Registered: Sep 2020
Posts: 436

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lvm_ View Post
No.
Thus, it just possible for partitions?
 
Old 01-30-2021, 04:55 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by n00b_noob View Post
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.

https://en.wikipedia.org/wiki/OverlayFS

https://www.kernel.org/doc/html/late...overlayfs.html

Last edited by jpollard; 01-30-2021 at 04:56 AM. Reason: added references
 
1 members found this post helpful.
Old 01-30-2021, 05:04 AM   #5
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,509

Rep: Reputation: Disabled
Quote:
Is it possible to merge two HDDs together without losing data
In its simplest form, yes - use links - see man ln for details.
 
Old 01-30-2021, 05:20 AM   #6
n00b_noob
Member
 
Registered: Sep 2020
Posts: 436

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
In its simplest form, yes - use links - see man ln for details.
"ln" make a shortcut!!!
 
Old 01-30-2021, 10:33 AM   #7
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,509

Rep: Reputation: Disabled
https://man7.org/linux/man-pages/man1/ln.1.html

(That's a lower case L & N)
 
Old 01-30-2021, 11:54 AM   #8
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by n00b_noob View Post
"ln" make a shortcut!!!
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".
 
Old 01-30-2021, 12:03 PM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,665

Rep: Reputation: Disabled
Quote:
Originally Posted by lvm_ View Post
No.
UnionFS.
 
Old 01-30-2021, 02:14 PM   #10
v00d00101
Member
 
Registered: Jun 2003
Location: UK
Distribution: Devuan Beowulf
Posts: 514
Blog Entries: 1

Rep: Reputation: 37
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.
 
Old 01-31-2021, 10:01 AM   #11
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
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.
 
Old 02-11-2021, 10:49 AM   #12
n00b_noob
Member
 
Registered: Sep 2020
Posts: 436

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
UnionFS.
Thank you.
With the UnionFS file system, Can I merge two HDDs and see them as a single drive?
 
Old 02-11-2021, 11:11 AM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by n00b_noob View Post
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.
 
Old 02-11-2021, 11:57 AM   #14
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,813

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by n00b_noob View Post
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:
Code:
$ cat /etc/fstab
/dev/sda1   /             ...
/dev/sdb1   /home         ...
/dev//sdc1   /mydata      ...
/dev/sdd1    /otherdata   ...
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.

HTH...
 
Old 02-11-2021, 12:56 PM   #15
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i merge two ext2 linux partition without loosing any data amitkjain_crld Linux - General 6 12-24-2022 01:04 AM
Merge two partitions without losing data. hack3rcon Linux - Newbie 15 12-31-2018 12:59 AM
[SOLVED] Installing two different dsitros on two different HDDs faizlo Linux - Software 3 04-20-2012 07:21 PM
How to merge two directories without losing data riteshanand40 Linux - Newbie 1 05-18-2009 06:17 AM
Accessing other HDDs/Booting from other HDDs Namatacka Ubuntu 2 05-07-2006 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration