Welcome: Hunan Intelligent Applications Tecgnology CO.,ltd.-HNIAT.com
Language: Chinese ∷  English

Basic knowledge

Linux mount--the original file is gone after the new disk is mounted in the directory

When using a server, the hard disk that comes with the server is often small and the storage space is limited. Generally, the hard disk must be mounted.

The mounting steps are as follows:

1. View hard disk information

# fdisk -l
1
2. Suppose now want to mount /dev/sdb to the new directory /data , we need:

# mkdir /data //Create a new hanging point
# mount /dev/sdb /data //Mount the disk
1
2
But sometimes we will encounter such a situation: the mount point is an existing non-empty directory

At this time, we need to pay attention to copy the files in the directory to other directories before performing the mount operation.

Assuming that the non-empty directory to be mounted is /oradata, the operation is as follows:

# mkdir /new //Create a temporary directory

# cp -R /oradata/* /new //Copy all data under /oradata to /new

# rm -rf /oradata/* //Make space for the original hard disk (optional)

#mount /dev/sdb /oradata //Mount /oradata to the new hard disk

# cp -R /new/* /oradata //Copy all data under /new back to /oradata

# rm -rf /new //delete temporary directory
1
2
3
4
5
6
7
8
9
10
11
What if, unfortunately, there are files in the mounted path, and other files are accidentally overwritten?

Don't panic! Data is not lost.

For example, if it is mounted under /home, all the files under the original /home are gone.

At this point we just need to unhook:

# umount /dev/sdb /home
1
You can also omit the mount point and write it directly as:

# umount /dev/sdb
1
After unhanging, the address of the operating system pointing to /home has changed, and the original files can be seen again.
———————————————
Copyright statement: This article is an original article by CSDN blogger "Luminous Rabbit Paper" and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/Ruishine/article/details/115180310

CONTACT US

Contact: Manager Xu

Phone: 13907330718

Tel: 0731-22222718

Email: hniatcom@163.com

Add: Room 603, 6th Floor, Shifting Room, No. 2, Orbit Zhigu, No. 79 Liancheng Road, Shifeng District, Zhuzhou City, Hunan Province

Scan the qr codeClose
the qr code