Do not restart Linux add disk, use Soft link for mount point expansion

Source: Internet
Author: User

When using Linux, there are times when the initial disk space allocation is not enough to be used in the case of the need to expand the mount point, which requires us to mount the new disk. But if we mount the disk while Linux is running, and Linux does not automatically recognize it without rebooting, then we need to use the following action to make Linux recognize the newly mounted disk without restarting it.

First, to view the host bus number, the disk must be connected by a bus:

[Email protected] ~]# ls/sys/class/scsi_host/host0 host1 host2

Second, re-scan the SCSI bus to add the device:

[[email protected] ~]# echo "---" >/sys/class/scsi_host/host0/scan[[email protected] ~]# echo "---" >/sys/clas S/scsi_host/host1/scan[[email protected] ~]# echo "---" >/sys/class/scsi_host/host2/scan

The SCSI bus is scanned because we are adding SCSI-type disks.

Again, look at the newly mounted disk, at which point Linux can already recognize the newly added disk:

[Email protected] ~]# fdisk-l

Finally, the newly mounted disks are partitioned, formatted, and mounted for use.

Added: expansion of Mount point

Suppose we had a mount point for/data, and/data is full, but still want to add new data under/data, you can use a soft link to/data the soft links to a new mounted disk partition for capacity expansion. The specific steps are shown below.

(1) Create a directory to use as a mount point later: [[email protected] ~]# Mkdir/newdata (2) mount the/DEV/SDB1 partition under/newdata: [[email protected] ~]# Mount/dev /sdb1/newdata (3) Create a soft link to/data to/newdata: [[email protected] ~]# ln-s/newdata/data

at this point in the/data directory there will be a soft link file NewData point to/newdata/, that is, NewData,/newdata/. This way, as long as we write to the/data/newdata file, the actual write to the/newdata/directory, equivalent to the original/data mount point we added a new part of the use of space. You can also specify the name of the soft link file manually:

[Email protected] ~]# ln-s/newdata/data/customed_name so there's/data/customed_name/newdata

Note: We can also take advantage of this use of soft links to link larger log files to mount points on disk partitions with ample storage space. For example, if the/opt/tomcat/logs/catalina.out log file is very large in size, and there is not much space left in the/opt mount point, there is an overflow risk that the log file can be soft-linked to another disk partition's mount point by the following two steps:

[Email protected] ~]# touch/newdata/catalina_link.out[[email protected] ~]# ln-sf/newdata/catalina_link.out/opt/ Tomcat/logs/catalina.out

There are also three points to note, one must first create a linked file, otherwise the soft link fails; the second is to force the soft link to empty before emptying the entire contents of the/opt/tomcat/logs/catalina.out log file; Third, you need to restart Tomcat Directory before you can continue writing to/opt/tomcat/logs/catalina.out.


Do not restart Linux add disk, use Soft link for mount point expansion

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.