天翼云-弹性云服务器硬盘分区格式化挂载 fdisk mkfs.xfs mount uuid

环境,天翼云弹性主机centos7.3 系统盘40G 。扩展盘100G 系统默认未挂载到系统里

[root@mail ~]# df -h                                            //查看系统磁盘使用情况,这里是看不到未挂载的硬盘的
Filesystem Size Used Avail Use% Mounted on
/dev/xvda2 36G 5.7G 28G 17% /
devtmpfs 902M 0 902M 0% /dev
tmpfs 908M 4.0K 908M 1% /dev/shm
tmpfs 908M 8.5M 900M 1% /run
tmpfs 908M 0 908M 0% /sys/fs/cgroup
tmpfs 182M 0 182M 0% /run/user/0
tmpfs 182M 0 182M 0% /run/user/9008

 

root@mail ~]# fdisk -l                     //使用 fdisk -l 可以看到100G的硬盘  和路径   /dev/xvde

Disk /dev/xvda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000a9cf3

Device Boot Start End Blocks Id System
/dev/xvda1 2048 8390655 4194304 82 Linux swap / Solaris
/dev/xvda2 * 8390656 83886079 37747712 83 Linux

Disk /dev/xvde: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0e5de398

Device Boot Start End Blocks Id System

[root@mail ~]# fdisk /dev/xvde    //使用 fdisk 进行分区
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.

Command (m for help):                //选n 新建  然后选e(扩展分区) 一路回车默认
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): e
Partition number (1-4, default 1):
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Extended and of size 100 GiB is set

Command (m for help): b^Hn^H^H
There is no *BSD partition on (null).

Command (m for help): n                 //继续n新建 然后 L (新建逻辑分区)一路 回车默认设置
Partition type:
p primary (0 primary, 1 extended, 3 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (4096-209715199, default 4096):
Using default value 4096
Last sector, +sectors or +size{K,M,G} (4096-209715199, default 209715199):
Using default value 209715199
Partition 5 of type Linux and of size 100 GiB is set

Command (m for help): w               //保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

[root@mail ~]# fdisk /dev/xvde    //在继续 进去新磁盘
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.


Command (m for help): p           // p 可以查看新磁盘的分区情况

Disk /dev/xvde: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0e5de398

Device Boot Start End Blocks Id System
/dev/xvde1 2048 209715199 104856576 5 Extended
/dev/xvde5 4096 209715199 104855552 83 Linux

Command (m for help): quit     //退出设置

接下来格式化磁盘

[root@2018sh001 ~]# mkfs.xfs /dev/vdb5     //这里注意 格式只能对逻辑分区进行操作,无法对扩展分区进行操作,第一次弄的时候吃了不少药
meta-data=/dev/vdb5 isize=256 agcount=4, agsize=6553472 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0, sparse=0
data = bsize=4096 blocks=26213888, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=12799, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

[root@2018sh001 /]# mkdir -p mail     //根目录下新建一个文件夹 未接下里的挂载做准备

[root@2018sh001 /]# mount /dev/vdb5 /mail      //把之前格式化好的磁盘和新建的文件夹挂载关联   

[root@2018sh001 /]# df -i     //查看挂载成功
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 218424 345 218079 1% /dev
tmpfs 222907 2 222905 1% /dev/shm
tmpfs 222907 450 222457 1% /run
tmpfs 222907 15 222892 1% /sys/fs/cgroup
/dev/vda2 37747712 79269 37668443 1% /
tmpfs 222907 1 222906 1% /run/user/9008
tmpfs 222907 1 222906 1% /run/user/0
/dev/vdb5 104855552 3 104855549 1% /mail        // 挂载成功

[root@2018sh001 /]# ls -l /dev/disk/by-uuid/              //查看磁盘的UUID 
total 0
lrwxrwxrwx 1 root root 10 Feb 11 16:46 3b4db05b-cb08-4cd2-84a5-89f41b392401 -> ../../vda2
lrwxrwxrwx 1 root root 10 Feb 13 15:46 611cb800-74d2-42fb-880b-f95ec82521d1 -> ../../vdb5           // 记录好该条UUID记录
lrwxrwxrwx 1 root root 10 Feb 11 16:46 a2aacb12-aefc-44b6-8a38-4de5e86462b9 -> ../../vda1

 

vim /etc/fstab    // 编辑磁盘启动文件

UUID=3b4db05b-cb08-4cd2-84a5-89f41b392401 / xfs defaults 0 0
UUID=a2aacb12-aefc-44b6-8a38-4de5e86462b9 swap swap defaults 0 0
UUID=611cb800-74d2-42fb-880b-f95ec82521d1 /mail xfs defaults 0 0        //添加这条记录   :wq保存

reboot  重启

[root@2018sh001 ~]# df -h            //查看磁盘使用情况
Filesystem Size Used Avail Use% Mounted on
devtmpfs 854M 0 854M 0% /dev
tmpfs 871M 0 871M 0% /dev/shm
tmpfs 871M 8.4M 863M 1% /run
tmpfs 871M 0 871M 0% /sys/fs/cgroup
/dev/vda2 36G 5.1G 31G 14% /
/dev/vdb5 100G 33M 100G 1% /mail                         // 挂载信息重启后还在
tmpfs 175M 0 175M 0% /run/user/0

 

posted @ 2019-02-13 16:09  backstreet  阅读(1968)  评论(0编辑  收藏  举报