Howto: Move /home and secure your files and configuration
I see many people here in this forum which have problems with their system after they install software, drivers or patches. It's hard to tell what causes these problems and hard to solve them. Sometimes some of us loose our beloved configuration which we have spent a long time to tweak and perfectionize. ...Frustrating!
So lets put an end to this:
Note: It's a while since I did this, so please let some of the gurus in here read it first if you are not sure what you are doing. Then if there are any mistakes, I'll correct them and remove this note.
Be careful, do this at your own risk, if you do something wrong you can end up losing files or configuration. Again, if you do this correct, you hopefully never end up losing anything again.
MOVING THE HOME DIRECTORY
If we have a free disk or a partition to play around with a good choice is to make a separate /home partition. By having a separate /home partition we don't have to worry that much about our files and folders anymore If everything breaks down and we get to the point of an upgrade or a reinstall, we can do so and just leave our files where they are.
This is what we do:
1.) Creating the filesystem
Use fdisk or any partitioner you feel comfortable with (Preferably not Windows fdisk), and create a partition or format your drive to a Linux filesystem. Ext3 is good, some prefer ReiserFS or other, but this is your own choice. If you don't know the difference, choose Ext3.
Note: More information about mounting and partitioning disks in linux:
http://wiki.linuxquestions.org/wiki/...new_hard_drive
2.) Moving the /home
First we need to log out of gnome. At the GDM (Gnome Login Screen) press:
Ctrl+Alt+F1
Then Login as your user and type (Without the #):
# sudo -s
To permanently become root.
# mkdir /mnt/home
# mount -t ext3 /dev/hda5 /mnt/home
Note: In this case I use hda5, which is my second aprtition on my first hard drive, this needs to be changed to your correct partition number. Also when I mount the partition I tell the command which type of filesystem I'm mounting (Ext3). this also needs to be changed to the correct file system of your choice.
Then we need to copy all the files from your /home directory, this may take a while since you probably have a lot of documents to move
NOTE: dradul suggest to use rsync -aS instead of cp -a
http://ubuntuforums.org/showpost.php...5&postcount=25
# cp -a /home/* /mnt/home
now we have to edit the /etc/fstab to point the direction to the new home drive
Understanding the fstab
/etc/fstab is the configuration document that tells Ubuntu where to find your disks.
Next you need to understand the disk structure. If you have one hard drive, that will most likely be named hda, if you have a slave hard drive to, that will most likely be named hdb. Your cd-rom will be hdc. If you partition your disk, hda will turn into hda1, hda2, hda5 and so on, the number is individual depending how your disk is partitioned.
Ex.: /dev/hda1 ...means: dev = the devise directory. Your devise information is stored in the"/dev
# pico /etc/fstab
Will bring up something like this in the Pico Text Editor:
#-------------------------------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda6 none swap sw 0 0
/dev/hda5 /home ext3 defaults,errors=remount-ro 0 1
/dev/hdb1 /mnt/sys2 ext3 defaults,errors=remount-ro 0 1
/dev/hdc /media/cdrom0 udf,iso9660 ro,user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
/.iso/ubuntu-5.04-install-i386.iso /mnt/iso iso9660 ro,loop,auto 0 0
#---------------------------------------------------------------------------------------------------------
Note: We need to ad a line like this, again changing the (ext3) filesystem of your choice and the (hda5) the disk / partition you have moved your /home to.
/dev/hda5 /home ext3 defaults,errors=remount-ro 0 1
Note: I like to add this line in accordance to your disk structure like shown above
when you are done press:
Ctrl+o to overwrite your old fstab. Press Enter to confirm the overwrite and Ctrl+x to exit
Then rename the old /home, remove the mounted home dir and mount the new /home by:
# mv /home /homeOLD
# mkdir /home
# umount /mnt/home
# mount -a
3.) Check that all your files and configuration is correct in your new /home.
Log in and see that everything is as it should, and if it is we are now ready to delete your old home directory.
Open a terminal window and type (Without the $):
$ sudo rm -rf /homeOLD
CREATE BACKUPS OF YOUR SYSTEM
NOTE: AgenT suggest to us an alternative backup system rsnapshot.
http://www.rsnapshot.org
No need to reinvent the wheel, Heliode has written an excellent howto for creating backups of your system located here:
http://www.ubuntuforums.org/showthread.php?t=35087
I will just add a coupple of thoughts of how to create different backups for different parts of your system.
1.) System backup.
As Heliode describes, do a system backup, but exclude also the /home. For the /home we will create a separate backup. Save this backup under your new /home
2.) User configuration backup
I prefer not storing my personal files directly under my /home/username, but instead create a subfolder: Documents.
Then do a backup as Heliode describes of your /home directory, but exclude the /home/username/documents Save this backup under your new /home.
Note: Remember to also exclude this backup and the system backup which is now located under /home.
3.) Personal files backup
Last you can also do a backup of your personal files if you like, these should preferably be backed up to a CD or a DVD.
SUMMARY
Now if you mess up your system, you can restore this from the command line. If you mess up your personal configuration, you can also restore this easy from the command line.
Bookmarks