服务器新硬盘分区、格式化和挂载

文章目录

    • 参考文献
    • 查看了一下起点现状
    • 分区
      • (base) ~ sudo parted /dev/sdc
      • mklabel gpt(设置分区类型)
      • 增加分区
    • 格式化
      • 需要先退出quit(可以)
      • (base) / sudo mkfs.xfs /dev/sdc/sdc1(失败)
      • sudo mkfs.xfs /dev/sdc1(成功。sdc1是硬盘标识符+分区号,和路径写法不同)
    • 挂载
      • 创建用于挂载的文件夹
      • 进行挂载 vi /etc/fstab(失败)
      • sudo vi /etc/fstab使用超级管理员权限再进行一遍上面操作
      • 加载 sudo mount -a
      • 设置文件夹权限:

参考文献

linux parted非交互式分区实例 —— 筑梦之路
Linux磁盘格式化(mkfs、mkfs.xfs、mkfs.ext4)、Linux文件系统的校验(xfs_repair、fsck_ext4)
【LINUX】磁盘分区、挂载
linux7磁盘挂载大于16T,CentOS6.5挂载超过16T的大容量存储空间,格式化为xfs
服务器硬盘安装配置及系统重装操作记录
服务器的硬盘不够大,导师新买了块用,安装的起点是这样子的在这里插入图片描述

查看了一下起点现状

在这里插入图片描述
发现第二块没挂载了,但是是别人的硬盘,所以就先不管了。

(base) ~ sudo fdisk -l
[sudo] password for cszx: 
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.Disk /dev/sda: 239.9 GB, 239902654464 bytes, 468559872 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: gpt
Disk identifier: AD68530F-9D77-4143-91E1-D222825C2F10#         Start          End    Size  Type            Name1         2048       411647    200M  EFI System      EFI System Partition2       411648      2508799      1G  Microsoft basic 3      2508800    468557823  222.2G  Linux LVM       
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.Disk /dev/sdb: 239.9 GB, 239902654464 bytes, 468559872 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: gpt
Disk identifier: 2BB6EFDB-AB43-4872-B56F-88620F6AF0B3#         Start          End    Size  Type            Name1           34         2047   1007K  BIOS boot       2         2048      1050623    512M  EFI System      3      1050624    468559838  222.9G  Linux LVM       Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-home: 180.6 GB, 180631896064 bytes, 352796672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/pve-swap: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/pve-root: 59.6 GB, 59592671232 bytes, 116391936 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/pve-vm--105--disk--0: 4 MB, 4194304 bytes, 8192 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytesDisk /dev/mapper/pve-vm--105--disk--1: 128.8 GB, 128849018880 bytes, 251658240 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes
Disk label type: dos
Disk identifier: 0x00000000Device Boot      Start         End      Blocks   Id  System
/dev/mapper/pve-vm--105--disk--1p1               1  4294967295  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.Disk /dev/sdc: 14000.5 GB, 14000519643136 bytes, 27344764928 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

分区

(base) ~ sudo parted /dev/sdc

[sudo] password for cszx:
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type ‘help’ to view a list of commands.

mklabel gpt(设置分区类型)

增加分区

mkpart primary 0% 25%
parted -s /dev/sdc mkpart primary 25% 50%
parted -s /dev/sdc mkpart primary 50% 75%
parted -s /dev/sdc mkpart primary 75% 100%
两种命令的结果看上去一样,采用第一行的形式没有详细信息的输入

