Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am having trouble thinking through how I can achieve my partitioning goals.

Now my partitions are:

  • sda1 (winA) (primary)
  • sda2 (winB) (primary)
  • sda3 (/ for linux) (primary)

What I want to migrate into is (obviously partition numbers need not be exactly like that)

  • sda1 (winA) (primary)
  • sda2 (winB) (primary)
  • sda3 (/boot) (primary)
  • sda4 - extended which will contain
    • sda5 (/home)
    • sda6 (/)
    • sda7 (swap)

One way I have thought is:

  1. Create a new primary partition for /boot and split it from the root partition into the new one. It shouldn't be too hard. Then the disk will have 4 primary partitions.
  2. Somehow convert the root ubuntu partition from primary to extended.
  3. Split that last partition in 3 extended partitions (root, /home, swap) and split the contents there.

I am obviously stuck on the 2nd part.

Another way could be (maybe easier):

  1. Create an extended partition (or two)
  2. Split /home there
  3. Somehow move everything except /boot to the extended partition. This way /boot will stay on the primary partition that exists now, and will be shrunk as needed, and everything else will end up to the extended partitions.

This may sound better, but I'm not too sure how to do the 3rd part and I'd like some feedback.

Some details: The disk is almost empty, so I have space to move things around in it, shrink the linux partition etc. I don't want to touch the windows partitions in any way. Reinstallation is not an option. Also using a different partitioning scheme with fewer partitions is not an option (for example not having a separate /boot)

Any ideas?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The second solution (create/split/move) seems good. I tried to come up with some short guide, but be careful. Maybe wait for other answers/comments. Note: if you are not familiar with command line maybe, this guide is probably not what you are looking for.

A. Create the extended partition (sda4) for /home, / and swap as you described. Reboot to reload the partition table.

B. Format the new partitions with the chosen filesystem type, e.g. mkfs.ext4 /dev/sda5 and mkfs.ext4 /dev/sda6. Format the swap with mkswap /dev/sda7.

C. Then, in a first time you can safely copy the content from the old sda3 to the new partitions using cp -a. Something like:

mkdir /mnt/{oldslash,newhome,newslash}
mount --bind / /mnt/oldslash  #mounted without submount points like /dev /proc
mount /dev/sda5 /mnt/newhome
mount /dev/sda6 /mnt/newslash
cp -a /mnt/oldslash/* /mnt/newslash
rm -rf /mnt/newslash/home/*   # homes will be copied to newhome
cp -a /home/* /mnt/newhome

D. Verify that the layouts in newslash and newhome are ok. Check you don't have .* files in / and /home, or copy them to their respective targets. Then:

umount /mnt/oldslash
umount /mnt/newslash
umount /mnt/newhome

E. Then modify /etc/fstab considering the new partitions devices for /, /home (and swap).

F. Reboot and hope for the best. (Be sure to have some emergency live cd to repair your /etc/fstab in case something goes wrong and the system won't boot.)

G. Then, if everything goes as expected, you can remove everything except /boot from your boot (sda3) partition.

share|improve this answer
    
Thank you very much! Everything worked fine in the end. I only had a bit trouble with moving and resizing /boot because grub broke, but all that was needed was a reinstall of grub. –  george_k Jul 31 '11 at 19:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.