centos磁盘分区与挂载

查看该设备未挂载的磁盘(如/dev/sdb)

[root@localhost ~]# parted  -l
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
1      1049kB  3146kB  2097kB  primary
2      3146kB  527MB   524MB   primary  xfs          boot
3      527MB   107GB   107GB   primary               lvm


Error: /dev/sdb: unrecognised disk label
Model: VMware Virtual disk (scsi)                                         
Disk /dev/sdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system     Flags
1      0.00B  17.2GB  17.2GB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 89.7GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
1      0.00B  89.7GB  89.7GB  xfs

对该磁盘进行分区

[root@localhost ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
(parted) mkpart primary 1 100%
(parted) print                                                            
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
1      1049kB  2199GB  2199GB               primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.

格式化磁盘

[root@localhost ~]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=134217600 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=536870400, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=262143, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

挂载磁盘至指定目录

[root@localhost /]# mkdir /zimo
[root@localhost /]# mount /dev/sdb1 /zimo

查询是否挂载成功

[root@localhost /]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   84G   11G   73G  13% /
devtmpfs                  16G     0   16G   0% /dev
tmpfs                     16G     0   16G   0% /dev/shm
tmpfs                     16G  1.6G   15G  11% /run
tmpfs                     16G     0   16G   0% /sys/fs/cgroup
/dev/sda2                497M  171M  326M  35% /boot
tmpfs                    3.2G   40K  3.2G   1% /run/user/0
/dev/sdb1                2.0T   33M  2.0T   1% /zimo

设置开机自动挂载

[root@localhost /]# vi /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Aug 27 06:39:45 2019
#
# 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=33181145-8d9e-412d-8b21-e997632a9c9c /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/sdb1               /zimo                   xfs     defaults        0 0

重启服务器

[root@localhost /]# reboot
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值