Setting up a home partition on a separate drive

Write tutorials and howtos in here
More tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please, Before you post please read this

Setting up a home partition on a separate drive

Postby corbintechboy on Fri Oct 28, 2011 10:13 pm

For backup purposes I like to have my /home on a separate drive from /, I noticed during install there was no option for this on LMDE. So I set it up myself.

NOTE: I would do this on a fresh install so you don't have a bunch of settings and whatnot, this will erase any settings you have in your current /home.

First we need the UUID of the drive you want to use:

Code: Select all
sudo blkid /dev/sdXX (replace XX with your device)


Now with UUID in hand:

Code: Select all
gksu gedit /etc/fstab


fstab tells the system where to mount drives during boot. Your fstab should look something like this:

Code: Select all
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc   /proc   proc   defaults   0   0
# /dev/sda1
UUID=c826b64f-d320-46c3-a6c2-f9e409f8a615   /   ext4   rw,errors=remount-ro   0   1
# /dev/sda2
UUID=2ef040e8-b399-447c-ba39-5800b574e511   swap   swap   sw   0   0


Now let's add the new info for the drive. Go down to the bottom of the file and add this:

Code: Select all
# /dev/sdXX (your drive)
UUID=(Your UUID)       /home   (FS type)    rw,errors=remount-ro    0       1


There are probably other choices for the way the system treats the drive, you can look into these if you choose. This works for me and should work fine for others.

Reboot your system and setup your programs and everything will be saved in your new home. All default setting will be written.

NOTE: When I did this my /dev was writing an error log after the initial boot. I did a second reboot and all was fine. YMMV
corbintechboy
Level 1
Level 1
 
Posts: 3
Joined: Fri Jan 14, 2011 6:33 pm

Linux Mint is funded by ads and donations.
 

Re: Setting up a home partition on a separate drive

Postby xenopeek on Sat Oct 29, 2011 7:09 am

During installation you can choose manual partitioning. There you will be able to create a partition on another disk, and indicate it to be mounted as /home. It will then automatically add the entry to fstab for you.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14509
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Setting up a home partition on a separate drive

Postby corbintechboy on Sat Oct 29, 2011 1:23 pm

Vincent Vermeulen wrote:During installation you can choose manual partitioning. There you will be able to create a partition on another disk, and indicate it to be mounted as /home. It will then automatically add the entry to fstab for you.


Hmmm it would not let me do this.

I would select the first drive and setup root, switch to the second drive to setup /home and it would say I had no /. I tried many different ways and it did not work.

Well, if anyone has the issue I had this will work. I don't have any idea why it didn't work that way for me.
corbintechboy
Level 1
Level 1
 
Posts: 3
Joined: Fri Jan 14, 2011 6:33 pm

Re: Setting up a home partition on a separate drive

Postby cangussu on Sun Dec 04, 2011 7:57 am

corbintechboy wrote:
Vincent Vermeulen wrote:During installation you can choose manual partitioning. There you will be able to create a partition on another disk, and indicate it to be mounted as /home. It will then automatically add the entry to fstab for you.


Hmmm it would not let me do this.

I would select the first drive and setup root, switch to the second drive to setup /home and it would say I had no /. I tried many different ways and it did not work.

Well, if anyone has the issue I had this will work. I don't have any idea why it didn't work that way for me.



In LMDE, if you have 2 separate hard drives, you can only choose one. To set /home partition in the second hard drive, you need to follow this tutorial after installation. But remember to copy all your files from old /home partition to new /home partition and set file's permitions.
cangussu
Level 1
Level 1
 
Posts: 1
Joined: Sun Dec 04, 2011 7:51 am

Re: Setting up a home partition on a separate drive

Postby Royal.Bengal on Fri Oct 12, 2012 9:00 am

Not an expert but I did this way:
Move home partition:

sudo mkfs -t ext4 /dev/sdb1 (new home partition/drive)
sudo mkdir /mnt/home (create mount folder for new home partition)
sudo mount /dev/sdb1 /mnt/home
sudo cd /home
sudo rsync -a . /mnt/home (copies all files and folders with permissions)

Note: Filesystem and home partitions are only examples, find out your own setting. Can't remenber the source but remember I googled for it.

P. S. Remember to update fstab to reflect the changes...
Royal.Bengal
Level 1
Level 1
 
Posts: 1
Joined: Fri Oct 12, 2012 8:46 am

Re: Setting up a home partition on a separate drive

Postby martywd on Fri Oct 12, 2012 8:48 pm

Here's a another way to 'move' the '/home' directory.

In the following example the 'manual' creation of a separate '/home' partition in also _not_ required at initial installation of the *nix OS. At some point, a one-time '/etc/fstab' configuration of (in this example) the '/data' partition _is_ require but can be done at anytime prior- or post-install of most any *nix OS install. (I mostly use 'gparted' to create partitions [GParted in the GUI menu]). What follows is the assumption that the '/data' partition has _already_ been properly created, configured in '/etc/fstab', and successfully mounted at boot up.

With that typed, my 'home' directory(ies) is/are _always_ ultimately positioned on a separate partition on /dev/sdaX or different hard drive (/dev/sdbX, or /dev/sdcX, or /dev/{wherever}) i.e., somewhere other than it's default '/home' position. Here's what I do...

On any new or existing hard drive I always leave enough room to create as large a partition as possible called: '/data' <== The partition name is totally arbitrary, of course!
Code: Select all
somename - # df -h
Filesystem              Size  Used Avail Use% Mounted on
/dev/sda5                24G  6.3G   16G  29% /
udev                    3.0G   12K  3.0G   1% /dev
tmpfs                   1.2G  1.1M  1.2G   1% /run
none                    5.0M     0  5.0M   0% /run/lock
none                    3.0G  344K  3.0G   1% /run/shm
/dev/sda7               902G  471G  386G  55% /data


The procedure:
After a sucssesful install of whatever Linux distro, I enable 'root's' password (temporarily). Open a 'Terminal' window and do:
Code: Select all
someuser@somename ~ $ sudo passwd root
[sudo] password for someuser:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Next. Logout of X and at the resulting GUI login screen I do the keystrokes: 'Ctrl+Alt F2' . You should now be at a black screen that looks something like this:
Code: Select all
Linux Mint 13 Maya somename tty2
somename login:

At the prompt, login as 'root' .
Code: Select all
somename login: root
Password:
Last login: Fri ... .. 09:..:.. CDT 2012 on tty2
Welcome to Linux Mint 13 Maya (GNU/Linux 3.2.0-23-generic-pae i686)

Welcome to Linux Mint
 * Documentation:  http://www.linuxmint.com

somename ~ #

Once logged in as 'root' do the following at the prompt:

Change to the '/' directory:

'cd /'

Move the existing '/home' directory to '/data'

'mv home /data/'
Code: Select all
somename ~ # mv home data/
`home' -> `data/home'


Create new symbolic link to '/data/home' in '/'

'ln -s /data/home' <== NOTE: No forward slash ('/') after '/data/home' !

Check you new symbolic link is correct. If your result looks like this you're good(!):
Code: Select all
somename / # ls -ld home
lrwxrwxrwx 1 root root 9 ... ... home -> data/home

--Or--

Another example of the 'mv'. In a current installation of LM 13 Maya MATE my 'mv' command was:

'mv home /data/mate_home'

'mate_home' could also be (in no particular order): 'cinnamon_home' or 'debian_home' or 'kde_home' or xfce_home'... I think you get the idea!

The symbolic link:

ln -s /data/mate_home home'

After creating the symbolic link, a 'ls -l' from commandline in the root ('/') directory shows this:
Code: Select all
somename / # ls -l
total 100
drwxr-xr-x   2 root root 12288 Oct  4 17:47 bin
drwxr-xr-x   3 root root  4096 Oct  4 17:56 boot
drwxr-xr-x   9 root root  4096 Aug 14 17:27 data
drwxr-xr-x  16 root root  4320 Oct 12 13:56 dev
drwxr-xr-x 164 root root 12288 Oct 12 13:58 etc
lrwxrwxrwx   1 root root    15 Aug 14 17:28 home -> /data/mate_home
drwxr-xr-x  23 root root  4096 Oct  2 00:17 lib
drwx------   2 root root 16384 Jun 13 11:23 lost+found
drwxr-xr-x   3 root root  4096 Oct 12 13:57 media
drwxr-xr-x   5 root root  4096 Oct  4 17:26 mnt
drwxr-xr-x   5 root root  4096 Oct  5 10:53 opt
dr-xr-xr-x 170 root root     0 Oct 12 08:56 proc
drwx------  23 root root  4096 Oct 11 20:26 root
drwxr-xr-x  25 root root  1000 Oct 12 13:56 run
drwxr-xr-x   2 root root 12288 Oct  8 11:11 sbin
drwxr-xr-x   2 root root  4096 Mar  5  2012 selinux
drwxr-xr-x   2 root root  4096 Apr 23 06:34 srv
drwxr-xr-x  12 root root     0 Oct 12 08:56 sys
drwxrwxrwt  11 root root  4096 Oct 12 13:57 tmp
drwxr-xr-x  10 root root  4096 Apr 23 06:34 usr
drwxr-xr-x  12 root root  4096 Oct 12 13:47 var
somename / #


Looks good!

Reboot.
Code: Select all
somename / # reboot

Log into 'X' as usual.

In a 'Terminal' window and running the 'pwd' command should give you:
Code: Select all
pwd
/home/someuser
pwd -P
/data/home/someuser
--Or--
Code: Select all
pwd
/home/someuser
pwd -P
/data/mate_home/someuser

depending on which one of the move examples was used? Otherwise, the access to the '/home' directory is transparent.

Don't forget to disable 'root's' logon when satisfied all is well. Open a terminal window:
Code: Select all
someuser@somename ~ $ sudo passwd -d -l root
[sudo] password for someuser:
passwd: password expiry information changed.
someuser@somename ~ $


Done.

NOTE: I've used this technique for years. It's always worked.
.
martywd
Level 3
Level 3
 
Posts: 119
Joined: Sun May 08, 2011 10:35 am
Location: Texas


Return to Tutorials / Howtos

Who is online

Users browsing this forum: No registered users and 0 guests