Ubuntu分区格式化并挂载新增磁盘方法
1.安装前准备
root@ub1404:/# apt-get install xfsprogs
root@ub1404:/# modprobe xfs
root@ub1404:/# lsmod |grep xfs
xfs 915019 3
libcrc32c 12644 1 xfs
2.添加硬盘
添加硬盘后重启服务器,会发现已经有新的磁盘挂载
root@ub1404:/# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 160G 0 disk
├─sda1 8:1 0 56G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 4G 0 part [SWAP]
sdb 8:16 0 100G 0 disk
sr0 11:0 1 1024M 0 rom
sdb就是新添加的磁盘
3.分区格式化
root@ub1404:/# 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 xfs 0% 100%
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 100GB 100GB xfs
#输入quit退出parted
(parted) quit
Information: You may need to update /etc/fstab.
(base)
PS:在上面依次输入的分区命令是:
parted /dev/sdb
mklabel gpt
mkpart xfs 0% 100%
quit
4.格式化为xfs文件系统
root@ub1404:/# mkfs.xfs -f /dev/sdb1
5.修改/etc/fstab,然系统自动挂载xfs卷
root@ub1404:/# sudo blkid
/dev/sdb1: UUID="5ab1bb7b-5a19-477a-b514-f27c1a4a45da" TYPE="xfs"
/dev/sda1: UUID="907fa6b6-9a44-440f-b2de-b4dcdf098d75" TYPE="ext4"
/dev/sda5: UUID="c16b633c-2288-4e7c-a3c7-cda0e4122878" TYPE="swap"
添加记录
root@ub1404:/# vi /etc/fstab
UUID=5ab1bb7b-5a19-477a-b514-f27c1a4a45da /diskb xfs defaults 0 1
6.检验
检验配置是否成功
root@ub1404:/# sudo mount -a
手动是否挂载成功
root@ub1404:/# mount /dev/sdb1 /diskb
然后用df -h查看即可。
成功之后可以重启
7.其他
如果ssh访问过慢,可以添加
root@ub1404:/# vim /etc/ssh/sshd_config
#添加下面这一句
UseDNS no
root@ub1404:/# service sshd restart
转载请注明来源:https://www.cnblogs.com/bugutian/