CentOS server hard disk mounting

Source: Internet
Author: User
Tags centos server
A CentOS server has been deployed recently. the requirement is that disks other than the system will be automatically mounted after startup. This should be a common requirement ~~ Online implementation is relatively simple, but there is a problem! Finally, the problem is solved. Now it's easy for everyone. After the system is installed, it is not mounted by default... information &

A CentOS server has been deployed recently. the requirement is that disks other than the system will be automatically mounted after startup. This should be a common requirement ~~ Online implementation is relatively simple, but there is a problem! Finally, the problem is solved. Now it's easy for everyone.

After the system is installed, no other disks are attached by default. At this time, you cannot use other disks. we need to manually mount them.

(1) find out what our disks are!


[Root @ xxxxxxxxxx ~] # Fdisk-l
 
Disk/dev/sda: 82.0 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0xf0b1ebb0
 
Device Boot Start End Blocks Id System
/Dev/sda1*1 9965 80040960 7 HPFS/NTFS
 
Disk/dev/sdb: 500.1 GB, 500107862016 bytes
222 heads, 30 sectors/track, 146662 cylinders
Units = cylinders of 6660*512 = 3409920 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0xf0b1ebb0
 
Device Boot Start End Blocks Id System
/Dev/sdb1 1 15376 51200000 5 Extended
/Dev/sdb2 15376 52277 122880000 7 HPFS/NTFS
/Dev/sdb3 52277 89178 122880000 7 HPFS/NTFS
/Dev/sdb4 89178 146663 191424512 7 HPFS/NTFS
/Dev/sdb5*1 13839 46080000 83 Linux
/Dev/sdb6 13840 15376 5116928 82 Linux swap/Solaris


The above command can be used to view all the storage media of the current system. The server has two hard disks, one FTP and the other for development, now the/dev/sdb5 and/dev/sdb6 file systems are mounted by default.

My requirement is to mount the four disks:/dev/sda1/dev/sdb2/dev/sdb3/dev/sdb4.

Now that we know the disk we want to attach, mount it now ~~~

(2) manually mount the file system


[Root @ xxxxxxxxxxxx ~] # Mount
/Dev/sdb5 on/type ext4 (rw)
Proc on/proc type proc (rw)
Sysfs on/sys type sysfs (rw)
Devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)
Tmpfs on/dev/shm type tmpfs (rw)
None on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)
Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

Mount command used to mount the file system

By default, no parameters are displayed. the mounted file system is displayed. Specific mount parameters, usage! There are a lot of online users ~~


[Root @ xxxxxxxxxxx ~] # Mkdir/mnt/ftp

First, create a directory. the file system we will mount will appear in this directory. do not mount the file system directly to the root directory!


[Root @ xxxxxxxxx mnt] # mount-t ntfs/dev/sda1/mnt/ftp
The command is simple. if the ftp disk type is ntfs, you need to specify the device to be mounted and then the target path to be mounted.

Unfortunately, after CentOS 6 is installed, the ntfs file system is not supported by default. at this time, we need to download a file.

NTFS-3G

With this stuff, we can mount the ntfs file system on CentOS.

Http://www.tuxera.com/community/ntfs-3g-download/

Download the most stable version


Tar zxvf ntfs-3g-20xxxxxx.tgz
 
Cd ntfs-3g-20xxxxxx
 
./Configure
 
Make
 
Make install
The installation is successful without any exceptions.

Mount-t NTFS-3G/dev/sda1/mnt/ftp
Okay? Now I want to automatically mount those devices when I start them!
Continue ~~~

In this case, we need to edit

/Etc/fstab
Open my dear VIM. it looks like this.


#/Etc/fstab
# Created by anaconda on Mon Oct 10 17:43:24 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
UUID = a3e8bcd2-d495-4cd0-8cda-8c701503a5a7/ext4 ULTS 1 1
UUID = 036ac161-13e5-490d-b579-9755f997efe0 swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0

The file will be scanned when the system starts. you just need to write the file system you want to mount to this file ~~
By the way, if you are a desktop user, you must be cautious. if not, you must reinstall the system or resume Live CD. The server is okay. if you make an error, the server will pass it if it is not checked, and the system will not become inaccessible.

The part starting with # in the file is Comments. this rule should be very familiar.


#/Etc/fstab
# Created by anaconda on Mon Oct 10 17:43:24 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
UUID = a3e8bcd2-d495-4cd0-8cda-8c701503a5a7/ext4 ULTS 1 1
UUID = 036ac161-13e5-490d-b579-9755f997efe0 swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
 
/Dev/sdb2/mnt/disk1 NTFS-3G ULTS 0 0
/Dev/sdb3/mnt/disk2 NTFS-3G defaults 0 0
/Dev/sdb4/mnt/disk3 NTFS-3G defaults 0 0
/Dev/sda1/mnt/ftp NTFS-3G default 0
After editing, as shown above, the last four lines are the file system I want to mount.
Format:

<设备> <挂载目的路径> <挂载系统的类型> Default 0 0

There are many details about the specific format (various settings, encoding, permissions ...), But this basically meets the normal needs!

Now it's done ~~~~ Restart!

Normally, you are right. if you are right! There is no problem. Normal ~ If I am right, I won't write this. now my machine has a problem and it will be wrong after I start it!

No mount is available in the changed mount location ~~~~

View
Fdisk-l

And

More/etc/fstab

We will find the following comparison.

The previous sda becomes the current sdb

The previous sdb becomes the current sda

After several shutdowns, I found that the order was random on my machine ~~~
I am so confused, why are you so embarrassed ~~~~

I thought of an immature method. I wrote a script and executed it after scanning the disk Mount file. I manually checked and mounted it !!


Finally, the problem is solved. The/etc/fstab file reminded me that,


UUID = a3e8bcd2-d495-4cd0-8cda-8c701503a5a7/ext4 ULTS 1 1
UUID = 036ac161-13e5-490d-b579-9755f997efe0 swap defaults 0 0
Here we take two lines and find that the ext4 file system is mounted differently ~~ Why?
What is UUID? I have found all the uuid I want to mount. Is this the case settled?


UUID is a globally unique identifier. it is a string of characters.

Run the following command to view the UUID of your computer's file system.


[Root @ xxxxxxxxxxxxx ~] # Blkid-o list
Device fs_type label mount point UUID
------------------------------------------------------------------------------
/Dev/sda1 ntfs FTP/mnt/ftp 84582A24582A1608
/Dev/sdb2 ntfs/mnt/disk1 B602ABF202ABB5B1
/Dev/sdb3 ntfs/mnt/disk2 54C2B9ADC2B99428
/Dev/sdb4 ntfs/mnt/disk3 C00E001C0E000E5A
/Dev/sdb5 ext4/a3e8bcd2-d495-4cd0-8cda-8c701503a5a7
/Dev/sdb6 swap 036ac161-13e5-490d-b579-9755f997efe0

Please check the instructions for using the blkid command ~~
Now let's change our/etc/fstab


#/Etc/fstab
# Created by anaconda on Mon Oct 10 17:43:24 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
UUID = a3e8bcd2-d495-4cd0-8cda-8c701503a5a7/ext4 ULTS 1 1
UUID = 036ac161-13e5-490d-b579-9755f997efe0 swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
#/Dev/sdb2/mnt/disk1 NTFS-3G defaults 0 0
#/Dev/sdb3/mnt/disk2 NTFS-3G defaults 0 0
#/Dev/sdb4/mnt/disk3 NTFS-3G defaults 0 0
#/Dev/sda1/mnt/ftp NTFS-3G default 0
 
UUID = B602ABF202ABB5B1/mnt/disk1 NTFS-3G defaults 0 0
UUID = 54C2B9ADC2B99428/mnt/disk2 NTFS-3G defaults 0 0
UUID = C00E001C0E000E5A/mnt/disk3 NTFS-3G defaults 0 0
UUID = 84582A24582A1608/mnt/ftp NTFS-3G defaults 0 0

It's done now. restart it ~

Finally, I'm sorry! There is still a big gap between the server version system and the desktop version. if you want to understand more, you have to develop the server version.

From: baobaoyeye's column

Related Article

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.