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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
|
06-18-2012, 02:51 PM
|
#1
|
Member
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522
Rep:
|
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...
|
|
|
06-18-2012, 03:05 PM
|
#2
|
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
|
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
|
|
|
06-18-2012, 03:08 PM
|
#3
|
Member
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270
Rep:
|
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.
|
|
|
06-18-2012, 03:24 PM
|
#4
|
Member
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522
Original Poster
Rep:
|
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.
|
|
|
06-18-2012, 03:35 PM
|
#5
|
Member
Registered: Jul 2009
Distribution: Ubuntu, RedHat, VMWare, CentOS, Windows, Android, Mac
Posts: 55
Rep:
|
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 ...
|
|
|
06-18-2012, 03:45 PM
|
#6
|
Member
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522
Original Poster
Rep:
|
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.
|
|
|
06-18-2012, 03:52 PM
|
#7
|
Member
Registered: May 2012
Posts: 426
Rep: 
|
Quote:
Originally Posted by Steve W
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.
|
|
|
06-18-2012, 03:55 PM
|
#8
|
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
|
Quote:
Originally Posted by Steve W
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
|
|
|
06-18-2012, 06:52 PM
|
#9
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
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.
|
|
|
06-19-2012, 04:38 AM
|
#10
|
Member
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522
Original Poster
Rep:
|
>>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?
|
|
|
06-19-2012, 05:52 AM
|
#11
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,379
|
Nope.
There is no such thing as being "overcautious" with your data.
|
|
|
06-19-2012, 07:25 AM
|
#12
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
Quote:
Originally Posted by Steve W
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
|
|
|
06-19-2012, 11:04 AM
|
#13
|
Member
Registered: Mar 2007
Distribution: Linux Mint 18.1
Posts: 522
Original Poster
Rep:
|
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?
|
|
|
06-19-2012, 06:52 PM
|
#14
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
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
|
|
|
06-20-2012, 10:12 PM
|
#15
|
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
|
Quote:
Originally Posted by Steve W
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)
|
|
|
All times are GMT -5. The time now is 03:39 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|