Linux/data Data partition disk space is insufficient, how to mount the disk.

Source: Internet
Author: User

First, we need to simulate the environment and use VMware to add a 300G (actually 200m~~ manual funny-_-) hard drive device to me.

Follow the steps step by step to add just fine. You will need to restart your virtual machine after the addition is complete to take effect.

OK, then we have the environment. I have installed a 300G (200M) hard drive for our "server", now let's mount it under/data.

The first step is to create a partition for the new disk.

[root@~]# ll/dev/sdb*    #检查第二块硬盘, and partition BRW-RW----1 root disk 8, the 14:35/dev/sdb# here shows that you have a second disk, but no partition ah, brother ~ ~

To create a partition for a disk, you can use two commands, Fdisk and parted. Let's talk about Fdisk first. parted, wait.

Fdisk command,-C option: Turn off DOS compatibility mode,-u partitions the disk in sectors.

When it's time to use the finer points for your disk, we're going to mount the 300G to/data without using the command option.

The following are the meanings of the Fdisk internal directives that need to be used:

M display Help.      n Create the partition.     P displays disk partition information.      d Delete the partition.     W Save and exit. Q Exit does not save.

[root@~]# fdisk/dev/sdb #fdisk command to add a disk file directly behind the warning:dos-compatible mode is deprecated. It ' s strongly recommended to switch off the mode (command ' C ') and change display units to sectors (Comman d ' u ').#这里的警告信息就是, it is recommended that you turn off DOS compatibility mode and enable the-u option, which simply means that you use the-CU option. However, this warning does not need to be too concerned, it will only be displayed when the disk is not partitioned, and will not have any effect on our operations below. Command (M for help): P#先看一下磁盘分区情况disk/dev/sdb:213 MB, 213909504 bytes64 heads, sectors/track, 204 cylindersunits = cylinders of 2048 * = 1048576 b  Ytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): + bytes/512 bytesdisk identifier: 0x1bf8bec7 Device Boot Start End Blocks Id System#嗯, the blank is that no disk partitions have been made. Command (M for help): N#创建磁盘分区Command Action E Extended P primary partition (1-4)#这里是系统提示, do you create an extended partition by E or press p to create a primary partition? P#咱们就准备整一个分区, Natural choice p main partition ~ ~Partition number (1-4): 1#键入1 is the meaning of the main partition number 1th. First cylinder (1-204, default 1):"Enter" (press ENTER)    #这里是让你选择分区开始的柱面, the carriage return is the default, the original meaningUsing default value 1Last cylinder, +cylinders or +size{k,m,g} (1-204, default 204):"Enter" (press ENTER)   #这里是让你选择分区结束的柱面, the carriage return is the default, the last meaningUsing Default Value 204(created well)Command (M for help): P#咱们再看一下disk/dev/sdb:213 MB, 213909504 bytes64 heads, sectors/track, 204 cylindersunits = cylinders of 2048 * = 1048576 b  Ytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): + bytes/512 bytesdisk identifier:    0x1bf8bec7 Device Boot Start End Blocks Id system/dev/sdb1 1 204 208880 Linux#嗯嗯, partition name/DEV/SDB1, size approximately "300G"Command (M for help): W# type W, be sure to save and exit. Otherwise, all settings will not take effect. The partition table has been altered! Calling IOCTL () to re-read partition table. Syncing disks.

FDISK-L Check the disk for information.

[root@~]# fdisk-l| grep '/dev/sdb ' disk/dev/sdb:213 MB, 213909504 bytes/dev/sdb1               1         204      208880  Linux# This means that our disk partition has been created OK. 

 The second step is to create a file system for your partition (formatted)

First to manually update, let the system know that the SDB Disk partition table has changed ~ ~

# Proud Linux doesn't give you any hints. But this step is essential.

And then just put a EXT4 file system on the partition.

[root@~]# mkfs.ext4/dev/sdb1    #mkfs command. Spaces are not required in the middle of the ext4. Follow the file name of the partition, not the disk file name, this should be noted. mke2fs 1.41.12 (17-may-2010) The number of lines omitted here writing Superblocks and filesystem accounting information:donethis filesystem would be automatically checked every 2 1 mounts or180 days, whichever comes first.  Use Tune2fs-c or-i to override. #最后这两个提示信息是最重要的, it means: This filesystem will be automatically checked after 21 mounts or 180 days, using TUNE2FS-C or-I can override the default automatic check. 

Anyway, I don't need the system default check what, then I just shut it down, and use it to suggest the TUNE2FS command is good.

[root@~]# tune2fs-c 0-i 0/DEV/SDB1 #-C and-I are    followed by 0 (not checked), or disk partition file ~ ~tune2fs 1.41.12 (17-may-2010) Setting Maximal mount Count to-1setting interval between checks to 0 seconds#提示信息我就不逐条翻译了, which probably means that the system does not automatically check. 

 The third step, the/DEV/SDB1 mount ~ ~ to/data, and realize the boot automatically mount.

Mount Mount, this simple, I will not speak.

[root@~]# mount/dev/sdb1/data[root@~]# df-h            #最好 df-h See Filesystem      Size  used Avail use% mounted On/dev/sda3        19G  2.3G   16G  13%/tmpfs           490M     0  490M   0%/dev/shm/dev/sda1       190M   66M  115M  37%/boot/dev/sdb1       194M  1.8M  182M   1%/data               #这里不应该是300G吗, Did I hang up wrong?-_-?

Boot automatic implementation of the method to mount a lot, we will simply say three kinds of good.

Method One: Realize power-on Operation Mount/dev/sdb1/data through/etc/rc.local. To enable automatic mounting of the boot

[root@~]# ll/etc/rc.local lrwxrwxrwx 1 root root  6 17:57/etc/rc.local, rc.d/rc.local#/etc/rc.local< c2/> is a symbolic link to/etc/rc.d/rc.local. You can modify the symbolic link file directly under root permission. [root@~]# vim/etc/rc.d/rc.local      #但是我有强迫症, I'm going to modify the source file.  Hem ~ ~#!/bin/sh## This script is executed *after* all the other init scripts.# you can put your own initialization Stuff in this if you don ' t# want to do the full Sys V style init stuff.touch/var/lock/subsys/localmount/dev/sdb1/d ATA            #编写这么一句就好了, but I don't recommend it. Maybe it's because it's relatively low.

Method Two: Realize the automatic mount of boot by/etc/fstab

[root@~]# vim/etc/fstab##/etc/fstab# Created by Anaconda on Sat Jul 14:15:11 2018## Accessible filesystems, by Refere NCE, is maintained under '/dev/disk ' # See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info#uuid=4b7f 430B-398B-4CA4-A6F4-75E11C8498F0/EXT4 Defaults 1 1uuid=b001470a-e506-4b50-a705-7b4343ac6 A7c/boot ext4 defaults 1 2uuid=ec344814-973b-45d3-95f0-7ce6265b3247 swap s                  WAP defaults 0 0tmpfs/dev/shm tmpfs defaults 0 0devpts        /dev/pts devpts gid=5,mode=620 0 0sysfs/sys Sysfs Defaults 0 0proc/proc proc Defaults 0 0/DEV/SDB1/DATA/EXT4 defaults 0 0
#第一列设备的名称 #第二列 mount point (directory) #3, file system type #4, defaults is the default mount parameter
#第一个 0 refers to whether to make a backup 0 (not) the second 0 refers to whether the boot disk check 0 (not checked)

Method Three: Through Chkconfig realizes the boot automatically.

This method I also do not recommend, after all, Chkconfig is still used to enable the system service is better, mount the thing or give fstab good.

Below is the link I wrote how to implement Chkconfig boot from start ~ ~ Link, interested can see.

Www.cnblogs.com/xuenil/p/9470812.html

As for the difference between Fdisk and parted, let's talk about ~~~~~ tomorrow.

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.