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

How to upgrade backup in CentOS7 system

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

Share

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

This article mainly introduces how to upgrade the backup of the CentOS7 system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

I. system version

1) CentOS 7.1.1503

2) CentOS 7.2.1511

Second, backup the current operating system through the tar command

# tar cvpzf / mnt/linuxbackup.tgz--exclude=/proc-exclude=/lost+found-exclude=/mnt/linuxbackup.tgz--exclude=/mnt-exclude=/sys /

The command explains:

Packaging programs commonly used in tar:linux

Cvpzf: is the parameter of tar

C-create a new document

Output relevant information during v-processing

P-means to maintain the same permissions

Z-call gzip to compress the archive file, and when combined with-x, call gzip to complete the decompression

F-operate on ordinary files

Linuxbackup.tgz: the file name to be packaged

-- exclude=/proc: exclude the / proc directory, do not package this directory, and do the same later. Remember to exclude the filename of your own package.

/: means to package all files in the linux root directory. Of course, excluded files are not included.

The whole process means to create a new file name linuxbackup.tgz compressed file, which saves the files after excluding the specified directory, and saves the original permission settings, here you must write down the excluded directory, which needs to be created manually when restoring. It is necessary to choose which catalogs should be excluded because of the different environment and work. Just wait for a certain amount of time after execution, copy the linuxbackup.tgz to another place, and the backup is complete.

It is important to note: do not do anything during the packaging process, otherwise some files will be modified, tar will prompt an error after the backup, and the same is true for recovery.

Third, upgrade the operating system version to CentOS 7.2.1511 by YUM command

# mount-t iso9660-o loop xxx.iso / mnt/iso# Mount the ISO image file to / mnt/iso#vim / etc/yum.repos.d/CentOS-Base.repo [local-source] name=CentOS-$releasever-Basebaseurl= file:///mnt/isogpgcheck=1enabled=1gpgkey=file:///mnt/iso/RPM-GPG-KEY-CentOS-7#yum clean#yum update-y

4. After reboot, the system was successfully upgraded to CentOS 7.2.1511.

Now restore the system to CentOS 7.1.1503 before the upgrade, and restore the files we backed up before with the tar command

# tar xvpfz / mnt/linuxbackup.tgz-C /

After the execution, do not focus on starting the system, but remember to create the directory that was excluded during the backup and create it manually. For example, if we exclude the above, we need to create

# mkdir / proc#mdkir / lost+found#mkdir / mnt#mkdir / sys

Sixth, restart the system, found that the system boot card in the last step, the graphical interface can not be fully displayed, through the SSH connection is also rejected.

Mount the CD, enter the rescue mode, mount the hard disk partition to / mnt, and modify the system boot level to 3 (character interface).

# mount / dev/mapper/centos-root / mnt/root#cd / mnt/root/etc/systemd/system/#rm default.target# ln-sf / lib/systemd/system/multi-user.target default.target

# systemd uses links to point to the default run level, which is determined in the / etc/systemd/system/default.target file.

After restart, the character user login interface is displayed, but the user is unable to log in, indicating that the password is wrong.

9. Start the single-user mode and change the root user password.

1) start the system and press the e key to enter edit mode

2) add the following at the end of the parameter line where linux16/vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/centos-root rord.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quietLANG=en_US.UTF-8 is located: init=/bin/sh

3) press Ctrl+x to start to shell

4) Mount the file system in writable mode: mount-o remount,rw /

5) run passwd and follow the prompts to change the root password.

6) how to enable selinux before the system, you must run the following command, otherwise you will not be able to start the system properly: # touch / .autorelabel. Because I was a personal experimental system, I shut down SELINUX directly.

7) run the command exec/sbin/init to start normally, or restart with the command exec/sbin/ reboot

10. Log in successfully through the new password after restart, the system prompts some errors, follow the prompts to execute the command one by one, repair successfully, execute startx to start the graphical interface successfully, and the system has successfully restored to CentOS 7.1.1503.

Restore the system boot level to 5 (graphical interface)

# systemctl set-default graphical.target Thank you for reading this article carefully. I hope the article "how to upgrade and backup the CentOS7 system" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

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

Servers

Wechat

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

12
Report