LinuxQuestions.org
Visit Jeremy's Blog.
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 06-18-2012, 02:51 PM   #1
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522

Rep: Reputation: 44
Restoring home directory


I'm helping a friend at the weekend to install Ubuntu on his laptop. It's the second time - I installed Ubuntu 12.04 for him last month, as a dual-boot, keeping his Vista on the primary partition as he didn't want to give up Windows completely.

Four weeks later, and he has decided he wants me to install it again, but covering the whole HDD - wiping out Windows. He says he still needs his Photoshop 6, but is happy to use it in Ubuntu with Wine.

Result! Another Linux convert.

However, I wanted to backup and restore his /home directory for him, so he doesn't need to re-do all his configs again once I've reinstalled. I have my /home on a separate partition, so restoring it to a new distro isn't something I've had to do before.

I was looking at Method 2 on here:

http://www.ubuntugeek.com/how-to-cop...ard-drive.html

I seem to remember that you cannot simply go onto the new installation and "overwrite" the existing /home with your backup, because some of the files will be in use and it won't let you.

If I simply use "Method 2" above, am I going to run into problems? Do I need to do sudo tar (etc) to unpack? It doesn't say...
 
Old 06-18-2012, 03:05 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
I would perform the restore while booted from a live cd
the biggest issue though isn't files being 'in use' as logging out and back in after doing the restore (if not done by a live cd) would take care of most of the issue
the biggest issue is proper ownership of the restored files, which can easily be fixed by booting into 'restore mode' ('rescue mode')

Code:
chown {user}:{user} -R /home/{user}
to make sure the current user with {user} owns their files
 
Old 06-18-2012, 03:08 PM   #3
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
What I did last time:

- become root (sudo will not do)
- wipe out tos (The Other System) using cfdisk to make it a Linux partition
- use mkext3fs (or similar) for that partition
- mount the new partition on /mnt/hd
- use 'mc' or similar to copy (NOT MOVE) the full /home to /mnt/hd
- rename /home into /oldhome
- mount <partition> /home
- change /etc/fstab accordingly

And that did it for me (with Slackkware, all from the command line). If people agree or disagree with this: please say so.
 
Old 06-18-2012, 03:24 PM   #4
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522

Original Poster
Rep: Reputation: 44
Code:
chown {user}:{user} -R /home/{user}
So, if his name was John, his home directory would be /home/john/, so I would do

Code:
chown john:john -R /home/john
In other words, without the braces { }?

And does that need a final slash after /home/john, or not?

Last edited by Steve W; 06-18-2012 at 03:25 PM.
 
Old 06-18-2012, 03:35 PM   #5
abi0909
Member
 
Registered: Jul 2009
Distribution: Ubuntu, RedHat, VMWare, CentOS, Windows, Android, Mac
Posts: 55

Rep: Reputation: 18
If you are going to be using up the whole HDD, why not use GParted or similar and format the Windows partition from Ubuntu? Then you can use that partition from Ubuntu right?

Why take the pain of fixing /home with the reinstall ...
 
Old 06-18-2012, 03:45 PM   #6
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522

Original Poster
Rep: Reputation: 44
You mean, leave Ubuntu in situ and use the vacant Windows partition as the new /home, or maybe use the vacant partitions as just "free storage space"? Well, the situation is that he didn't have much space for a Ubuntu install, and his root directory only has about 2GB remaining. If I used the vacant Windows space as a /home partition or extra storage space, he'd have around 115GB file storage but hardly any space to put new applications!

And the existing partitioning is slightly more complex than that. He has two Windows formatted partitions, one of which contains some kind of Vista "system restore" CAB files. So he's actually got two NTFS partitions taking up all the room.

I thought a fresh install, with /home inside his Linux partition, would be for the best. That way, he's free to either install loads of new apps, or put tonnes of files in his /home directory, and it would expand naturally to fill the whole of his HDD.

Last edited by Steve W; 06-18-2012 at 03:52 PM.
 
Old 06-18-2012, 03:52 PM   #7
nixblog
Member
 
Registered: May 2012
Posts: 426

Rep: Reputation: 53
Quote:
Originally Posted by Steve W View Post
I thought a fresh install, with /home inside his /root partition, would be for the best. That way, he's free to either install loads of new apps, or put tonnes of files in his /home directory, and it would expand naturally to fill the whole of his HDD.
Yep, keep it simple. Make sure his data is backed up 100% and just do a standard 12.04 install and use whole disk. No need to have a separate /home on a normal desktop or laptop.
 
Old 06-18-2012, 03:55 PM   #8
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Quote:
Originally Posted by Steve W View Post
Code:
chown {user}:{user} -R /home/{user}
So, if his name was John, his home directory would be /home/john/, so I would do

