Web lists-archives.com

Re: how to add a /home partition




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Nov 03, 2017 at 09:06:28PM +0000, Long Wind wrote:
> i have installed wheezy at /dev/sda3, no swapdisk space isn't enough nowi want to add /dev/sda4 as /home partitionbut how to do it? Thanks!

First, take a backup. Things tend to go wrong if they can!

Do all of this as root. Best if no user is logged in (since
this might change the contents of /home during the procedure;
safest is if you boot in single user mode)

 - if not done yet, set up a file system of your choice (I'll
   assume ext4, adjust to taste)

   mkfs.ext4 /dev/sda4

   *THIS WILL WIPE THE CONTENT OF /dev/sda4*

 - add /dev/sda4 to your /etc/fstab:

   a line like this

   /dev/sda4 /home           ext4    defaults        0       2

   (instead of /dev/sda4 you can insert the disk's UUID, which
   you find out with "sudo blkid /dev/sda4". This has the advantage
   that the blkid is sometimes more stable than the device name)

   Adjust your file system 

   *DON'T REBOOT YET*

 - copy the content of /home to your new disk:
   for example
   - mount /dev/sda4 somewhere suitable:

     mount /dev/sda4 /mnt

  - copy the contents of /home to its future location:

    rsync -av /home/ /mnt/
    (slashes are important)

    or cp -a /home/* /mnt

  - test your setup. Either issue "mount -a" and login as normal user
    or just reboot normally (if you were in single user mode, just
    reboot). All working?

  - if yes, you can wipe the content of your old /home, which is
    still taking up space on your /dev/sda3:

  - boot into single user mode

  - unmount /home (which is now /sda4)

    umount home

  - now your old home becomes visible. Wipe it

    rm -Rf /home/*

  - reboot. Done!

You didn't forget to take a backup, did you?

Don't hesitate to ask if anything is unclear. Proceed with caution!

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAln84MkACgkQBcgs9XrR2kbz7wCfeWc8yEixUpWTzGc1hg3hW5Y0
JSQAnA0ivC9LtlVJ0xNBiUcMapKbEofl
=Zjy3
-----END PGP SIGNATURE-----