记录一次Linux下磁盘格式化、挂载的操作过程、swap扩容过程

2021/6/30 7:20:41

本文主要是介绍记录一次Linux下磁盘格式化、挂载的操作过程、swap扩容过程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

记录一次Linux下磁盘格式化、挂载的操作过程、swap扩容过程

[root@bogon ~]# fdisk -l | grep sdb
Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 sectors
[root@bogon ~]#
[root@bogon ~]# fdisk /dev/sdb
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 0xc861ca16.

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
First sector (2048-125829119, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-125829119, default 125829119): +15G
Partition 1 of type Linux and of size 15 GiB is set

Command (m for help): p

Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0xc861ca16

Device Boot Start End Blocks Id System
/dev/sdb1 2048 31459327 15728640 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@bogon ~]#
[root@bogon ~]# fdisk -l | grep sdb
Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 sectors
/dev/sdb1 2048 31459327 15728640 83 Linux
[root@bogon ~]# mkdir /storage1
[root@bogon ~]#
[root@bogon ~]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=983040 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=3932160, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@bogon ~]#
[root@bogon ~]# mount /dev/sdb1 /storage1/
[root@bogon ~]# df -h | grep sdb
/dev/sdb1 15G 33M 15G 1% /storage1
[root@bogon ~]#
[root@bogon ~]# blkid | grep sdb
/dev/sdb1: UUID=“3e756359-0c9d-4d3b-9361-abb2f7138e56” TYPE=“xfs”
[root@bogon ~]#
[root@bogon ~]# vi /etc/fstab
插入:
UUID=3e756359-0c9d-4d3b-9361-abb2f7138e56 /storage1 xfs defaults 0 0

swap

[root@bogon ~]# fdisk /dev/sdb
n p 2 w
[root@bogon ~]# mkswap /dev/sdb2
Setting up swapspace version 1, size = 5242876 KiB
no label, UUID=704be937-e306-4739-b05e-734238698c6e
[root@bogon ~]# swapon /dev/sdb2
[root@bogon ~]# vi /etc/fstab(配置开机自启)
增加:
UUID=704be937-e306-4739-b05e-734238698c6e swap swap defaults 0 0

其他说明:

当磁盘来源于存储设备,而主机又无法重启时可执行如下命令来让操作系统扫描磁盘信息,以便于发现新磁盘

#find /sys/class/scsi_host/host*/scan | while read line; do echo - - - > $line; done
#find /sys/class/scsi_device/*/device/rescan | while read line;do echo 1 > $line;done

#blkid 查看磁盘的uuid



这篇关于记录一次Linux下磁盘格式化、挂载的操作过程、swap扩容过程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程