[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: partitions



Mark Grieveson wrote:
Hello.  When debian first installs, it gives the option of separating
the home directory (and some other directories) into a separate
partition.  I did not choose this option, and instead went for the
recommended newbie option of everything in one partition.  However, now
I think it would be a good idea to separate stuff.  Is there a way to
rerun that aspect of the install, or, if not, another way to do this?

I recently split my /home off onto another disc. Perhaps my experience
can help. I DO NOT use LVM. If you use LVM, then I can't help. I am not
a Debian specific expert. I encourage others here to read and examine
what I have written for mistakes or omissions.

Before starting, be sure to read this all the way through several
times, and make sure you understand what is being accomplished
by each command, and why it needs to be done. If you have any doubts
about why any particular command is recommended, or what it is
accomplishing, or how to reverse its action, be sure to ask before
doing anything. Any failure of complete comprehension on your part
may result in an unbootable and possibly unrecoverable system.
You need to print a copy of this before you start, as well.

I TAKE NO RESPONSIBILITY FOR ANY ACTIONS YOU MAY PERFORM ON YOUR
MACHINE REGARDLESS OF WHETHER YOU CARRIED THEM OUT EXACTLY AS
I DESCRIBED. I OFFER NO WARRANTIES OR FITNESS FOR ANY PURPOSE
FOR THE FOLLOWING INFORMATION. IT IS PROVIDED FOR INFORMATIONAL
PURPOSES ONLY.

This information is free; don't come sue me.

First, and foremost, make a full backup of your system. If you don't
know how, or if you think you do, but haven't tested your ability
to restore everything you need, then you need to learn how and/or
test. You may lose your system if I made a mistake writing, or
you make a mistake following, the instructions.

Ok, now you have a good backup, and if something goes wrong, you
won't lose your system. Next, you need to make room. If you have
some unallocated room on your main disc, and a spare entry in
your Partition Table (PT) then create a new partition entry
in your PT for the new file system(s). If you don't have unallocated
space, or no entries in your PT, then get a new disc and partition
it, or use your favorite tool to repartition your disc. If you
use the second method, then you'll lose everything and have to
reload from backup.

Ok, now you have some space on your current disc, or on another.
Make whatever file systems you want on the various partitions.
I suppose that you are going to put /home and possibly /usr,
or /usr/local, or perhaps /tmp on their own partitions. Anyway,
select the partitions you want to be your new /home or whatever.
I'll presume you are doing only /home, you should be able to
extrapolate.

You can test your work so far by making an entry in your
/etc/fstab and mounting the new file system, and playing around
with it for a little bit. Be sure to delete whatever you create
before proceeding, and be sure to remove any entry in /etc/fstab
referring to the new partition before proceeding. If you do
this, be sure to make another backup.

All right, now you have a new file system on a new partition which
is empty. Reboot to single user mode.

Save your current fstab

# cd /etc
# cp -p fstab fstab.bak

Now mount your new file systems where you want. For the sake of
ease of exposition, I'll presume you have a new disc /dev/hdb and
you want the first partition to become your new home...

# mkdir -p /media/newhome
# mount -t auto /dev/hdb1 /media/newhome

Unmount any other mounted file systems. I'll presume you have only two,
/ and /boot. You can't actually unmount your root, because then
you'll have no applications, like rsync, to run. We'll do the next
best thing, and remount your root partition read only. Be sure
to unmount any other file systems you mount (given what you wrote
above, there shouldn't be any, but for future reference) to
protect them from damage.

# umount /boot
# mount -o remount,ro /

Ok, your root file system is now static. Now copy over your stuff...

# rsync -a /home/ /media/newhome

Don't omit the trailing slash on /home/ or you'll get a directory
named /media/newhome/home, which you don't want. This copy may
take a long time. If you want to see what's happening, add
"-v" after the "-a". It'll probably take a lot longer, however.

After this has completed, you have a full copy of your current
/home in /media/newhome, which is your new disc/partition.

You can also use dump/restore, but I find rsync easier.

Unmount your copy, so it is safe from damage...

# umount /media/newhome

Now, edit your /etc/fstab to mount your new disc at the next boot.

# mount -o remount,rw /
# echo "/dev/hdb1 /home auto exec" >> /etc/fstab

Ok, now we can rename /home to /oldhome, so you can leave
it around for a while, in case you want to reverse the procedure
later.

# cd /
# mv home oldhome
# mkdir home

At this point, you should have a system which will boot and
look just like it did before. However, you can check your
work so far...

# mount /home
# cd /home
# ls -ld

You should see what looks like your original system. If so, you
are done, reboot...

# shutdown -r now

You should come up and run normally. Everything should look the same.
After you have run for a few days and everything looks good, you
can delete /oldhome and /media/newhome.

If you have a problem, then reboot to single user mode and back out
your changes...

# cd /etc
# mv fstab fstab.bad
# mv fstab.bak fstab
# cd /
# rmdir home
# mv oldhome home
# shutdown -r now

You should now reboot exactly as you were. You can examine
/etc/fstab.bad and try to figure out what is wrong. However,
if you can make an entry in /etc/fstab like

/dev/hdb1 /media/newhome auto exec

and successfully mount it, then it should work. If you
get some problems worked out, and want to try again,
you'll have to reboot to single user mode again, and
set up /etc/fstab, and do the rsync and so on again,
since your file system may have changed. Using rsync
should be pretty fast, as it'll only copy what has
changed. Using dump/restore will take as long as it
did the first time.

There are some directories which CANNOT be moved off onto
other partitions. You must not move /sbin, for example.
You can usually move /usr and certainly /usr/local, but
any program used during boot must be "premounted" and
part of the root partition.

If it comes to the worst, then reinstall, and use the new
partitioning scheme you want during the install, then
restore your data from your backup. That's what you'd have
to do anyway, if you do it the "safe" way. I don't see
much, if any, risk in this procedure, and it's what I used.
(Actually, my situation was more serious, as I was also
merging a "split" home back together at the same time.)

If you start out making a full backup which works, then
you aren't going to lose anything but time, and stand to
learn a good bit.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I speak only for myself, and I am unanimous in that!


Reply to: