Re: Moving /home to its own partition.
>Suppose Debian was installed on hda with only two partitions, swap
>and / and you have accumulated much data in /home.
>Later, you add another hard drive, hdb, and decided to place swap
>and a separate /home partition on this new drive while keeping / on
>the original hda.
# Get a root shell. Commands follow. This is a comment.
# New drive? Unsure of how it was handled? Scan it for defects.
# This gives the drive a chance to swap bad blocks out for spares
# before Linux ever sees them. It takes a while. Overnight for
# a modern large drive.
badblocks -w /dev/hdb
# In a hurry? This is faster, not as thorough.
badblocks /dev/hdb
# Create a partition table. Rumor has it the first cylinders are
# the fastest (maximizes MS-Windoze performance) so put swap there.
cfdisk /dev/hdb
# Create file systems and swap area.
mkswap -c /dev/hdb1
mke2fs -c /dev/hdb2
# Activate new swap area just to see if it works.
# Mount new /home temporarily.
swapon /dev/hdb1
mkdir /b2
mount -t ext2 /dev/hdb2 /b2
# Drop to single user; kills any pesky daemons writing stuff in background.
telinit 1
# Anything here we don't understand? If not, proceed.
cd /home && ls -la
# Copy everything whose name does not start with a dot.
cp -a * /b2 && sync
# Move old /home aside. Move new /home into place.
cd /
mv home home-old
umount /b2 && rmdir /b2
mkdir home
mount -t ext2 /dev/hdb2 /home
# Make new /home mount and new swap next time.
# Notice we are not deactivating the old swap.
# The more swap spindles you have, the better.
echo /dev/hdb2 /home ext2 defaults 0 2 >> /etc/fstab
echo /dev/hdb1 none swap sw 0 0 >> /etc/fstab
# Welcome to your new, larger machine. Restart daemons, X.
telinit 2
# You don't have to reboot, but it's good practice to
# test your new configuration, to make sure it boots okay.
>how could you best utilize the space gained by
>transferring data from the original /home to the new /home partition?
Don't worry, /var/cache will use it eventually. You didn't move /var.
Cameron
Reply to: