Recreate Ubuntu partitions after installing Gentoo
Q I have a system with Ubuntu on a 500GB hard disk (dev/sda). I had been using Gentoo, which I like better, so I created a new partition and installed Gentoo. I used the original boot and swap partitions. Now running Gparted, I seem to have three partitions: /dev/sda1 (198.70GB) for /boot, /dev/sda3 (261.26GB) for root and /dev/sda2 (extended 5.80GB) with swap on extended /dev/sda5. Gentoo is working fine but I lost Ubuntu on /dev/sda1. I believe I didn't format when I repartitioned with Gparted, but there wasn't anything critical on the disk so I can reinstall. Can I repartition /dev/sda1, creating another partition for Ubuntu or whatever and leave a small boot partition? What size will the boot partition be and can I use the same boot partition for both distros Gentoo and whatever? Also, can I use the same swap partition for both distros? Finally, will the new partition scheme change the naming scheme in the Gentoo grub loader?
A Gparted creates a new file system on any new partition it creates, so you formatted sda1 without realising it. You can resize sda1, but you'll have to create another primary partition, which will mean you won't be able to create any further partitions, except by shrinking your swap partition. The x86 partition table is limited to four partitions. We get more by making one of them an extended partition and creating logical partitions within that. Resizing sda1 will leave free space outside of the extended partition. You could do this, and let Ubuntu install in the space you free up, and it's perfectly safe to share a swap partition between the two distros.
However, sharing /boot is more complex and generally not a good idea, especially as Ubuntu defaults to using no separate boot partition. A separate /boot is something of an anachronism, dating back to limited PC BIOSes that could only handle small disks, so the boot files had to be at the start of the disk. Nowadays, this is no longer applicable and I don't use a boot partition on anything. You have a couple of options. The best in the long term, but the most work, is to back up your Gentoo install, using either a second drive or a pile of DVDs, and repartition the disk from scratch.
As you're not running Windows, there's no need for a primary partition. By making every partition logical, you make the whole disk an extended partition to give yourself more flexibility. Then restore Gentoo from the backup before installing Ubuntu. The alternative is to shrink sda1 to around 50MB and install Ubuntu in the space this frees up. In this case, Grub's root for Gentoo will still be (hd0,0) but you'll need to change the root parameter passed to the kernel, probably to /dev/sda4. Either way, installing Ubuntu will set Grub to use its configuration: this should pick up your Gentoo installation and add it to the menu. If not, you can restore your Gentoo bootloader and add an entry to the menu to boot Ubuntu. To do this, boot from the Gentoo Live CD and run the following commands:
mount /dev/sda4 /mnt/gentoo # assuming your Gentoo installation is now on /dev/sda4 mount /dev/sda1 /mnt/gentoo/boot mount --bind /dev /mnt/gentoo/dev chroot /mnt/gentoo /bin/bash grub root (hd0,0) setup (hd0) quit exit
You'll probably recognise most of this from the Gentoo handbook - all you're doing is chrooting into your Gentoo system and running Grub to set it to boot from your Gentoo /boot partition. Once Gentoo is running, you'll need to edit /boot/grub/menu.lst to add an entry to boot Ubuntu (copy it from the existing Ubuntu menu.lst file).
- Sharing partitions between different flavours of Ubuntu
- Switch back to Windows after installing Ubuntu
- Installing a new kernel on Gentoo
- Ubuntu installation: GRUB being installed in Dell hidden partition
- How to configure Evolution on Ubuntu