Ubuntu mounts other partitions to/home, replacing the contents of the current partition

Source: Internet
Author: User
Tags uuid rsync

Sometimes, when we install the system, we may not pay attention to the distinction between a certain point of small, leading to the end, our disk will not fit,

At this point, the face of the two choices is: either uninstall some software, or re-partition, reinstall the system, in fact, can also go to the other

The extra disk is divided into a zone, then replaces the current partition, rest assured that the data will not be lost, and all installed software can be used properly.

And I installed the system found that the root/directory is almost finished, and do not want to re-install the system, want to use a new partition to replace/home, as follows:

To mount the/home partition as an example, the other partitions should be similar.

The following 6 steps are required:

1, divide a new partition and format the file system format into your current system, such as ext3 or EXT4

2, back up your fstab file, then edit the file, mount the partition you just formatted as/media/home and restart

3. Use the rsync command to synchronize all files under/home to/media/home

4. Edit the Fstab file again, and mount it to change the/media/home you just made to/home

5, modify the current file/home for/old_home restart

6, delete/old_home

Depending on the action above, even if you make a mistake in one step, it's easy to change it back.

To elaborate on every point:

1, divided into a new partition and formatted as EXT4 file system

This is very good here, you can go to see, or search the FDISK command partition, to see it will be

2, back up your fstab file, then edit the file, mount the partition you just formatted as/media/home and restart

A) Find the UUID for this partition

Or use DF-VH to view

This will show you the area that you just separated,-H is the size of a person can read the format G to show the size of the disk, so you can find the area you just divided

b) Back up your fstab file

$ sudo cp/etc/fstab/etc/fstab.$ (date +%y-%m-%d)  

c) Compare the backup file to see if there is a difference and back up again

$ cmp/etc/fstab/etc/fstab.$ (date +%y-%m-%d)

d) with your favorite editor, open the file/ect/fstab as follows:

# (identifier) (location  , eg sda5)   (format, eg ext3 or EXT4)      (some settings) uuid=????????   /media/home    ext4          defaults       0       

Note: The UUID here and your division of the replacement of the area, as well as the file format to replace, the other is not the tube, save the exit

e) Create a new directory/media/home

$ sudo mkdir/media/home

f) Use the command:

$ sudo mount-a

To mount all of the partition devices and restart

3. Use the rsync command to synchronize all files under/home to/media/home

$ sudo rsync-axs--exclude= '/*/.gvfs '/home/. /media/home/.

Note: This adds--exclude to prevent the copying of. gvfs files, and copies the entire current home/home file to the/media/home

Check if synchronization is complete, enter:

$ sudo diff-r/home/media/home

4. Edit the Fstab file again, and mount it to change the/media/home you just made to/home

# (identifier) (location  , eg sda5)   (format, eg ext3 or EXT4)      (some settings) uuid=????????   /home    ext4          defaults       0       2

Note: Change the/media/home to/home here

5, modify the current file/home for/old_home restart

$ sudo rm-rf/old_home

  

Summary: For the Linux partition file system, like a drawer, you can plug and Play at any time, so, when you want to replace a partition, just do a few steps: 1, first mount a partition to/media/home

Then modify the partition table file/etc/fstab so that the mounted partition can be mounted automatically after the reboot, and then synchronize the partition data now like the update to the new partition, and then change the partition table again.

/etc/fstab for the real partition, and then reboot, OK, thank you!

Welcome everyone to guide Ah!

Ubuntu mounts other partitions to/home, replacing the contents of the current partition

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.