[SOLVED] Best way move/copy HOME to different partition for reinstallation

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
Post Reply
chen_ww
Level 1
Level 1
Posts: 5
Joined: Mon Jun 25, 2018 7:59 pm

[SOLVED] Best way move/copy HOME to different partition for reinstallation

Post by chen_ww »

I am using Linux Mint 18.3 XFCE x64 on a Ryzen 3 1300X, with an SSD (sdb) as / (system) and HDD (sda) as /home. My SSD died but my HDD is still intact with /home still accessible when I boot with a Live USB. I'm getting a new HDD and plan to create 2 partitions on it ... 1 for / and 1 for a new /home. My plan is to just rsync the contents of old /home to this new /home with all my configurations intact. Will this work? Is there a better way?
Last edited by chen_ww on Thu Jul 05, 2018 7:41 am, edited 2 times in total.
User avatar
WharfRat
Level 21
Level 21
Posts: 13909
Joined: Thu Apr 07, 2011 8:15 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by WharfRat »

Hello chen_ww Image

Welcome to Linux Mint and the Linux Mint forum :)

rsync is a good way to go. Use the -a (archive) option which is recursive and preserves owner:group, permissions and modified time etc.

Good luck :wink:
ImageImage
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Best way move/copy HOME to different partition for reinstallation

Post by catweazel »

chen_ww wrote:
Mon Jun 25, 2018 8:22 pm
Will this work? Is there a better way?
rsync will work fine, but if home is on its own partition you can also use Clonezilla live to backup that partition in its entirety. Clonezilla takes a little getting used to but it's worthwhile.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
rene
Level 16
Level 16
Posts: 6689
Joined: Sun Mar 27, 2016 6:58 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by rene »