(parted) mklabel gpt                                                      
(parted) mkpart primary  0% 25%                                           
(parted) parted -s /dev/sdc mkpart primary  25% 50%                       align-check TYPE N                        check partition N for TYPE(min|opt) alignmenthelp [COMMAND]                           print general help, or help on COMMANDmklabel,mktable LABEL-TYPE               create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END     make a partitionname NUMBER NAME                         name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or aparticular partitionquit                                     exit programrescue START END                         rescue a lost partition near START and ENDresizepart NUMBER END                    resize partition NUMBERrm NUMBER                                delete partition NUMBERselect DEVICE                            choose the device to editdisk_set FLAG STATE                      change the FLAG on selected devicedisk_toggle [FLAG]                       toggle the state of FLAG on selected deviceset NUMBER FLAG STATE                    change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBERunit UNIT                                set the default unit to UNITversion                                  display the version number and copyright information of GNU Partedalign-check TYPE N                        check partition N for TYPE(min|opt) alignmenthelp [COMMAND]                           print general help, or help on COMMANDmklabel,mktable LABEL-TYPE               create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END     make a partitionname NUMBER NAME                         name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or aparticular partitionquit                                     exit programrescue START END                         rescue a lost partition near START and ENDresizepart NUMBER END                    resize partition NUMBERrm NUMBER                                delete partition NUMBERselect DEVICE                            choose the device to editdisk_set FLAG STATE                      change the FLAG on selected devicedisk_toggle [FLAG]                       toggle the state of FLAG on selected deviceset NUMBER FLAG STATE                    change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBERunit UNIT                                set the default unit to UNITversion                                  display the version number and copyright information of GNU Partedalign-check TYPE N                        check partition N for TYPE(min|opt) alignmenthelp [COMMAND]                           print general help, or help on COMMANDmklabel,mktable LABEL-TYPE               create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END     make a partitionname NUMBER NAME                         name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or aparticular partitionquit                                     exit programrescue START END                         rescue a lost partition near START and ENDresizepart NUMBER END                    resize partition NUMBERrm NUMBER                                delete partition NUMBERselect DEVICE                            choose the device to editdisk_set FLAG STATE                      change the FLAG on selected devicedisk_toggle [FLAG]                       toggle the state of FLAG on selected deviceset NUMBER FLAG STATE                    change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBERunit UNIT                                set the default unit to UNITversion                                  display the version number and copyright information of GNU Parted

可以了
查看在这里插入图片描述

格式化

在parted内mkfs.xfs /dev/sdc/sdc1(失败)

(parted) mkfs.xfs /dev/sdc/sdc1                                           align-check TYPE N                        check partition N for TYPE(min|opt) alignmenthelp [COMMAND]                           print general help, or help on COMMANDmklabel,mktable LABEL-TYPE               create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END     make a partitionname NUMBER NAME                         name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or aparticular partitionquit                                     exit programrescue START END                         rescue a lost partition near START and ENDresizepart NUMBER END                    resize partition NUMBERrm NUMBER                                delete partition NUMBERselect DEVICE                            choose the device to editdisk_set FLAG STATE                      change the FLAG on selected devicedisk_toggle [FLAG]                       toggle the state of FLAG on selected deviceset NUMBER FLAG STATE                    change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBERunit UNIT                                set the default unit to UNITversion                                  display the version number and copyright information of GNU Partedalign-check TYPE N                        check partition N for TYPE(min|opt) alignmenthelp [COMMAND]                           print general help, or help on COMMANDmklabel,mktable LABEL-TYPE               create a new disklabel (partition table)mkpart PART-TYPE [FS-TYPE] START END     make a partitionname NUMBER NAME                         name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or aparticular partitionquit                                     exit programrescue START END                         rescue a lost partition near START and ENDresizepart NUMBER END                    resize partition NUMBERrm NUMBER                                delete partition NUMBERselect DEVICE                            choose the device to editdisk_set FLAG STATE                      change the FLAG on selected devicedisk_toggle [FLAG]                       toggle the state of FLAG on selected deviceset NUMBER FLAG STATE                    change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBERunit UNIT                                set the default unit to UNITversion                                  display the version number and copyright information of GNU Parted

需要先退出quit(可以)

(base) / sudo mkfs.xfs /dev/sdc/sdc1(失败)

[sudo] password for cszx:
/dev/sdc/sdc1: Not a directory

sudo mkfs.xfs /dev/sdc1(成功。sdc1是硬盘标识符+分区号,和路径写法不同)

meta-data=/dev/sdc1              isize=512    agcount=4, agsize=213630912 blks=                       sectsz=4096  attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=854523648, imaxpct=5=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=417247, version=2=                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

sudo mkfs.xfs /dev/sdc2
sudo mkfs.xfs /dev/sdc3
sudo mkfs.xfs /dev/sdc4

