DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Build Multiple OS on A Host


Rearrange Disk Partitions

Start computer with gparted LiveCD and start GParted. The data partition is "/dev/sda1".

  1. Use "Resize/Move" to move /dev/sda1 partition to the end of the disk, before the swap partition. Shrink 928GB to 295GB, where 87GB are used. It took about 5 hours. You can only shrink the partition without moving them to the end, which will be faster than the previous "shrink + move" method.

  2. Right click /dev/sda1 -> Manage Flags, uncheck the "boot" flag.

  3. Create a new 50GB partition /dev/sda3 with EXT4 format, label it as "system1" and quit GParted;

  4. Start computer with new system (Mint 17 64bit here) LiveCD;

  5. Install Mint, select "Something else" when asked for "Installation type";

  6. Select /dev/sda3, click "change", then choose "Ext4 journaling file system" in "Use as", then choose "/" as the "Mount point", set /dev/sda1 mounted at /home and the old swap partition as swap;

  7. Install the system, then reboot;

Transfer old data

The old partition is mounted on /home, so the old home folder is now /home/home/chad. So we need:

  1. Move sub-folders of /home/home/chad to /home/chad;

  2. After some days when it's sure all data have been transfered, delete all folders and files under /home except "chad" (new $HOME folder);

Now on /dev/sda3, there is only one folder "chad". When install the second system, just mount /dev/sda3 to /home, everything will be ok.

Supported methods for disk partition management

Start "Terminal" on LiveCD.

  1. Detect disk: gdisk /dev/sda, notice your detection target is the whole disk instead of a partition, so "sda" can't be written as "sda1", or there will no MBR be found.

  2. Backup MBR: sfdisk -d /dev/sda > parts.txt, you can recover MBR with sfdisk /dev/sda < backup-sda.sfdisk , or with "dd" command:

    Backup: # dd if=/dev/sda of=/backup/mbr_sda.bak bs=512 count=1 Restore: # dd if=/backup/mbr_sda.bak of=/dev/hda bs=512 count=1

Install the Second OS

  1. Backup MBR and grub.cfg:

  2. Install centOS 6.5 Minimal with USB stick;

  3. Choose "Create Custom Layout", create a new partititon, mounted at /, and mount sdb1 as /home;

  4. Uncheck "Install boot loader on /dev/sdb";

  5. Reboot system. There is no change in boot menu, startup origin system (Mint 17), run update-grub with root.

  6. Reboot, you can see the CentOS is in boot menu.

Note: If you don't want an OS in your boot menu, rename its "boot" folder as "boot.old" (or anything else).

Ref:

How to Move Your Home Folder to Another Partition

Google: Linux系统启动过程

Linux系统启动过程

6 Stages of Linux Boot Process (Startup Sequence)

How To Backup & Restore Master Boot Record (MBR) In Linux

Linux: Copy Master Boot Record (MBR)

Manpage of sfdisk.

Boot loader Grub: how to repair, adapt or remove it



Published

Jul 18, 2014

Last Updated

Jul 18, 2014

Category

Tech

Tags

  • linux 158
  • os 2
  • partition 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor