Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux system moves root partition

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you the mobile root partition of the Linux system, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The root partition is the root partition, which is a name for the system of the linux platform. The root partition is the most important partition in the Linux system, so how to move the root partition of the Linux system?

Disclaimer: I only discuss technical issues. I do not bear any responsibility for data loss and other problems caused by it.

0: my configuration: partition: sda1 original Vista

Sda2 extended partition with two logical partitions (sda5,sda6)

Sda3 Ubuntu partition

Sda4 Swap partition

1: start from LiveUSB (LiveCD).

Use the existing system's production LiveUSB tool and installation image to make LiveUSB. Of course, you can also use LiveCD. It is recommended to use LiveUSB (LiveCD may not be able to create a directory when the partition is mounted)

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

2: Mount sda1 and sda3.

There is nothing to say about this. You can mount it in a file browser or use the mount command manually.

3: move the file.

Use the cp-ax / media/ partition 3Accord * / media/ 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 the attributes are retained during replication.

4: reinstall grub.

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

Method: still on LiveUSB, open the terminal, enter the sudo grub command, it may take a while, and then the grub > prompt appears

Type find / boot/grub/stage1, and if there are two items (hd0,0) (hd0,2), it means you have no problem with copying.

Then enter: root (hd0,0), indicating that the boot partition is the 0th partition on the 0th hard disk (grub uses 0 for 1 and 1 for 2, and so on)

Then type: setup (hd0) to install grub on the 0th hard drive.

5: modify menu.lst.

This is the most critical step, which is the key to whether it can be started from the new system.

Open the terminal

Rename the original menu.lst: enter the / boot/grub directory in the partition 3 directory in the terminal, and use sudo mv menu.lst newfilename to rename the menu.lst (newfilename to any other name)

The cd command goes to the / boot/grub directory under the sda1 mount directory

Look at 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 line)

Modify the menu.lst on partition 1:

Sudo cp menu.lst menu.lst.backupfile (backup menu.lst files)

Sudo gedit menu.lst, replace all UUID of sda3 with UUID of sda1, then save and close gedit and terminal

Note: some people's grub may not use UUID to identify the partition, you can directly change the / dev/sda3 in the menu.lst to / dev/sda1.

6: restart. Boot from the hard drive (change back to your settings and no longer boot with LiveUSB)

If successful, enter any directory to check the remaining space. If it matches the remaining space of the new partition, this step will enter the new partition. If you have no problem after using it for a period of time, you can delete the original sda3 for other use.

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

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The above content is the mobile root partition of the Linux system. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report