UbuntuLinux move the root Partition

Source: Internet
Author: User
Since I used Ubuntu, I found that the dependency on Windows is getting smaller and smaller. I deleted my Vista two days ago, and now the system only has Ubuntu, so I want to switch Ubuntu from partition 3 during installation to partition 1. The results of the experiment are as follows: I only discuss technical issues. I shall not be liable for any data losses or other problems arising therefrom. 0: My configuration: partition: sda1 original Vista, sda2 extended partition, there are two logical partitions (sda5, sda6 ),

Since I used Ubuntu, I found that the dependency on Windows is getting smaller and smaller. I deleted my Vista two days ago, and now the system only has Ubuntu, so I want to switch Ubuntu from partition 3 during installation to partition 1. The experiment results are as follows:

Disclaimer: I will only discuss technical issues. I shall not be liable for any data losses or other problems arising therefrom.

0: My configuration: partition: sda1 original Vista,

Sda2 extended partition, which has two logical partitions (sda5, sda6 ),

Sda3 Ubuntu partition,

Sda4 Swap Partition

1: Start from LiveUSB (LiveCD.

Use the LiveUSB tool of the existing system and install the image to create LiveUSB. Of course, you can also use LiveCD. We recommend that you use LiveUSB (LiveCD may not be able to create a directory when mounting the partition );

Select your boot device in the boot options (use the Del key, F2 key, or F12 key to enter the boot options, depending on the machine)

2: Mount sda1 and sda3.

You can mount the file in the file browser or manually use the mount command.

3: Move a file.

Use cp-ax/media/to partition 3/*/media/to partition 1/"partition 1" is the directory mounted by sda1, and "partition 3" is the directory mounted by sda3, adding the-ax parameter ensures that attributes are retained during replication.

4: reinstall grub.

The purpose of this step is to ensure that grub looks for the menu. lst file from sda1, rather than the original sda3.

Method: Still on LiveUSB, open the terminal and enter the sudo grub command. It may take a while before the grub> prompt appears;

Enter find/boot/grub/stage1. If two items (hd0, 0) (hd0, 2) appear, it indicates that you have copied them;

Then input: root (hd0, 0), indicating that the boot partition is The 0th partition on the 0th hard disk (0 represents 1, 1 represents 2 in grub, and so on );

Then enter setup (hd0) and install grub on The 0th hard disks.

5: Modify menu. lst.

The key to this step is the ability to start a new system.

Open the terminal;

Change the original menu. lst rename: Enter the/boot/grub directory under partition 3 in the terminal and use sudo mv menu. lst newfilename. lst name change (newfilename is any other name)

Run the cd command to go to the/boot/grub directory under the sda1 Mount directory;

View the partition UUID: sudo ls-l/dev/disk/by-uuid, and record the UUID of sda1 and sda3 (Partition Number sdx at the end of the row );

Modify menu. lst on partition 1:

Sudo cp menu. lst menu. lst. backupfile (Backup menu. lst file)

Sudo gedit menu. lst, replace the UUID of sda3 with the UUID of sda1, save it, and close gedit and terminal;

Note: Some grub may not use UUID to identify partitions. You can change/dev/sda3 in menu. lst to/dev/sda1.

6: restart. Start from hard disk (change back to your settings and stop using LiveUSB)

If it succeeds, go to any directory to check the remaining space. If it is consistent with the remaining space of the new partition, this step will start with the new partition. If there is no problem after you use it for a while, you can delete the original sda3 for other purposes.

If it fails, restore menu. lst on partition 3, and use root (hd0, 2) under the grub command, and then setup (hd0) to reinstall grub.

If you have any questions, you are welcome to discuss them actively.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.