Automatic mount of hard drive in linux-rhel7.2

Source: Internet
Author: User
Tags uuid

Experimental content:

Mount Partitions in Rhel 7.2

Lab Environment:

VMware Workstation 12

Virtual machine configuration:

Os:rhel 7.2 x64

Memory: 2G

Cpu:2 Nuclear

HDD: SDA 40G

Sda1/boot 524M

sda2/23.6g

Sda3 Swap 1073M

CD/DVD: Mounted Image rhel7.2

Network adapter: Bridging, replicating physical NIC connection status


First, add the new hard disk 20G in the server shutdown state.

In edit virtual machine settings, add the hard disk.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/30/wKiom1cWAkTiy-r3AAF-ApjxNpM574.png "title=" 1.png " alt= "Wkiom1cwaktiy-r3aaf-apjxnpm574.png"/>


Leave the default selection, next

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/2E/wKioL1cWAz3zfytFAABJcADP93k075.png "style=" float: none; "title=" 2.png "alt=" Wkiol1cwaz3zfytfaabjcadp93k075.png "/>


Create a new disk, next

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/2E/wKioL1cWAz6BIENHAABLzTonHm8552.png "style=" float: none; "title=" 3.png "alt=" Wkiol1cwaz6bienhaablztonhm8552.png "/>


Specify size 20G, select multi-file mode

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/2E/wKioL1cWAz6jeV_pAABSQejCr0M102.png "style=" float: none; "title=" 4.png "alt=" Wkiol1cwaz6jev_paabsqejcr0m102.png "/>


Specify the disk name to complete

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7F/2E/wKioL1cWAz7QQC1nAABQiYKtYns421.png "style=" float: none; "title=" 5.png "alt=" Wkiol1cwaz7qqc1naabqiyktyns421.png "/>


After you create a new disk, start the virtual machine

Viewing the current Mount situation

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/2E/wKiom1cV2hnC57aQAAAzJSpdxgA908.png "title=" 1-13- After rebooting, view mount. png "alt=" Wkiom1cv2hnc57aqaaazjspdxga908.png "/>



Temporarily mount the newly created partition, and now restart the server.

[[Email protected] ~] #init 6


After the server restarts, view the current device mount condition

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/2E/wKiom1cV2hnC57aQAAAzJSpdxgA908.png "title=" 1-13- After rebooting, view mount. png "alt=" Wkiom1cv2hnc57aqaaazjspdxga908.png "/>


View hard disk Partitions

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/2F/wKioL1cWCE2QWPehAAB2cW5EpjM662.png "title=" 1-13- Partition. png "alt=" Wkiol1cwce2qwpehaab2cw5epjm662.png "/>


Create primary partition 650 on new hard disk SDB) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/7F/31/wKiom1cWBivBSsjHAABi9x8RJ-s928.png " Style= "Float:none;" title= "1-13-Create primary partition. png" alt= "Wkiom1cwbivbssjhaabi9x8rj-s928.png"/>


Create an extended partition

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/31/wKiom1cWBivTUnGeAABH6Qzz8wk217.png "title=" 1-13- logical partition creation. png "style=" Float:none; "alt=" Wkiom1cwbivtungeaabh6qzz8wk217.png "/>


Creating a logical drive

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/31/wKiom1cWCJWwZjixAAA83i0Lnak338.png "title=" 1-13- Logical partition. png "alt=" Wkiom1cwcjwwzjixaaa83i0lnak338.png "/>


Print partition list, save exit

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/31/wKiom1cWCW2ikoodAABO3R38PuM053.png "title=" 1-13- View a list of partitions and save the. png "alt=" Wkiom1cwcw2ikoodaabo3r38pum053.png "/>


View a list of partitions under a new hard disk

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/2F/wKioL1cWDJDRs1tLAAAUeftp0W4620.png "title=" 1-13- New hard disk partition. png "alt=" Wkiol1cwdjdrs1tlaaaueftp0w4620.png "/>


If it is not displayed, use the following command to refresh

[Email protected] ~]# Partprobe/dev/sdb

Formatting a newly created partition

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7F/31/wKiom1cWC-vjFqdUAAB5IDwttn4112.png "title=" 1-13- Format the partition. png "alt=" Wkiom1cwc-vjfqduaab5idwttn4112.png "/>


To create a mount point

[Email protected] ~]# MKDIR/SDB1

[Email protected] ~]# MKDIR/SDB5

Mount a new partition

[Email protected] ~]# MOUNT/DEV/SDB1/SDB1

[Email protected] ~]# MOUNT/DEV/SDB5/SDB5

View New partition Mount status

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7F/31/wKiom1cWDAyD5q2IAAA1keqaCMc525.png "title=" 1-13- Mount points after the. png "alt=" Wkiom1cwdayd5q2iaaa1keqacmc525.png "/>

Restart the virtual machine to view the newly created partition

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/2E/wKiom1cV2hnC57aQAAAzJSpdxgA908.png "title=" 1-13- After rebooting, view mount. png "alt=" Wkiom1cv2hnc57aqaaazjspdxga908.png "/>


As you can see, the newly created partitions/sdb1 and/SDB5 are not mounted at this time.

Now edit/etc/fstab to test boot automatically mount the newly created partition

[[Email protected] ~] #vim/etc/fstab

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/2C/wKioL1cV3EHhB18yAABQhSJ5kWk060.png "title=" 1-13- Auto-mount. png "alt=" Wkiol1cv3ehhb18yaabqhsj5kwk060.png "/>


"ZZ" to save the exit.

Restart the server to view the Mount status (following restart of the server)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/2E/wKiom1cV3SiCg7njAABDcxmSQR4139.png "title=" 1-13- The new partition is mounted. png "alt=" Wkiom1cv3sicg7njaabdcxmsqr4139.png "/>


At this point, the automatic mount of the new partition is implemented.


The lack of this mount:

Insufficient reason: The server is not only one hard disk, example: There are four hard drives. In the process of hard disk maintenance, four hard drives are prone to plug dislocation.

How to ensure that hard disk maintenance is not confusing?


Automatic boot mount with UUID

UUID Action

The UUID is a string that identifies the storage device in your system and is designed to help the user uniquely determine all the storage devices in the system, regardless of their type. It can identify DVD drives, USB storage devices, and hard drive devices in your system.

Characteristics:

It's really the only sign

Many of the key features in Linux are now dependent on UUID

Red Hat 5 is mounted via a label, starting with Red Hat 6, which is basically a UUID.

Get the UUID of the device

[Email protected] ~]# Blkid |grep SDB

/dev/sdb1:uuid= "69d99306-6399-4da4-8d6b-b645d0fe5440" type= "XFS"

/dev/sdb5:uuid= "64e82a13-24d3-4d71-bc5a-d4ae3984e24b" type= "XFS"

After getting the UUID to the device, start editing in/etc/fstab

[[Email protected] ~] #vim/etc/fstab

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/2E/wKiom1cV4d2jcycQAABFCFq7wKE119.png "title=" 1-13- Use the UUID mount. png "alt=" Wkiom1cv4d2jcycqaabfcfq7wke119.png "/>


That is

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/2C/wKioL1cV4r6wxZXxAAA6V9go5KU045.png "title=" 1-13- The UUID has been used instead of. png "alt=" Wkiol1cv4r6wxzxxaaa6v9go5ku045.png "/>

Restart the server again to verify the Mount effect

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/2E/wKiom1cV4svhGbo-AAA7lqVrujQ707.png "title=" 1-13- Use the UUID to mount the effect. png "alt=" Wkiom1cv4svhgbo-aaa7lqvrujq707.png "/>


This time, we can guarantee


Special Mount Method:

[[Email protected] ~] #mount-T XFS/DEV/SDB5/SDB5

-t specifies the file type to mount

。 The ISO file is similar to the real-world CD-ROM drive, and if you encounter a disc image on a real server:

[[Email protected] ~] #mount-O loop rhel-server-7.2-x86_64-dvd/mnt

Implement read-only mount (must be mounted before a read-only image can be mounted)

[[Email protected] ~] #mount-o REMOUNT,RO/SDB5


Reprint Annotated Source! Thank you!

http://renzhe27.blog.51cto.com/1735477/1765489



This article is from a "non-secure" blog, so be sure to keep this source http://renzhe27.blog.51cto.com/1735477/1765489

Automatic mount of hard drive in linux-rhel7.2

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.