Page 1 of 4 123 ... LastLast
Results 1 to 10 of 58

Thread: Howto: Move /home and secure your files and configuration

Hybrid View

  1. #1
    Join Date
    May 2005
    Location
    Sweden
    Beans
    442
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Howto: Move /home and secure your files and configuration

    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.
    Last edited by Lunde; October 4th, 2005 at 09:10 PM.
    Fredrik Lunde | Vergic AB
    www.vergic.com

  2. #2
    Join Date
    May 2005
    Location
    Wilts, UK
    Beans
    3

    Re: Howto: Move /home and secure your files and configuration

    just want to ask what may be a silly question, does the format have to be ext2/ext3? can it be fat32? I'd like to move my /home to a shared partition, accesed by numerous oS's and want them all to have rw access, this does include windows so therefore must have a MS format (unfortunately). Will this still work? or are there problems associated with having your home directory in a non-*nix format?

  3. #3
    Join Date
    May 2005
    Location
    Sweden
    Beans
    442
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Howto: Move /home and secure your files and configuration

    Quote Originally Posted by r0jaws
    just want to ask what may be a silly question, does the format have to be ext2/ext3? can it be fat32? I'd like to move my /home to a shared partition, accesed by numerous oS's and want them all to have rw access, this does include windows so therefore must have a MS format (unfortunately). Will this still work? or are there problems associated with having your home directory in a non-*nix format?
    I would'nt recomend it. Some earlier comments about that subject:
    Quote Originally Posted by davahmet
    I don't think there is anything that prevents you from putting /home on a FAT32 partition, it's just an extremely bad idea. I believe you may not like the results that come from doing this.

    The problem is with ownerships and permissions. Linux uses filesystem ACLs to assign ownership and permissions to files, directories and symlinks. Unfortunate, this concept isn't really applicable in the Windows world, so putting files on a FAT32 partition should give it root ownership with wide-open permissions. You might say, "so what. I like having a Windows security model" but the problem then becomes that your .profile, .bash_profile and or .bashrc is no longer owned by you. Without these important files, you may face instability or complete failure to log on. I've never tried it so I'm not sure how bad the results would be.

    Putting /home on FAT32 may seem like a convenient idea, but certainly it is an experiment only for the adventurous.
    Quote Originally Posted by desdinova
    I'd second the "disaster" .... as FAT32 has no concepts of permissions its very likely things like X and the like are just not going to work.
    However.. what you can do is to mount the Fat32 partition as a subdirectory under /home/username (~/). then you can just save the files you want to share and your backups to that directory and exclude it in the tar backups.
    Fredrik Lunde | Vergic AB
    www.vergic.com

  4. #4
    Join Date
    Nov 2004
    Location
    Quebec
    Beans
    741
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Howto: Move /home and secure your files and configuration

    just gave the howto a try, but I think there is a step missing, we moved the /home to /homeOLD so /home no longer exists as a mount point.
    so we need to create a new /home directory i think.

    EDIT:
    btw, THANKS!
    I never thought it wouuld be so simple
    Last edited by trash; July 18th, 2005 at 08:53 PM.
    ~
    Desktop:ASRock P4i65GV/P4 2.8ghz 2gbram
    Laptop:Toshiba L350-PSLD8C Centrino64 dualcore 2ghz 4gbram

  5. #5
    Join Date
    May 2005
    Location
    Sweden
    Beans
    442
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Howto: Move /home and secure your files and configuration

    Quote Originally Posted by trash
    just gave the howto a try, but I think there is a step missing, we moved the /home to /homeOLD so /home no longer exists as a mount point.
    so we need to create a new /home directory i think.
    Thank you, correct! The howto is now updated.
    Fredrik Lunde | Vergic AB
    www.vergic.com

  6. #6
    Join Date
    Jan 2005
    Beans
    27

    Re: Howto: Move /home and secure your files and configuration

    "However.. what you can do is to mount the Fat32 partition as a subdirectory under /home/username (~/). then you can just save the files you want to share and your backups to that directory and exclude it in the tar backups."

    I would like to do this - but as newbe I have no idea how it works - could you give me a short description

  7. #7
    Join Date
    Oct 2006
    Beans
    6

    Re: Howto: Move /home and secure your files and configuration

    Quote Originally Posted by trash View Post
    just gave the howto a try, but I think there is a step missing, we moved the /home to /homeOLD so /home no longer exists as a mount point.
    so we need to create a new /home directory i think.

    EDIT:
    btw, THANKS!
    I never thought it wouuld be so simple

    => so has this been included in some new documentation somewhere ?

    ... I have the problems of having followed the steps, I now have no home directory

    can someone point me to the new / updated version of this ... many thx

    Ajc

  8. #8
    Join Date
    Dec 2005
    Location
    Argentina
    Beans
    33
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: Howto: Move /home and secure your files and configuration

    Quote Originally Posted by r0jaws
    just want to ask what may be a silly question, does the format have to be ext2/ext3? can it be fat32? I'd like to move my /home to a shared partition, accesed by numerous oS's and want them all to have rw access, this does include windows so therefore must have a MS format (unfortunately). Will this still work? or are there problems associated with having your home directory in a non-*nix format?
    you can add ext2 or ext3 support to windows... i've done it.. look up in google.

  9. #9
    Join Date
    Apr 2005
    Location
    2600m closer to the stars
    Beans
    Hidden!

    Re: Howto: Move /home and secure your files and configuration

    Quote Originally Posted by Lunde
    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
    Code:
    # cp -a /home/* /mnt/home
    Please don't. cp is not safe nor designed for mirroring tasks.

    You should use a proper tool such as
    Code:
    rsync -aS /origin/. /target/.
    or a simple
    Code:
    cd /origin && tar cf - . | ( cd /target ; tar xf - )
    Personally I prefer rsync because it can do md5 checksums on all files to decide if they need copying or not, by adding the "-c" flag.

  10. #10
    Join Date
    May 2005
    Location
    Sweden
    Beans
    442
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Howto: Move /home and secure your files and configuration

    Thanks dradul, I'll make a note in the howto above
    Fredrik Lunde | Vergic AB
    www.vergic.com

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •