You are not logged in.

#1 2007-08-29 17:44:07

calvinthomas
Member
Registered: 2007-06-24
Posts: 15

Moving Partitions

Hello all! I'm a current and extremely happy Arch Linux user, however, I have my partitions set up in a way I no longer want them to be and would like to change them slightly without losing Arch:

Currently I have Arch Linux on hda8 and another (elive atm but changes regularly) distro on hda7, I also have a swap on hda6 and a home on hda5. What I would like to do is format hda7 and add the space to hda8 without losing the current Arch installation (Grub is controlled via hda7 but I figure I can fix that from a live cd) is there anyway for me to do this that isn't very complicated? If so, could someone provide me with info on how to do this?

Calv

Offline

#2 2007-08-29 18:01:18

ozar
Member
From: USA
Registered: 2005-02-18
Posts: 1,686

Re: Moving Partitions

If you want a good GUI tool to use for working with your partitions, take a look at the Parted Magic LiveCD:

http://www.partedmagic.com

It's easy to use and good documentation for using it can be found on their website.


oz

Offline

#3 2007-08-30 20:02:44

mac57
Member
From: St. Somewhere
Registered: 2006-01-06
Posts: 304
Website

Re: Moving Partitions

I have done a similar thing myself just recently. Here is what I did. I will substitute your disk numbers throughout, so that this should be directly applicable to your situation.

First of all, any time you start messing with partitions you run the risk of messing up your partition table and potentially rendering your disk inaccessible and your machine unbootable. The very FIRST thing you should do is save off your current MBR, just in case.

To save your current MBR, as root issue the commands:

# dd if=/dev/hda of=hda-mbr bs=512 count=1

and then save off hda-mbr onto some form of media that is not on the hard drive itself.(a floppy, an external hard drive, a USB memory stick, etc.).

OK, with the initial safety steps out of the way, I then booted a Live Linux CD that had the "partimage" program on it (I used Knoppix, but there are many Live CDs that will do the trick) and made a complete partition image of my existing Arch install to an external USB2 harddrive using partimage. Then I used QtParted (also on the Knoppix Live CD) to delete hda7 and hda8, creating one large contiguous space. I then created one new partition in that space and formatted this new space for the same file system that the Arch install was using (this is critical - if you don't preformat, it doesn't work!). I then reversed the partimage process, this time restoring the partition from the external hard drive to the newly combined single larger partition, now named hda7.

All of that is the "easy" part. Now you have one large partition with Arch back on it. How do you get it to boot? Arch was on hda8, now it is on hda7. For both Lilo and GRUB, this is a showstopper. Further, your fstab entry for "/" is now wrong. I corrected that first, still from Knoppix. I went in and edited the newly restored Arch's /etc/fstab and corrected the old "hda8" reference to "hda7".

To get this to boot for the first time, I took advantage of the fact that my machine has a floppy drive. First, I noted down the complete details of the boot files pathnames and the /boot/grub/menu.lst parameters that boots them and then I booted the PC from a free standing GRUB boot disk I have (see the end of this posting for details on how to create such a beast if you don't have one). This boots to a floppy based GRUB prompt. From there, using the following commands, I booted Arch:

grub> root (hd0,6)
grub> kernel /boot/vmlinuz.....  (same paramters that were on your grub boot line before)
grub> boot

This boots Arch in its new location, and since you have already corrected fstab, it runs properly. In my case, I normally use Lilo, so I then went into /etc, corrected the hda8 references in lilo.conf and reran lilo to recreate a usable boot record. From there on in, the machine booted normally.

If you are using GRUB as your normal boot loader, I actually can't provide complete help. You need to re-install GRUB in the same way as I just reinstalled Lilo, so that it now points at hda7's /boot/grub/menu.lst, not hda8's. I *think* this is as simple as opening an xterm, going into su, and issuing the command:

# grub-install /dev/hd0

BUT I am not sure - I have never done this. So, a question to the audience: given that you have a running Arch install, how do you re-install GRUB into the MBR? Once you have that last puzzle piece in place, you will have a full recipe for what you want to do.

BTW, to create that free standing GRUB boot floppy I used above, do this:
1/ Start with a running system that has GRUB installed - this is likely your current Arch system before you try any partition moving.
2/ cd into your /boot/grub directory
3/ Place a floppy in the drive
4/ Issue the commands:

# dd if=stage1 of=/dev/fd0 bs=512 count=1
# dd if=stage2 of=/dev/fd0 bs=512 seek=1

Wait until the write to the floppy completes and eject the floppy. That is it. You have a standalone bootable GRUB floppy.

Last edited by mac57 (2007-08-30 20:33:12)


Cast off the Microsoft shackles Jan 2005

Offline

Board footer

Powered by FluxBB