Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

setting up a separate home partition after installing

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
MeanDean
Posts: 3866
Joined: 2007-09-01 01:14

setting up a separate home partition after installing

#1 Post by MeanDean »

Okay, here is how I do a seperate /home partition after installing everything to one partition on debian.

(1)Open a terminal and su to root

(2)Use the command fdisk -l (lower case L) to view your partitions on your system, mine looks like this:

Code: Select all

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        3149    25294311   83  Linux
/dev/hda2            3150        4865    13783770    5  Extended
/dev/hda5            3150        3659     4096543+  83  Linux
/dev/hda6            3660        4169     4096543+  83  Linux
/dev/hda7            4170        4679     4096543+  83  Linux
/dev/hda8            4680        4865     1494013+  82  Linux swap / Solaris
I know that hda7 is unused and that is what I will use for my new home/ partition.


(3)We need to find out if it is currently mounted and what file system it has so I use the command mount and get output that looks like this:

Code: Select all

deans:/home/user# mount
/dev/hda5 on / type jfs (rw,noatime,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/hda7 on /media/usbdisk-1 type ext3 (rw)
/dev/hda1 on /media/usbdisk type jfs (rw,noexec,nosuid,nodev,iocharset=utf8
As you can see my hda7 is mounted on /media/usbdisk-1 and it is using the ext3 filesystem.

*If your partition is not mounted then use mount /dev/hda7 /mnt (adjust for your partition) to mount it at /mnt. Then repeat step 3 to verify it is mounted and where it is mounted and the filesystem type.



(4)do the following commands
cp -a /home/* /media/usbdisk-1
This will copy your user folders from home to the new partition. Adjust /media/usbdisk-1 to whatever your partition mount point was in step 3.

umount /media/usbdisk-1
This unmounts the partition so we can remount it later at /home instead. Adjust /media/usbdisk-1 to whatever your partition mount point was in step 3.

mv /home /oldhome
This moves (renames) our home folder to oldhome as a backup just in case.

mkdir /home
This makes a new blank home folder to mount our partition with.

mount /dev/hda7 /home
This mounts our spare partition at /home. Adjust /dev/hda7 for the partition you want to use as home.

Now if you use the mount command you should see something like this:

Code: Select all

deans:/home/user# mount
/dev/hda5 on / type jfs (rw,noatime,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/hda7 on /home type ext3 (rw)
/dev/hda1 on /media/usbdisk type jfs (rw,noexec,nosuid,nodev,iocharset=utf8)
and you are now using a seperate /home partition but we aren't quite done.


(5)Now we need to *carefully* edit our /etc/fstab file and add a line so that it knows to mount our partition as /home at boot time.

cp /etc/fstab /etc/fstab_BKUP
makes a backup of our /etc/fstab file just in case

nano /etc/fstab
to open the file in nano

My fstab originally looks like:

Code: Select all

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda5       /               jfs     noatime,errors=remount-ro 0       1
/dev/hda8       none            swap    sw              0       0
Need to add a new line at the bottom that looks like

Code: Select all

/dev/hda7   /home   ext3   defaults   1   2
Adjust for the proper partition and so forth.

So now my /etc/fstab looks like:

Code: Select all

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda5       /               jfs     noatime,errors=remount-ro 0       1
/dev/hda8       none            swap    sw              0       0
/dev/hda7   /home   ext3   defaults   1   2
Save it, close it and you are done.
Last edited by MeanDean on 2007-10-03 11:27, edited 1 time in total.

User avatar
MeanDean
Posts: 3866
Joined: 2007-09-01 01:14

#2 Post by MeanDean »

If you reboot and it goes all to hell, dont panic, use a livecd or something else to access your install partition
remove the /home folder
rename the oldhome folder back to home
remove the /etc/fstab file
rename /etc/fstab_BKUP to fstab
reboot and it should be back to original and you can try again.

User avatar
garrincha
Posts: 2335
Joined: 2006-06-02 16:38

#3 Post by garrincha »

Just to add in for those interested in the meaning of /etc/fstab conventions:
13.2 mount and /etc/fstab:
http://www-rohan.sdsu.edu/doc/debian/ch ... isks-mount
13.2.3 /etc/fstab: Automating the mount process

The file /etc/fstab (it stands for "file system table") contains descriptions of filesystems that you mount often. These filesystems can then be mounted with a shorter command, such as mount /cdrom. You can also configure filesystems to mount automatically when the system boots. You'll probably want to mount all of your hard disk filesystems when you boot.

Look at this file now, by typing more /etc/fstab. It will have two or more entries that were configured automatically when you installed the system. It probably looks something like this:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump > <pass>
/dev/hda1 / ext2 defaults 0 1
/dev/hda3 none swap sw 0 0
proc /proc proc defaults 0 0

/dev/hda5 /tmp ext2 defaults 0 2
/dev/hda6 /home ext2 defaults 0 2
/dev/hda7 /usr ext2 defaults 0 2

/dev/hdc /cdrom iso9660 ro 0 0
/dev/fd0 /floppy auto noauto,sync 0 0

The first column lists the device the filesystem resides on. The second lists the mount point, the third the filesystem type. The line beginning proc is a special filesystem explained in FIXME xref. Notice that the swap partition (/dev/hda3 in the example) has no mount point, so the mount point column contains none.

The last three columns may require some explanation.

The fifth column is used by the dump utility to decide when to back up the filesystem. In most cases you can put 0 here.

The sixth column is used by fsck to decide in what order to check filesystems when you boot the system. The root filesystem should have a 1 in this field, filesystems which don't need to be checked (such as the swap partition) should have a 0, and all other filesystems should have a 2. FIXME: cross ref to fsck, also, is the swap partition really a filesystem?

Column four contains one or more options to use when mounting the filesystem. Here's a brief summary (some of these probably won't make much sense yet --- they're here for future reference):

async and sync
Do I/O synchronously or asynchronously. Synchronous I/O writes changes to files immediately, while asynchronous I/O may keep data in buffers and write it later, for efficiency reasons. FIXME: cross ref to section on sync for full explanation. Also, should recommend when to choose one or the other.

ro and rw
Mount the filesystem read-only or read-write. If you don't need to make any changes to the filesystem, it's a good idea to mount it read-only so you don't accidentally mess something up. Also, read-only devices (such as CD-ROM drives and floppy disks with write protection tabs) should be mounted read-only.

auto and noauto
When the system boots, or whenever you type mount -a, mount tries to mount all the filesystems listed in /etc/fstab. If you don't want it to automatically mount a filesystem, you should use the noauto option. It's probably a good idea to use noauto with removable media such as floppy disks, because there may or may not be a disk in the drive. You'll want to mount these filesystems manually after you put in a disk.

dev and nodev
Use or ignore device files on this filesystem. You might use nodev if you mount the root directory of another system on your system --- you don't want your system to try to use the devices on the other machine.

user and nouser
Permit or forbid ordinary users to mount the filesystem. nouser means that only root can mount the filesystem. This is the normal arrangement. You might use the user option to access the floppy drive without having to be root.

exec and noexec
Allow or do not allow the execution of files on this filesystem. Probably you won't need these options.

suid and nosuid
Allow or do not allow the suid bit to take effect. Probably you won't need these options.

defaults
Equivalent to: rw, dev, suid, exec, auto, nouser, async. You can specify defaults followed by other options to override specific aspects of defaults.
Maurice Green on Usain Bolt's 9.58: "The Earth stopped for a second, and he went to Mars."

User avatar
MeanDean
Posts: 3866
Joined: 2007-09-01 01:14

#4 Post by MeanDean »

Thanks for that! I am still lost...
So should it be
/dev/hda7 /home ext3 defaults 0 2
:?

I am probably the worst to explain this since I do not even run a home partition!

User avatar
MeanDean
Posts: 3866
Joined: 2007-09-01 01:14

#5 Post by MeanDean »

I was going by examples on the net and the ones I have seen have 1 2 for home???

User avatar
garrincha
Posts: 2335
Joined: 2006-06-02 16:38

#6 Post by garrincha »

MeanDean wrote:Thanks for that! I am still lost...
So should it be
/dev/hda7 /home ext3 defaults 0 2
:?

I am probably the worst to explain this since I do not even run a home partition!
Heh..good catch. I simply use one whole disk as a home partition. So whenever I installed Debian or similar Linux distro in the master drive, I just add a new home partition for it on the slave drive or none at all, by simply adding the old /home to /etc/fstab and use it as /home.
Maurice Green on Usain Bolt's 9.58: "The Earth stopped for a second, and he went to Mars."

jongi
Posts: 472
Joined: 2007-04-15 02:41

#7 Post by jongi »

Is there a need to reboot? I would think a mount -a command should sort out almost all fstab changes.

User avatar
MeanDean
Posts: 3866
Joined: 2007-09-01 01:14

#8 Post by MeanDean »

as in, ready to reboot when you decide to do so not that you need to reboot...

I will try to clarify that!

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

#9 Post by llivv »

MeanDean wrote:I was going by examples on the net and the ones I have seen have 1 2 for home???
I think the answer to this one is:
If hda7 was ever used in another fstab entry you would copy the dump pass entries from there.
If it is a brand spanking new or never used partition the dump pass entries would be 0 0
info tune2fs
You might also want to label hda7 home
e2label

User avatar
arka
Posts: 1
Joined: 2013-11-02 15:18

Re: setting up a separate home partition after installing

#10 Post by arka »

Hello,
I followed your instructions, and I've been succesful mounting the home directory on another partition. Debian starts nicely.
But ... now geany won't start, says something about socket and other user... and none of the apps I ran over wine work anymore.
A significant difference may be that I'm using an ntfs partition to host the home folder. Also the partition is not labeled as 'home', but I don't really think it's that.
Well, after this I just remade to my old set up and everything is in order as usual.

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: setting up a separate home partition after installing

#11 Post by saulgoode »

What mount options are you using?

Code: Select all

grep ntfs /etc/mtab
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

Post Reply