C. Linus Hicks
lhicks at nc.rr.com
Tue Nov 23 05:39:20 UTC 2004
On Mon, 2004-11-22 at 11:46 -0600, Gustavo Seabra wrote:
> Sorry, I just found a way to get the info. Here is the result of df -h:
> Filesystem Size Used Avail Use% Mounted on
> /dev/sda3 4.9G 4.2G 427M 91% /
> /dev/sda1 99M 17M 78M 18% /boot
> none 125M 0 125M 0% /dev/shm
> /dev/sda2 12G 683M 11G 7% /home
> What I'd like to do is to take a couple of Gigs from /home and put them
> into / (root). I believe I can backup and erase /home without problems,
> but how can I put this space into root?
I'd like to see the output of the "p" command from fdisk also, but this
will be a somewhat complicated case. Since your root partition comes
after your /home partition, you will have to move the contents of your
root partition in order to make it bigger. It is doable, just more
complicated. You decide whether the potential risk is worth it.
There are two posibilities dependent on whether or not you are able to
backup your /home partition to off-line storage, like burning a CD.
Here's the basic outline if you can backup /home:
1. Back up your home partition.
2. Unmount /home and remove it (comment it out) from your fstab.
3. Delete the sda2 partition.
4. Create a new sda2 the size your new root partition should be.
5. Copy everything in sda3 to sda2.
6. Make a new entry in your grub.conf pointing to the new root. Be sure
to preserve your existing entry in the grub menu.
7. Test to make sure you can boot the new root partition. Use the mount
command to verify what device is mounted as your root partition. Make
sure the system works properly - just remember you have no /home.
8. Assuming you booted successfully from the new root, you can now
delete sda3 and create any new partitions you want, including your
9. Restore /home from your backup.
10. Update your fstab to reflect your new /home partition.
The above can be simplified if you like the existing paritions sizes and
just want to switch them.
Here's the outline if you can't backup /home:
1. Unmount /home.
2. Use resize2fs to shrink the filesystem. I would shrink it to the size
you want your new root to be.
3. Use fdisk to shrink the parition.
4. Decide how to proceed:
The safer way to proceed from here is to leave what is currently in your
sda2 partition there, and just copy your root partition from sda3 into
sda2 as well. Note that this will consolidate everything (except /boot)
into one partition. You will want to create a /home/home directory and
move all your user directories into it first. This will allow you to
boot both new and old roots, but will alter disk allocation patterns
(this should have a negligible negative effect). From here, it remains
to create a new grub entry, test booting the new root, then deleting
your old root, creating your new /home, then moving /home in your root
partition to your new /home partition.
The risker way to proceed is to go ahead and create a new partition
for /home and move it first. The risk here is that you must modify both
you grub.conf and your fstab for your existing root in order to boot it
successfully. The reason is that your partition names have changed
because you now have two where there used to be one. So sda3 becomes
sda4, your new /home is sda3 and your new root is sda2.
I have not outlined the rest of this process, but this much should give
you an idea of the risk should you decide to proceed with it. If you are
not comfortable with using resize2fs and/or fdisk, the potential for
damaging your system beyond repair could be great. On the other hand, it
could be a great learning opportunity.
C. Linus Hicks <lhicks at nc.rr.com>
More information about the users