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

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

  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
    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 kultex
    "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
    Sure...

    In terminal as your user type:
    $ mkdir ~/shared_fat32
    I use the name "shared_fat32" as an example, you may name it to what ever you want. but remember to do so also in fstab.

    $ sudo gedit /etc/fstab

    Add this line just above the /dev/hdc /media/cdrom... line:

    /dev/hdXX /home/username/shared_fat32 vfat user,rw,exec 0 0

    Note:
    Change the "username" to your user name and change the "hdXX" to your partition / disk number. Ex: hdb5

    Save and Exit

    Again in terminal type:
    $ sudo mount -a

    And that's it..
    Fredrik Lunde | Vergic AB
    www.vergic.com

  8. #8
    Join Date
    Jan 2005
    Beans
    27

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

    tank you - but is it not solving my problem. I need to have a link of directories (I hope it is the right word in english) I am actually working on the desktop and the problem is, that in Ubuntu I can not create a link on the vfat partitions (i hope it is clear, what I mean).

    Do you know any solution - the only thing I see in the moment is http://www.fs-driver.org/ , but writing to ext3 from windows could be dangerous (searching the net)

  9. #9
    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 kultex
    tank you - but is it not solving my problem. I need to have a link of directories (I hope it is the right word in english) I am actually working on the desktop and the problem is, that in Ubuntu I can not create a link on the vfat partitions (i hope it is clear, what I mean).

    Do you know any solution - the only thing I see in the moment is http://www.fs-driver.org/ , but writing to ext3 from windows could be dangerous (searching the net)
    I'm not sure if I understand what you meen. You can create what ever you like on the fat32 partition form both Linux and Windows. Maybe there are some file pernission problems, if that's the issue it can be fixed.

    If you have a fat32 partition, I don't see why you would want to write to the ext3
    Fredrik Lunde | Vergic AB
    www.vergic.com

  10. #10
    Join Date
    Jan 2005
    Beans
    27

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

    I could transfer all my files and mails to /home, rename the partition in Windows - and it would be perfect. It works fine - I tried it, but I find it still to dangerous.

    Yes it is a qustion of permission.

    The owner of the shared partition is root - to make a link it is necessary that the owner is the user. After I changed the permission, it worked fine.

    I know to change the permission for one file, but not for all the files eg. the whole partition.
    Last edited by kultex; July 31st, 2005 at 12:28 PM.

Page 1 of 6 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
  •