ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

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

2021-06-29 23:02:02  阅读:199  来源: 互联网

标签:bytes 磁盘格式 dev swap sdb Linux bogon 512 root


记录一次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

标签:bytes,磁盘格式,dev,swap,sdb,Linux,bogon,512,root
来源: https://blog.csdn.net/u014379204/article/details/118345656

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有