时间:2019年11月22日 | 作者 : liuhui | 分类 : Linux | 浏览: 5749次 | 评论 0 人
阿里云限量代金券 | 此广告位出租25元/月 |
香港VPS自带一个硬盘没有被挂载,需要手工来挂载,下面方法适用于CentOS7.6系统。
查看已挂载的硬盘
# 使用 fdisk -l 命令查看所有磁盘信息 [root@ecs-Up5 ~]# fdisk -l Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0000425c Device Boot Start End Blocks Id System /dev/vda1 * 2048 2099199 1048576 83 Linux /dev/vda2 2099200 41943039 19921920 8e Linux LVM Disk /dev/vdb: 85.9 GB, 85899345920 bytes, 167772160 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes #显示参数说明 /dev/vda 是正常使用的硬盘 /dev/vdb 是未被使用的硬盘
对未被使用的硬盘进行分区
#使用 fdisk /dev/vdb 命令对未使用的硬盘进行分区 [root@ecs-Up5 ~]# fdisk /dev/vdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xc9cfb4bc. Command (m for help): n # 表示创建分区 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p # 表示创建主分区 Partition number (1-4, default 1): 1 # 表示创建1号分区 First sector (2048-167772159, default 2048): # 表示起始分区,默认 Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-167772159, default 167772159): # 表示结束分区,默认是全部容量 Using default value 167772159 Partition 1 of type Linux and of size 80 GiB is set Command (m for help): w # 表示写入分区,生效 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. # 使用 fdisk -l 命令查看分区结果 [root@ecs-Up5 ~]# fdisk -l Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0000425c Device Boot Start End Blocks Id System /dev/vda1 * 2048 2099199 1048576 83 Linux /dev/vda2 2099200 41943039 19921920 8e Linux LVM Disk /dev/vdb: 85.9 GB, 85899345920 bytes, 167772160 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xc9cfb4bc Device Boot Start End Blocks Id System /dev/vdb1 2048 167772159 83885056 83 Linux Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes #显示参数说明 成功创建 /dev/vdb1
格式化分区
#使用 mkfs.xfs -f /dev/vdb1 命令进行格式化分区 [root@ecs-Up5 ~]# mkfs.xfs -f /dev/vdb1 meta-data=/dev/vdb1 isize=512 agcount=4, agsize=5242816 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=20971264, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=10239, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
挂载分区
#使用mount -t xfs /dev/vdb1 /DATA命令进行磁盘挂载。把新加入的磁盘分区挂载到/DATA目录下 #在根目录下创建文件夹”DATA“ [root@ecs-Up5 ~]# mkdir /DATA [root@ecs-Up5 ~]# mount -t xfs /dev/vdb1 /DATA [root@ecs-Up5 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 17G 1.9G 16G 12% / devtmpfs 909M 0 909M 0% /dev tmpfs 920M 12K 920M 1% /dev/shm tmpfs 920M 8.6M 912M 1% /run tmpfs 920M 0 920M 0% /sys/fs/cgroup /dev/vda1 1014M 143M 872M 15% /boot tmpfs 184M 0 184M 0% /run/user/0 /dev/vdb1 80G 33M 80G 1% /DATA
开机自动挂载分区
#编辑 /etc/fstab 加入开机自动挂载语句 [root@ecs-Up5 ~]# vi /etc/fstab /dev/vdb1 /DATA xfs defaults 0 0
将上面最后一行代码加到fstab文件末尾就可以了
推荐您阅读更多有关于“”的文章
Powered By Z-Blogphp
分享:
支付宝
微信