[Last Call] Learn how to a build a cloud-first strategyRegister Now


How to change /home directory

Posted on 2005-04-30
Medium Priority
Last Modified: 2013-12-05
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 ?


Question by:magitek

Accepted Solution

slow1000 earned 200 total points
ID: 13902190
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:


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.
LVL 10

Assisted Solution

Luxana earned 100 total points
ID: 13902697

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:-)


LVL 16

Assisted Solution

JammyPak earned 200 total points
ID: 13909252
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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 12

Expert Comment

ID: 13914476
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...
LVL 16

Expert Comment

ID: 13917443
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

LVL 12

Expert Comment

ID: 13922902

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.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question