Migrating the/home directory to a new hard disk partition summary-no backup

Source: Internet
Author: User

Had a day, and finally successfully migrated. Since there was no backup process in the beginning, it was very tortuous.

I hope this article is helpful to those friends who don't have a backup habit.

Preparatory work:

sudo vim/etc/fstab

In the file, add:

/dev/sdb8/home ext4 USER,RW 0 2

There's actually a problem here, and we'll mention it later.

A new Linux partition, here my new partition is SDB8, the individual is different. I am using the EXT4 format, note to new, do not have bad blocks, preferably reformatted. I just because of not formatted, eat a loss, logo interface on the prompt mount error, really chilling.

Decisive into the CTRL +alt + F1, command line mode, execute mount-a, the system will prompt for an instruction, I entered this command, found that there are bad blocks, decisive formatting

How to format, this is not explained in detail here. With the command mkfs can, on the safe side, I also use sudo fdisk/dev/sdb to see the partition table situation, also normal.

The next step in this article is to explain how to successfully migrate/home to a new partition without backing up

The format is complete, the difference is normal, then restart. Then there's the problem: You can't log in to the desktop. Always want you to enter the password, the password is not a problem, because tty1, that is, the beginning of the command line can login.

Unable to log into the desktop, there are many online, there are many ways. I have also met once before, because I unscrupulous to remove the various dependencies, resulting in system file corruption, even though there are many big God, I can only say is back to the weak, helpless, I can only reload, the birth of the partition table is damaged in the case of reloading the log. So please be careful when you delete dependencies, unless you remember the names of these dependent packages, you can re-install them back.

So this time can not log on to the desktop, the reason is completely different, because I found that I use the visitors can be logged in, that the desktop system is not damaged, then those on the Internet on the re-intall desktop commands, all can be ignored, because the medicine is not disease, we have to focus on those, modify the home directory configuration file command, such as: RM ~/. Xauthority and so on, this command is only a reference, but the meaning is very important, the following will be mentioned.

Then the problem again, since the configuration file, I now only in fstab add the/home directory, there is no master directory, of course, the system can not login, so at home and under, MkDir rainey/. So the main directory is set up, reboot, expected, a little change is not, why, because there is no. Xauthority This configuration file, but do not say on the Internet to delete this file, I would like to add here, the reason I will talk about, I first to add this file under the ~ (You can search for this file in the/directory, and then copy to your home directory), and then restart, the situation is: you can log in to the desktop, But it's dead. That is, the password interface has passed, the desktop control is not activated, equivalent to dead.

Here is the question of the permissions of the relationship, Ls-l/home, you will find that your master directory owner is actually root (even if the fstab under my parameter write usr, or the root permission to hang up, this does not know why Ubuntu to do so), this is naturally problematic, Linux is good in its mount system, the original/home directory file is still there, but not hanging at the point. In order to confirm whether it is a permission problem, I put the sentence of the fstab under/home partition, and then restart, the system will automatically find/partition under the/home directory (the original default to the site).

Execution: Ls-al,:

Sure enough, Rainey for the owner.

So come back and re-fstab the line that you just commented on, restart and execute:

sudo chmod Rainey:rainey/home/rainey

and then reboot. Smooth access to the desktop.

Back to think about it, whether we start with this command, or with sudo chmod 777/home/rainey such a command, the problem will be solved, perhaps, because after all. Xauthority This configuration file is automatically generated, perhaps after the creation of the main directory, directly change the permissions, can let us less detours, the reader to try it yourself.

But this is not the end of the operation, because a lot of configuration files in the home directory is very useful, many of our development use of the environment configuration is inside, so I am going to the original home directory. * These profiles are in my new home directory, so I need to go back to the original home directory (the method has been mentioned above), Then back up to a different partition (as long as it is not in the original/home directory), and then copy the backup configuration files to the new home directory. But will find that many of your applications can not run, will error, the first consideration of the issue of permissions, many directories are root users, to their own users.

Although this solves most of the problem of the program error. But my main environment as (Android Studio) still error, said ~/. Androidstudio1.03/system/tmp/*.sh (the specific name is too long forgotten), this file permission is not enough, suggest me to reload, good, I listen to it, re-install as, Pit Dad, or report the same problem, that explains the configuration has a problem. Originally thought is this sh file problem, so I wrote a sh, found also can not execute. The description is not a file issue. And then found/bin/bash *.sh can be executed,./*.sh is not, so try to add in the PATH environment variable./, the results found still not. So try to put *.sh Mobile/directory execution, found./*.sh. Suddenly, suddenly enlightened, must be home/home directory, executable permissions configuration and other directories are not the same, but/home under the directory are Rainey users of Ah, also contains the X permission ah. Think of the solution Ah, Mount has a problem, because home/home is not the same as other directories, other configurations are the same AH. And then carefully recall the whole process, suddenly think of a point, fstab, yes, is the beginning I mentioned that the following will focus on the sentence Mount statement, mount parameters out of the question, Pro, after the parameter can not write RW ah (even if you put /home under all the things are changed to 777, this one also can not make a pass AH) , because of this sentence, the whole let me toss a day ah. The correct mount statement is given below:

/dev/sdb8/home ext4 Errors=remount-ro 0 1

This sentence is the positive solution ah. Hard day, write some experience, that is the lesson, but also accumulation.

Migrating the/home directory to a new hard disk partition summary-no backup

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.