If rsync please be careful that you rsync your home directory/ies though. Most configuration is stored in "hidden" files (dot-files) in your home and a somewhat frequent issue is people using e.g. rsync -av /home/foo/* /dst; this misses all dot-files due to the shell rather than rsync expanding the * and it not (by default) including dot-files.

That is, with your old /home mounted on /mnt, something like rsync -av /mnt/ /home/. You'll want to do so with the same users pre-created on the new system as on the old and all of them logged out; therefore, from a text console root login which also means you'll first need to enable root login: sudo passwd root. Then log everyone out, Ctrl-Alt-F1 from the graphical login screen to a text console, login as root, rm -r /home/* to delete the new home directories, the above rsync command, passwd -d root if you want to disable the root password again, exit to logout, Ctrl-Alt-F7 back to the graphical login screen.
chen_ww
Level 1
Level 1
Posts: 5
Joined: Mon Jun 25, 2018 7:59 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by chen_ww »

rene wrote:
Mon Jun 25, 2018 10:18 pm
If rsync please be careful that you rsync your home directory/ies though. Most configuration is stored in "hidden" files (dot-files) in your home and a somewhat frequent issue is people using e.g. rsync -av /home/foo/* /dst; this misses all dot-files due to the shell rather than rsync expanding the * and it not (by default) including dot-files.

That is, with your old /home mounted on /mnt, something like rsync -av /mnt/ /home/. You'll want to do so with the same users pre-created on the new system as on the old and all of them logged out; therefore, from a text console root login which also means you'll first need to enable root login: sudo passwd root. Then log everyone out, Ctrl-Alt-F1 from the graphical login screen to a text console, login as root, rm -r /home/* to delete the new home directories, the above rsync command, passwd -d root if you want to disable the root password again, exit to logout, Ctrl-Alt-F7 back to the graphical login screen.
Thanks for the warm welcome AND the tip rene! Will definitely take note of those hidden files :D
chen_ww
Level 1
Level 1
Posts: 5
Joined: Mon Jun 25, 2018 7:59 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by chen_ww »

catweazel wrote:
Mon Jun 25, 2018 9:48 pm
chen_ww wrote:
Mon Jun 25, 2018 8:22 pm
Will this work? Is there a better way?
rsync will work fine, but if home is on its own partition you can also use Clonezilla live to backup that partition in its entirety. Clonezilla takes a little getting used to but it's worthwhile.
Will have a look at Clonezilla ... thanks for the suggestion, catweazal! :D
User avatar
Sir Charles
Level 7
Level 7
Posts: 1895
Joined: Thu Jan 04, 2018 1:00 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by Sir Charles »

You could use Gparted as well from a Linux Mint Live USB. Copy the partition where the old /home resides and paste it onto a new partition
(or un-allocated space) on the new drive.
Have a look at: https://gparted.org/display-doc.php%3Fn ... -partition
I suppose that's one of the ironies of life, doing the wrong thing at the right moment -C.C.
chen_ww
Level 1
Level 1
Posts: 5
Joined: Mon Jun 25, 2018 7:59 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by chen_ww »

Marziano wrote:
Tue Jun 26, 2018 2:36 am
You could use Gparted as well from a Linux Mint Live USB. Copy the partition where the old /home resides and paste it onto a new partition
(or un-allocated space) on the new drive.
Have a look at: https://gparted.org/display-doc.php%3Fn ... -partition
Different partition sizes but thanks for the tip and link, Marziano! :D
User avatar
AndyMH
Level 13
Level 13
Posts: 4743
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Best way move/copy HOME to different partition for reinstallation

Post by AndyMH »

As an alternative to clonezilla have a look at redo.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
galaxy0815

Re: Best way move/copy HOME to different partition for reinstallation

Post by galaxy0815 »

chen_ww wrote:
Mon Jun 25, 2018 8:22 pm
I'm getting a new HDD and plan to create 2 partitions on it ... 1 for / and 1 for a new /home.
My plan is to just rsync the contents of old /home to this new /home with all my configurations intact. Will this work? Is there a better way?
You can use mc. This terminal application could also be used with live rescue dristributions like systemrescuecd. By the way systemrescuecd has xfce installed. It could run from RAM. With kernel parameter 'docache'. In RAM the system runs faster.

First step mount your partitions. Second step start mc in terminal window. Then select your mounted partitions and press F5. A request "window" will popup. If partitions are mounted with the same name, all the files in the source directory will be copied unchanged and complete into the destination directory by selecting e.c. 'home' of both sides. BUT you must format the new partition to make it clean and empty. Otherwise source files will be added or will overwrite existing files.

Example:

Code: Select all

$ sudo mkfs.ext4 /dev/your_new_partition
$ sudo mkdir /mnt/src/home -p
$ sudo mkdir /mnt/dest/home -p
$ sudo mount /dev/your_old_partition /mnt/src/home
$ sudo mount /dev/your_new_partition /mnt/dest/home
$ sudo mc #does the rest
With systemrescuecd you don't need 'sudo' because you are root.

On Debian/Ubuntu/Mint mc isn't installed by default. Do this in Terminal:

Code: Select all

sudo apt-get install mc
ugly
Level 4
Level 4
Posts: 360
Joined: Thu Nov 24, 2016 9:17 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by ugly »

Maybe this should be in another topic, but when upgrading from LM 18 to LM 19 (or another distro entirely), are there any files under /home that should not be copied over?
User avatar
Flemur
Level 18
Level 18
Posts: 8726
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Best way move/copy HOME to different partition for reinstallation

Post by Flemur »

chen_ww wrote:
Mon Jun 25, 2018 8:22 pm
I'm getting a new HDD and plan to create 2 partitions on it ... 1 for / and 1 for a new /home. My plan is to just rsync the contents of old /home to this new /home with all my configurations intact. Will this work? Is there a better way?
That would work.

Since the new /home/username will be close to empty, even simpler would be:

Code: Select all

rm -r /home/username
cp -ax /oldhome/username /home/username
Assuming same username and same UID (=1000 for first or only user added).

I can't see any reason to make the process complicated by copying partitions....

Edit: Or, rather than

Code: Select all

rm -r /home/username
do

Code: Select all

mv /home/username /home/username.save
so you'll have the Mint 19 default files around, just in case.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
AZgl1500
Level 14
Level 14
Posts: 5217
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes sweeping down the plains
Contact:

Re: Best way move/copy HOME to different partition for reinstallation

Post by AZgl1500 »

. Since you are going to do a New Install...............

Here is how I did it and it worked perfectly.

I created an Aptik backup file to a extUSB HDD of the laptop this morning.
it had a broken display and 500gB HDD and both were to be replaced.

After replacing the HDD with a SSD and installing the new display,
I used a flash drive ISO to make a fresh install to the SSD including using "Something Else" to create the new partitions that I wanted.
/
/home
/backup
/swap

previously the laptop had a typical "erase disk" install, so the new setup would be different with new locations....

Aptik is a Smart Genius of an App. It restored the new SSD install to exactly the way it was on the HDD even though the partitions are in different places now.

From start to finish, the install and Aptik took less than 1 hour and 30 minutes.
And all of the updates were included, Update Manager had a Checkmark on it after the install was done.

you can't beat that.

The only 'hard part" was installing Aptik and Aptik-gtk after the Fresh Install was done.
Linux Mint 19.3 Cinnamon
Photojoe4
Level 1
Level 1
Posts: 8
Joined: Mon Mar 12, 2018 6:15 pm
Location: Portland, OR

Re: Best way move/copy HOME to different partition for reinstallation

Post by Photojoe4 »

If you're just installing a new SSD for your root partition, you should be able to install from the live usb without changing the home partition. When it gives you the option to "erase all" or "something else" select "something else". Then just make your root and swap partitions on the new ssd, and mount your hdd as "home" and make sure the box is unchecked next to "fomat" for this partition.

If you're replacing both drives with new ones, you could set it up the same way, just check "format" next to all of them. Then you can install grsync (it's the gui for rsync) and sync your old /home drive to the new one.

You may have already done this, but I'd also suggest backing up your /home drive once you have it back up and running so that if THAT drive fails you don't lose too much data. If you use the "backup tool" to backup your applications to your /home drive it will be a piece of cake to restore your system (and upgrade it).
galaxy0815

Re: Best way move/copy HOME to different partition for reinstallation

Post by galaxy0815 »

ugly wrote:
Sun Jul 01, 2018 2:33 pm
Maybe this should be in another topic, but when upgrading from LM 18 to LM 19 (or another distro entirely), are there any files under /home that should not be copied over?
First answer is no. :-)

But if you are using some applications it should be useful to save directories and files, to copy it to the new home folder.

For applications like:
Mozilla Firefox and any other browser
GKrellM
Zim
Osmo
Recoll
email clients
music players

because there are often data in it you have edited e.c. all your bookmarks for Firefox.
Since a decade I'm copying the whole .mozilla folder on a stick. There is every data in it you know from the graphical user interface. You only must be shure to use the same UID/GID or you set it like

Code: Select all

chown YOUR_UID:YOUR_GID .mozilla -R
If your email folder is inside the home folder it's quite the same. Maybe to import your mail data is better. But you can try to use the files from here. If your mail client has an export function use this.

Before I installed LM19 I saved all the folders inside my home folder which I found and all of data inside .config folder and also some data in .cache for my applications. And all the applications I'm using where all much newer, and all where running out-of-the-box with LM19. Nothing lost from the applications I used with LM18.3.

But only data of my applications I have copied. Nothing from the DE. So I could be shure that the desktop is clean. There are a lot of configurations where something has changed inside two years.

It should be an idea to copy all your data onto an USB stick. If you are familiar with a scripting language you can write a backup job. Or use mc and copy complete folders including .config folder from your home folder. If you are copying to the new disk, do first copying with mc without renew files and then install additionallly your apps. This is the easyest way to transport your configurations. I do this for many years and have had only a few problems.

Please note: there are many cached data e.c. from your mail client. This could be much data you don't need. Also plenty thumbnails. Please forget them. They will be rebuild on the new system. Cached data could be in .cache folder or in the folder of your application. Only the cache inside .mozilla folder you can leave unchanged. This cache is configurable in the browser setttings.
chen_ww
Level 1
Level 1
Posts: 5
Joined: Mon Jun 25, 2018 7:59 pm

Re: Best way move/copy HOME to different partition for reinstallation

Post by chen_ww »

Thanks, everyone for the suggestions ... :D I wanted to share my experience thus far.
I ended up installing Linux Mint 19 XFCE as a single partition on my 500GB SSD. I figured I have the flexibility of install any and all apps, changing swapfile sizes, storing Timeshift stuff, having a 'safer' /home for critical data and better performance than a HDD. The catch is that /home will need to be backed up regularly and especially when an OS reinstall or upgrade is required. Limited to 500GB, so I think I can live with that.

My previous Linux Mint 18.2 XFCE installation last year, was haphazard as I was learning to use it. This time around with Linux Mint 19, I decided to go for a clean install experience so no complete rsync or clone of the old /home to the new /home. Instead, I opted to slowly copy required config files from old /home config files ... for apps like Double Commander (which took me a while to customize my desired look-and-feel), Firefox profile, some created launchers etc. It was tedious but easier than expected. No issues with ownership or permission and enabling 'Show Hidden Files' on Thunar was a great idea!
So far so good ... I also learnt the value of backing up /etc ... and was able to reuse my Samba configs etc.
Going forward though ... for Linux Mint 2x (?), I'd probably do a complete rsync of old /home to new /home or a direct clone :lol:
Again, thanks to all for the many suggestions ... keeping them on file for future reference ... :D
User avatar
Pierre
Level 20
Level 20
Posts: 10839
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: Best way move/copy HOME to different partition for reinstallation

Post by Pierre »

so, I've had this issue before, and my HDD is still intact with /home is still accessible,
- when I boot with a Live USB, and use it's Gparted program to see that my /home is still there,
and so use that same Gparted program to copy & paste that /home partition onto another HDD,
but, after I've pre-partitioned that new HDD with some partition(s) by using that same Gparted program.
8)
works well indeed.

then install that New System via the 'something else' option . .
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
Post Reply

Return to “Installation & Boot”