Mount other partitions to/home in ubuntu to replace the content of the current partition.
Source: Internet
Author: User
Mount other partitions in ubuntu to the home, and replace the content of the current partition. sometimes, when we install the system, we may make a small distinction because we didn't pay attention to it, we can't afford that disk. at this moment, we face two choices: either uninstall some software, or re-partition and reinstall the system. In ubuntu, We mount other partitions to/home, replace the current partition content. sometimes, when we install the system, we may not be able to distinguish a specific partition because we did not pay attention to it, there are two options: either uninstall some software, or re-partition and reinstall the system. In fact, you can also split other redundant disks into one partition and then replace the current partition, rest assured that data will not be lost, and all installed software can be used normally. I installed the system and found that the root/directory was quickly occupied and I didn't want to reinstall the system. I wanted to replace/home with a new partition as follows: here, the mount/home partition is used as an example. for other partitions, perform the following six steps: 1. separate a new partition and format it as the file system format of your current system, for example, ext 3 or ext4 2, back up your fstab file, edit and modify 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/media/home to/home 5, modify the current file/home to/old_home and restart 6. delete/old_home based on the above Operation. even if an error occurs in one step, it is easy to modify it back to elaborate on each point: 1, split a new partition and format it as the ext4 file system. this is a good example here. you can check it out, or search for the fdisk command partition to see it, back up your fstab file, edit and modify the file, mount the partition you just formatted to/media/home, and restart a) find the uuid [plain] xiaobing @ zhang :~ $ Sudo blkid [sudo] password for xiaobing:/dev/sda1: UUID = "00087570000398CE" TYPE = "ntfs"/dev/sda5: UUID = "000B32AB00053B61" TYPE = "ntfs"/dev/sda6: UUID = "000D000B000602E6" TYPE = "ntfs"/dev/sda7: UUID = "uid" TYPE = "ext4"/dev/sda8: UUID = "5803947b-195a-41ca-b0fd-d8a47ccd8095" TYPE = "swap"/dev/sda9: UUID = "8cbedd1f-6da5-40ca-add5-16af9c2eaa7e" TYPE = "ext4"/dev/sda10: UUID = "1f0000485-6400-4a67-bc7d-a1fab5f50db1" TYPE = "ext4" or view the zone you just allocated using df-Vl, -h is to display the disk size in a readable size format G, so you can find the partition B you just divided) back up your fstab file [plain] $ sudo cp/etc/fstab. $ (date + % Y-% m-% d) c) check whether the backup files are different, [plain] $ cmp/etc/fstab. $ (date + % Y-% m-% d) open the file/ect/fstab in your favorite editor and enter the following: [plain] # (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings) UUID =? ??????? /Media/home ext4 defaults 0 2 Note: replace the UUID and your partition, and the file format. save and exit e) create a directory/media/home [plain] $ sudo mkdir/media/home f) and run the command [plain] $ sudo mount-a to mount all the partition devices, restart 3 and run the rsync command to synchronize all files in/home to/media/home [plain] $ sudo rsync-aXS -- exclude = '/*/. gvfs '/home /. /media/home /. note: add -- exclude to prevent replication. copy the entire/home file to/media/home to check whether synchronization is complete. enter: [plain] $ sudo diff-r/home/media/h Ome 4, edit the fstab file again, mount it to/media/home to/home [plain] # (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings) UUID = ???????? /Home ext4 defaults 0 2 Note: Change/media/home to/home 5, modify the current file/home to/old_home and restart [plain] $ cd/& sudo mv/home/old_home & sudo mkdir/home. note: rename the current/home to/old_home. This does not delete your content. restart 6 and delete/old_home [plain] $ sudo rm-rf/old_home. conclusion: for linux partition file systems, like drawers, they can be plugged or unplugged at any time. Therefore, when you want to replace a partition, you only need to perform the following steps: 1, first mount a partition to/media/home and then modify the partition table file/etc/fstab so that the mounted partition can be automatically mounted after restart. then, synchronize all the currently updated partition data to the new partition, and then change/etc/fstab to the real partition again. then restart OK. thank you! Thank you for your advice!
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.