(base) / sudo mkfs.xfs /dev/sdc2
[sudo] password for cszx: 
meta-data=/dev/sdc2              isize=512    agcount=4, agsize=213630976 blks=                       sectsz=4096  attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=854523904, imaxpct=5=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=417248, version=2=                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
^[[A%                                                                                                                                      
(base) / sudo mkfs.xfs /dev/sdc3
meta-data=/dev/sdc3              isize=512    agcount=4, agsize=213630976 blks=                       sectsz=4096  attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=854523904, imaxpct=5=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=417248, version=2=                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
(base) / sudo mkfs.xfs /dev/sdc4
meta-data=/dev/sdc4              isize=512    agcount=4, agsize=213630912 blks=                       sectsz=4096  attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=854523648, imaxpct=5=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=417247, version=2=                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
(base) / 

查看,可以了
在这里插入图片描述

挂载

创建用于挂载的文件夹

mkdir c1
mkdir c2
mkdir c3
mkdir c4

进行挂载 vi /etc/fstab(失败)

在这里插入图片描述
加入四行
/dev/sdc1 /home/cszx/c1 xfs defaults 0 0
/dev/sdc2 /home/cszx/c2 xfs defaults 0 0
/dev/sdc3 /home/cszx/c3 xfs defaults 0 0
/dev/sdc4 /home/cszx/c4 xfs defaults 0 0
保存并退出:wq!
报错"/etc/fstab" E212: Can’t open file for writing
原因是权限不够,退出:q!

sudo vi /etc/fstab使用超级管理员权限再进行一遍上面操作

在这里插入图片描述
保存并退出:wq!

加载 sudo mount -a

查看
在这里插入图片描述
成功了。
发现需要使用sudo权限,mkdir: cannot create directory ‘zgp’: Permission denied

设置文件夹权限:

sudo chmod 777 /home/cszx/c1
sudo chmod 777 /home/cszx/c2
sudo chmod 777 /home/cszx/c3
sudo chmod 777 /home/cszx/c4

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/29246.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

通过nginx转发后应用偶发502bad gateway

序言 学习了一些东西,如何才是真正自己能用的呢?好像就是看自己的潜意识的反应,例如解决了一个问题,那么下次再碰到类似的问题,能直接下意识的去找到对应的信息,从而解决,而不是和第一次碰到一样…

CRC循环冗余校验

CRC循环冗余校验 循环冗余校验码是一种用在数字网络和存储设备上的差错校验码,可以校验原始数据的偶然差 错。 CRC 计算单元使用固定多项式计算 32 位 CRC 校验码。 1. 硬件CRC 在单片机中,芯片具有专用的CRC计算单元,它是按照32位数据长…

LeetCode 48.旋转图像

1.做题要求: 2.从此题我们可以看出规律为第几行要变为倒数第几列,所以我们最好先把二维数组存入一维数组中,然后先从最后一列遍历,把一维数组里的元素,依次等于遍历的元素即可: void rotate(int** matrix, int matrixSize, int*…

Scala函数

文章目录 一、第1关:方法S 三角形 ​实验代码: 二、第2关:Scala函数以及函数调用实验代码: 一、第1关:方法 任务描述 本关任务:根据三角形的三边长 a、b、c,返回三角形的面积。 任意三角形面积…

外网怎么访问内网?

当我们需要在外网环境下访问内网资源时,常常会面临一些困扰。通过使用一些相关的技术与工具,我们可以轻松地实现这一目标。本文将介绍如何通过【天联】组网产品,解决外网访问内网的问题。 【天联】组网是一款由北京金万维科技有限公司自主研…

JAVAFX打包部署真正能用的办法(jdk21,javafx23)IntelliJ IDEA

我之前创建了javafx项目,想打包试试。一试,全是坑,所以记录下来,为有缘人节约时间。直接构建工件是错误的,别尝试了,找不在JDK的。我也花了一天多的时间尝试了网上各种大神的办法,就没找到一个是…

stm32学习-软件I2C读取MPU6050

接线 SDAPB11SCLPB10 I2C 对操作端口的库函数进行封装 void MyI2C_W_SCL(uint8_t BitValue)//写 {GPIO_WriteBit(GPIOB, GPIO_Pin_10, (BitAction)BitValue);Delay_us(10); }void MyI2C_W_SDA(uint8_t BitValue)//写 {GPIO_WriteBit(GPIOB, GPIO_Pin_11, (BitAction)BitValu…

Redis 7.x 系列【4】命令手册

有道无术,术尚可求,有术无道,止于术。 本系列Redis 版本 7.2.5 源码地址:https://gitee.com/pearl-organization/study-redis-demo 文章目录 1. 说明2. 命令手册2.1 Generic2.2 数据类型2.2.1 String2.2.2 Hash2.2.3 List2.2.4 S…

如何在纯内网环境下,将EasyCVR视频汇聚网关通过4G与第三方公网云平台级联?

EasyCVR视频汇聚网关是TSINGSEE青犀软硬一体的一款产品,可提供多协议的接入、音视频采集、处理,能实现海量前端设备的轻量化接入/转码/分发、视频直播、云端录像、云存储、检索回看、智能告警、平台级联等,兼容多种操作系统,轻松扩…

HTTP/2 协议学习

HTTP/2 协议介绍 ​ HTTP/2 (原名HTTP/2.0)即超文本传输协议 2.0,是下一代HTTP协议。是由互联网工程任务组(IETF)的Hypertext Transfer Protocol Bis (httpbis)工作小组进行开发。是自1999年http1.1发布后的首个更新。…

第3讲:关于Pixi的Text、Container、Sprite、Graphics组件功能作用

首先这里提供一个公用代码: 下部分各种组件基于这个公用代码直接往下添加代码即可。 import {Application, Text, Container, Sprite, BaseTexture, Texture, Graphics} from pixi.js import ./style.css import testImageUrl from ./images/test.jpg // 指明Appli…

3.1、前端异步编程(超详细手写实现Promise;实现all、race、allSettled、any;async/await的使用)

前端异步编程规范 Promise介绍手写Promise(resolve,reject)手写Promise(then)Promise相关 API实现allraceallSettledany async/await和Promise的关系async/await的使用 Promise介绍 Promise是一个类,可以翻…

HTML静态网页成品作业(HTML+CSS)—— 家乡成都介绍网页(4个页面)

🎉不定期分享源码,关注不丢失哦 文章目录 一、作品介绍二、作品演示三、代码目录四、网站代码HTML部分代码 五、源码获取 一、作品介绍 🏷️本套采用HTMLCSS,未使用Javacsript代码,共有4个页面。 二、作品演示 三、代…

C语言 | Leetcode C语言题解之第164题最大间距

题目&#xff1a; 题解&#xff1a; int maximumGap(int* nums, int numsSize) {if (numsSize < 2) {return 0;}int maxVal INT_MIN, minVal INT_MAX;for (int i 0; i < numsSize; i) {maxVal fmax(maxVal, nums[i]);minVal fmin(minVal, nums[i]);}int d fmax(1,…

计算机网络:3数据链路层

数据链路层 概述封装成帧和透明传输帧透明传输&#xff08;填充字节或比特&#xff09;差错检测奇偶校验循环冗余校验CRC Cyclic Redundancy Check 可靠传输停止-等待协议回退n帧协议&#xff08;滑动窗口协议&#xff09;选择重传协议 点对点协议PPP共享式以太网网络适配器&am…

React+TS前台项目实战(十一)-- 全局常用组件提示语可复制Link组件封装

文章目录 前言HighLightLink组件1. 功能分析2. 代码详细注释3. 使用方式4. 效果展示 总结 前言 今天这篇讲的这个组件&#xff0c;是一个用于高亮显示文本并添加可选的跳转链接&#xff0c;提示文本&#xff0c;复制文本的 React 组件 HighLightLink组件 1. 功能分析 &#x…

【交易策略】#22-24 残差资金流强度因子

【交易策略】#22-24 残差资金流强度因子

路由控制和策略路由

文章目录 一、路由控制&#xff08;1&#xff09;、前言1.1.1-路由策略 &#xff08;2&#xff09;、正反掩码和通配符1.2.1-通配符 &#xff08;3&#xff09;、ACL1.3.1-ACL步长1.3.2-步长的作用1.3.3-TCP/UDP端口号 实验1:实验2: 二、前缀列表实验1:2.1.1-前缀列表的表达式2…

【图像分割】DSNet: A Novel Way to Use Atrous Convolutions in Semantic Segmentation

DSNet: A Novel Way to Use Atrous Convolutions in Semantic Segmentation 论文链接&#xff1a;http://arxiv.org/abs/2406.03702 代码链接&#xff1a;https://github.com/takaniwa/DSNet 一、摘要 重新审视了现代卷积神经网络&#xff08;CNNs&#xff09;中的atrous卷积…

找工作小项目:day16-重构核心库、使用智能指针(1)

day16-重构核心库、使用智能指针 今天是该项目开源在gthub的最后一天&#xff0c;我这里只是将我自己对于这个项目的理解进行总结&#xff0c;如有错误敬请包含指正&#xff0c;今天会整体理一遍代码&#xff0c;并使用智能指针管理整个项目。 1、common 头文件 定义宏用于…