Code:
chown john:john -R /home/john
In other words, without the braces { }?

And does that need a final slash after /home/john, or not?
that is correct
 
Old 06-18-2012, 06:52 PM   #9
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
Steve it is fine how you plan to do it.

However I couldn't help but to react on what you said "files might be in use". Altough Windows locks every file it thinks is no user's business, even for reading, you can happily copy Linux file systems on running installation as you desire.

So in your case, you could have wiped Windows, create a number of new partitions, and copy the complete Ubuntu into those partitions from the same running Ubuntu you already have. Then check the copied fstab to make sure the UUID's were set right to the new partitions.

Mostly I do this on a empty hard disk running a Live distro, but the source machine is usually running its own OS. Makes it easier to gain access. I have even done that on a running target machine.

My favorite tool is rsync which can preserve ownerships and links, and makes a real image on file level. (not on byte level)

Of course you should use common sense while copying a live system, and preferably stop running databases or running mail servers.

Like I said, proceed as you proposed, but it might be a nice exercise to experiment with during a rainy weekend and see how far you get.

jlinkels

Last edited by jlinkels; 06-18-2012 at 06:54 PM.
 
Old 06-19-2012, 04:38 AM   #10
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522

Original Poster
Rep: Reputation: 44
>>you can happily copy Linux file systems on running installation as you desire.

Oh. I didn't realise that. So people who do such Home directory restores using a live distro are being overcautious then?
 
Old 06-19-2012, 05:52 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,379

Rep: Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190
Nope.
There is no such thing as being "overcautious" with your data.
 
Old 06-19-2012, 07:25 AM   #12
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
Quote:
Originally Posted by Steve W View Post
Oh. I didn't realise that. So people who do such Home directory restores using a live distro are being overcautious then?
If I said "yes they are" it would not end this discussion for the next few weeks. Like with most things you must know what you are doing. If you are logged in as root and only as root, the entire /home is not being used by anyone, not even root.

For example, if one of your users is running a GUI like KDE and the GUI is active, you might copy the desired config files, and overwrite them again with the current configuration when logging out which is probably not desired.

But there is no such thing as the dreaded file and registry locking.

jlinkels
 
Old 06-19-2012, 11:04 AM   #13
Steve W
Member
 
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522

Original Poster
Rep: Reputation: 44
The phrase "logged in as root" is a bit confusing with Ubuntu. I think you log in as a user, but can get superuser privileges with sudo. The senior member above commented about "booting into 'restore mode' ('rescue mode')" which I presume is the one I see in my GRUB list at bootup time. Does booting into that (which I never have done) automatically boot you in with Root privileges then?
 
Old 06-19-2012, 06:52 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434

Rep: Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790
Well, in RHEL/Centos etc 'rescue mode' would be

1. boot off install media CD/DVD
2. instead of choosing an install option type 'linux rescue' and <enter>

This causes the HW to boot off the install media as root (bit like a live cd option) and mount your HDD(s) as purely data drives ie not as part of the running OS.
You can then fix stuff ...

Not sure if you can do that on Ubuntu, but no harm in trying.

This is different to going into single user mode in the normal OS, either by
Code:
telinit 1

# ubuntu
sudo telinit 1
http://linux.die.net/man/8/telinit

or similarly by editing grub during boot

Last edited by chrism01; 06-21-2012 at 12:46 AM. Reason: typo
 
Old 06-20-2012, 10:12 PM   #15
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Quote:
Originally Posted by Steve W View Post
The phrase "logged in as root" is a bit confusing with Ubuntu. I think you log in as a user, but can get superuser privileges with sudo. The senior member above commented about "booting into 'restore mode' ('rescue mode')" which I presume is the one I see in my GRUB list at bootup time. Does booting into that (which I never have done) automatically boot you in with Root privileges then?
a bit late on the draw for the anser perhaps, but in response to your query,booting into rescue mode boots you into 'single user' mode, that is to say the linux equivalent of 'safe mode', which isn't 'logged in' per-se (it's single user mode, logged in implies a multi user system, but that is neither here nore there) and yes, you have root access (no point using a limited user)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
restoring ONLY the home directory from a complete tar backup irishbitte Linux - Server 5 11-11-2008 08:24 AM
contents of 'home' directory found at sda5: mounted as /home, and also on sda6:/home leswatson Linux - Newbie 4 04-18-2008 04:02 PM
restoring desktop directory in /root (or any home directory) mel_lai Linux - Newbie 3 02-04-2008 03:13 AM
restoring permissions to my home bl0tt0 Slackware 1 12-06-2006 07:01 PM
Restoring Home Directory Ownership taylortbb Linux - General 1 08-27-2004 09:40 AM

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

All times are GMT -5. The time now is 03:39 PM.

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