HOWTO: Move /home to second HDD

Post your tutorials and howtos here.
User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

HOWTO: Move /home to second HDD

Postby ScottQuier » 09 Aug 2013 16:02

This tutorial is based on a number of pages I found scattered around the net - most of them were a bit dis-jointed and hard to understand. I hope my effort to pull all these pieces together into a single cohesive blob will make life easier for someone else.

ETA: If anyone sees a mistake or problem or .... please say something so we can make this right.

What if you want to install SoldyK (or SolydX) on one HDD and have your /home partition on another HDD. The SolydXK live-installer does not "know" about additional hard drives. So, what is one to do. Here's how I solved that problem.
  1. Disconnect from your MBO the drive onto which /home is going to, eventually, reside.
  2. Go through the normal install process, creating all the partions you like onto sda. But, do not create a /home partition. Doing this, SolydXK will create a /home FOLDER into which user accounts will be written/created.
  3. Perform all the normal updates as well.
  4. Do NOT do any custom configurations or addition software installs ... until later
  5. Once you have your machine stable, that is, all the updates done
    1. Power off the computer
    2. Connect the second HDD,
    3. Power on the computer and enter the BIOS Setup - need to make sure the computer will boot from the install drive.
    4. Complete the boot-up/logon process
  6. Using Dolphin (or similar) select the second HDD and enter your password - this will cause SolydXK to automagically mount that drive for you. If it needs to be partitioned and/or formatted - well, you can do that and it should be done before going forward.
  7. Now we need to find out what the computer calls each of the drives:
    1. Run the 'lsblk' command to get something like this:

      Code: Select all

      $ lsblk
      NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
      sda      8:16   0 149.1G  0 disk 
      ├─sda1   8:17   0   3.9G  0 part [SWAP]
      ├─sda2   8:18   0  39.1G  0 part /
      └─sda3   8:19   0 106.1G  0 part 
      sdb      8:0    0 465.8G  0 disk 
      └─sdb1   8:1    0 465.8G  0 part 
      sr0     11:0    1  1024M  0 rom  
      
    2. Run sudo blkid to get the UUID of each partition (note you'll have to enter your password for this one):

      Code: Select all

      $ sudo blkid
      [sudo] password for scott: 
      /dev/sdb1: UUID="9789a6a8-d080-43e0-8097-36a8cd22b374" TYPE="ext4" 
      /dev/sda1: UUID="fc9aac16-cfd5-452f-a89b-c043d21b2228" TYPE="swap" 
      /dev/sda2: UUID="d6868073-bdf6-4f5b-ab2d-e3824f19ecea" TYPE="ext4" 
      /dev/sda3: UUID="c130e7d5-ccc6-4187-ab26-c906c9a74732" TYPE="ext4" 
      
  8. Rename our "/home" folder ... just to get it out of the way (choose what ever name you like for the destination - I was just trying to be a little funny):

    Code: Select all

    sudo mv /home /oldHomeWeek
  9. Create our /home mount point

    Code: Select all

    sudo mkdir /home
  10. Unmount and remount our second HDD - this just makes things easier

    Code: Select all

    sudo umount /dev/sdb1
    sudo mount /dev/sdb1 /home
    
  11. Copy our account folder(s) to the /dev/sdb1

    Code: Select all

    sudo cp -a /oldHomeWeek /home
    
  12. Using the "-a" option should eliminate the need for this step, but it won't hurt to check.
    For each user copied:

    Code: Select all

    sudo chown -R <UserName>:<UserName> /home/<UserName>
    
  13. Check to make sure you have a copy of your account folders on the top level of your second HDD. Also, it might be a good idea to make sure that everything copied over correctly.
  14. Edit our fstab file so that our new /home will be automounted on system startup.
    1. First make sure we have a backup

      Code: Select all

      sudo cp /etc/fstab /etc/fstab.bak
    2. Code: Select all

      kdesudo kate /etc/fstab
      or

      Code: Select all

      gksudo mousepad /etc/fstab
    3. Add the following lines to the end of the file (leave a blank line at the end just for so). Of course, you will want to your YOUR UUID - what is below is just my example:

      Code: Select all

      # /dev/sdb1
      UUID=9789a6a8-d080-43e0-8097-36a8cd22b374	/home	ext4    defaults		0	2
      
    4. Save the file and close the editor
  15. At this point you can either

    Code: Select all

    sudo reboot
    or

    Code: Select all

    sudo umount /dev/sdb1
    sudo mount -a
    
  16. When you are ready and are comfortable with the work done, you may of course

    Code: Select all

    sudo rm -rf /oldHomeWeek
Note: On a fresh install, there is at least one easier way to accomplish the above. But the above process will work later in the life of an active install and will move all the user accounts to the new/second HDD. That other process? On boot but before login
  1. Open single user console

    Code: Select all

    Ctrl-Alt-Fx
  2. Login as root
  3. Delete the newly created user account because you can't have two accounts with the same account name

    Code: Select all

    userdel -r <username>
    
  4. Get the /home folder on sda1 out of the way

    Code: Select all

    mv /home /oldHomeWeek
  5. Mount the new/second HDD (see above)
  6. Create the user account and give it a password

    Code: Select all

    adduser sys adm lp dialout cdrom floppy sudo audio dip video plugdev lpadmin sambashare <username>
    passwd <username>
  7. Log out

    Code: Select all

    exit
  8. Get back to our pretty window manager/DE

    Code: Select all

    Ctrl-Alt-F7
  9. Now, log into the new account
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"

User avatar
Arjen Balfoort
Site Admin
Posts: 9258
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: HOWTO: Move /home to second HDD

Postby Arjen Balfoort » 12 Aug 2013 07:37

Very nice!
That second part holds the logic for live-installer...if I ever get the time to implement that.


SolydXK needs you!
Development | Testing | Translations

User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

Re: HOWTO: Move /home to second HDD

Postby ScottQuier » 12 Aug 2013 11:05

Schoelje wrote:Very nice!
That second part holds the logic for live-installer...if I ever get the time to implement that.
Thanks. Your comment caused me to look at that part a little harder and I noticed a small error. Users will have to delete the newly created user account before it can be added to the system because, as I noted above, a system can't have two accounts with the same user name.

On the other hand, when you make the modifications to the live-installer, you will have the ability to create the appropriate mount point, mount the second HDD, and thus create the user's account in the right place the first time.
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"

Bequimão
Posts: 79
Joined: 30 May 2013 10:55
Location: Mannheim, Germany

Re: HOWTO: Move /home to second HDD

Postby Bequimão » 12 Aug 2013 15:41

Hi ScottQuier,

cp -a {source} [target} or rsync -a, as I prefer, would simplify step 11 and 12.

Furthermore, I would not use the new /home as a mountpoint, but mount the new device on /home2. Then I would create symlinks to the new home directories:

Code: Select all

# ln -s /home2/username /home
There is no need to drop and recreate the users. This would work in all Debian derivatives.
And I would not purge the backup. Perhaps you will need it later.

Best regards,
Bequimão

User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

Re: HOWTO: Move /home to second HDD

Postby ScottQuier » 12 Aug 2013 21:31

Hello Bequimão,

The first point

Code: Select all

cp -a ....
Yes, I can see that.

The second .... I'm not so sure. If I read the man pages correctly (gotta remember, I'm still learning all this :) ), it seems to me that

