• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1266
  • Last Modified:

How to change /home directory

I want to add a new hard drive to my Slackware Linux machine, to serve as the /home directory.

What do I need to do to remap /home  from /dev/hda2/home to /dev/hdb/home ?

Also, after I fdisk the new hard drive, what is the command to format it.. is it simply format ?

Thanks!

Jared
0
magitek
Asked:
magitek
3 Solutions
 
slow1000Commented:
To change the location of home, you'll need to edit the /etc/fstab file.  Hopefully, it should be fairly intuitive.  

To format the disk, I believe slackware has cfdisk at /sbin/cfdisk.  I would go to single user mode first.  

Single User mode:

init 1

to partition and format:

/sbin/cfdisk

I think running cfdisk should be fairly intuitive also.

After formating, reboot and edit the /etc/fstab file, and mount the old disk to a different location, probably by editting /etc/fstab also.  After doing this, you can run mount -a as root to execute the changes to /etc/fstab.  

Hopefully, the lack detail of detail in the steps is ok.  You could post your /etc/fstab file if you need more detailed advice.
0
 
LuxanaCommented:
Hi

you need to create your desired filesystem:
mkfs.ext3 /dev/hdb ==> this will make ext3 filesystem
mkfs.ext3 /dev/hdb2 ==> this will create ext3 on second primary partition

I all depends how you partitioned your hard drive.
another options are for example:
mkfs         mkfs.ext2    mkfs.minix   mkfs.vfat
mkfs.cramfs    mkfs.msdos

then just mount this partiton in /etc/fstab

and your done:-)

./lubo



0
 
JammyPakCommented:
as mentioned, use fstab to change which drive is mounted as /home

one thing not mentioned it moving the actual data...

I would boot into single user mode, then mount the new drive as /mnt/temp (or whatever you want), then do cp -R -a /home/* /mnt/temp/ this will recursively copy everything from /home to the new drive, and keep the ownership and permissions and everything the same.

Next, unmount the new drive from /mnt/temp, and modify the /etc/fstab to mount the new drive as /home...reboot, and all should be well.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mburdickCommented:
Install the new hard drive into the system and create a file system on it.

Then, create a temporary mount of the new partition with something like: mount -t ext3 /dev/hdb1 /mnt

Copy all of the current "/home" content to the new system like this:

cp -R -r /home/* /mnt/

Update your /etc/fstab to automatically mount /dev/hdb1 under /home

Re-execute the "cp -R -r /home/ /mnt/" command with no users logged in. Then, rename the /home directory with something like "mv /home /home.old". Create a new /home directory with "mkdir /home". Reboot the system and check to see that /dev/hdb1 is mounted as /home. Once you're comfortable that everything is working ok, you can delete the /home directory with "rm -rf /home.old"


This series of steps assumes the new hard drive is IDE, has only one partition, is formatted as ext3, that you want to "move" all user home directory data to the new drive, and that you have the root password. All are reasonable assumptions, but may not be exactly correct. Adjust pieces as necessary...
0
 
JammyPakCommented:
mburdick: 2 questions...
 - why bother executing the cp command twice? if you boot into single-user mode, then you can copy everything with no worries
 - why delete and recreate the /home directory? It's just an empty directory to mount the file system in.

just curious if there's any reason to do so that I don't see....

also, -R and -r are the same thing...recursive copy. I used the -a, because that preserves ownership, permissions, and timestamps

0
 
mburdickCommented:
JammyPak:

The reason you would execute twice is that the first pass will do the "heavy lifting" to make a "mostly accurate" copy. The second pass will shore things up by updating any files that changed. This basically allows you to make this kind of change on a system with active users and be able to make the diretories exact mirrors with minimal time (on the second pass).

If you read the directions I posted a little more closely, I don't recommend "deleting and recreating the /home directory". I have the original directory get renamed (which preserves it in its entirety for the purposes of a backout plan). Once renamed, a new one must be created.

As for the parameters for cp... my bad. I should have specified -R -u, the -u meaning to only copy those files that have changed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now