Code: Select all

adduser username2
would create the second user's account folder as

Code: Select all

/home2/username/username2
If I'm right (and there's lots of room to question that), wouldn't

Code: Select all

ls -s /home2 /home
be the correct syntax?
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"

Bequimão
Posts: 79
Joined: 30 May 2013 10:55
Location: Mannheim, Germany

Re: HOWTO: Move /home to second HDD

Postby Bequimão » 13 Aug 2013 16:24

Hi ScottQuier,

You are right

Code: Select all

# ln -s /home2 /home
would do the job. All paths remain valid.I ounce documented the steps, albeit in Portuguese
http://forum.aptosid.com.br/viewtopic.p ... 021&p=4191

If you like it still easier:

- close your session and login as root in a textual terminal [Ctrl + Alt + F1]
- copy the files
- switch the UUIDs with the command tune2fs
- remount the devices
- login a new session [Ctrl + Alt + F7]

Best regards,
Bequimão

Sorry, I don't get used to sudo :)

Notsonoble
Posts: 14
Joined: 11 Jul 2013 16:07

Re: HOWTO: Move /home to second HDD

Postby Notsonoble » 27 Jan 2014 02:25

I've followed these instructions on a fresh install. The system doesn't boot.
When I escape to see behind Plymouth I find fsck has failed and it wants a maintenance terminal. It's asking for the root password or Control-D to continue. Control-D does nothing and it resets the prompt when you try and type.

Nevermind. I got the endquote in fstab.

Fargo
Posts: 896
Joined: 17 Sep 2013 14:40

Re: HOWTO: Move /home to second HDD

Postby Fargo » 27 Jan 2014 20:35

I just noticed that Anticapitalista over at Antix has created a script for the installer to install home on a separate device. Maybe this is something the devs want to look into. The code and more info is on the 2nd page of the thread. http://forum.mepiscommunity.org/viewtop ... 92&t=35421

User avatar
zorgshanker
Posts: 21
Joined: 11 Apr 2014 05:24

Re: HOWTO: Move /home to second HDD

Postby zorgshanker » 04 May 2014 18:49

Thanks for putting this together, worked like a charm, i'm definiely bookmarking :)

Only had to do minor changes to a couple steps in there :

Code: Select all

sudo cp -a /oldHomeWeek /home
This created /home/oldHomeWeek which isn't what we want, just like step 13 mentions, make sure that your data is in /home/username . Only had to cd into /home/oldHomeWeek and cp -a username/ /home .

Code: Select all

sudo kate /etc/fstab
returns

Code: Select all

kate: cannot connect to X server :0
Which happens because root account doesn't have an environment bound to it (something along those lines), i simply used nano.

Code: Select all

sudo nano /etc/fstab
Stoked i found this post, thanks!

User avatar
zorgshanker
Posts: 21
Joined: 11 Apr 2014 05:24

Re: HOWTO: Move /home to second HDD

Postby zorgshanker » 05 May 2014 15:11

AH was reading something else and realized why the following command didn't, figured i' drop by.

Code: Select all

sudo kate /etc/fstab
shoud be

Code: Select all

kdesudo kate /etc/fstab
cheers

User avatar
ScottQuier
Posts: 1781
Joined: 18 Jul 2013 15:55
Location: Newport News, VA

Re: HOWTO: Move /home to second HDD

Postby ScottQuier » 05 May 2014 17:06

zorgshanker wrote:AH was reading something else and realized why the following command didn't, figured i' drop by.

Code: Select all

sudo kate /etc/fstab
shoud be

Code: Select all

kdesudo kate /etc/fstab
cheers
Yep - and the one for mousepad should be changed as well. So I re-worked both. Thanks!
Scott
Quoting zerozero, "The usage of PPA's in debian-based
systems is risky at best and entails serious compatibility
problems; usually it's the best way to destroy an install"


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests