服务器新硬盘分区、格式化和挂载
创始人
2025-01-17 13:32:05
0

文章目录

    • 参考文献
    • 查看了一下起点现状
    • 分区
      • (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            Name  1         2048       411647    200M  EFI System      EFI System Partition  2       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            Name  1           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 bytes   Disk /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 bytes   Disk /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 bytes   Disk /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 bytes   Disk /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 bytes   Disk /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 bytes   Disk /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: 0x00000000                              Device 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) alignment   help [COMMAND]                           print general help, or help on COMMAND   mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)   mkpart PART-TYPE [FS-TYPE] START END     make a partition   name NUMBER NAME                         name partition NUMBER as NAME   print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a         particular partition   quit                                     exit program   rescue START END                         rescue a lost partition near START and END      resizepart NUMBER END                    resize partition NUMBER   rm NUMBER                                delete partition NUMBER   select DEVICE                            choose the device to edit   disk_set FLAG STATE                      change the FLAG on selected device   disk_toggle [FLAG]                       toggle the state of FLAG on selected device   set NUMBER FLAG STATE                    change the FLAG on partition NUMBER   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER   unit UNIT                                set the default unit to UNIT   version                                  display the version number and copyright information of GNU Parted   align-check TYPE N                        check partition N for TYPE(min|opt) alignment   help [COMMAND]                           print general help, or help on COMMAND   mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)   mkpart PART-TYPE [FS-TYPE] START END     make a partition   name NUMBER NAME                         name partition NUMBER as NAME   print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a         particular partition   quit                                     exit program   rescue START END                         rescue a lost partition near START and END      resizepart NUMBER END                    resize partition NUMBER   rm NUMBER                                delete partition NUMBER   select DEVICE                            choose the device to edit   disk_set FLAG STATE                      change the FLAG on selected device   disk_toggle [FLAG]                       toggle the state of FLAG on selected device   set NUMBER FLAG STATE                    change the FLAG on partition NUMBER   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER   unit UNIT                                set the default unit to UNIT   version                                  display the version number and copyright information of GNU Parted   align-check TYPE N                        check partition N for TYPE(min|opt) alignment   help [COMMAND]                           print general help, or help on COMMAND   mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)   mkpart PART-TYPE [FS-TYPE] START END     make a partition   name NUMBER NAME                         name partition NUMBER as NAME   print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a         particular partition   quit                                     exit program   rescue START END                         rescue a lost partition near START and END      resizepart NUMBER END                    resize partition NUMBER   rm NUMBER                                delete partition NUMBER   select DEVICE                            choose the device to edit   disk_set FLAG STATE                      change the FLAG on selected device   disk_toggle [FLAG]                       toggle the state of FLAG on selected device   set NUMBER FLAG STATE                    change the FLAG on partition NUMBER   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER   unit UNIT                                set the default unit to UNIT   version                                  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) alignment   help [COMMAND]                           print general help, or help on COMMAND   mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)   mkpart PART-TYPE [FS-TYPE] START END     make a partition   name NUMBER NAME                         name partition NUMBER as NAME   print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a         particular partition   quit                                     exit program   rescue START END                         rescue a lost partition near START and END      resizepart NUMBER END                    resize partition NUMBER   rm NUMBER                                delete partition NUMBER   select DEVICE                            choose the device to edit   disk_set FLAG STATE                      change the FLAG on selected device   disk_toggle [FLAG]                       toggle the state of FLAG on selected device   set NUMBER FLAG STATE                    change the FLAG on partition NUMBER   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER   unit UNIT                                set the default unit to UNIT   version                                  display the version number and copyright information of GNU Parted   align-check TYPE N                        check partition N for TYPE(min|opt) alignment   help [COMMAND]                           print general help, or help on COMMAND   mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)   mkpart PART-TYPE [FS-TYPE] START END     make a partition   name NUMBER NAME                         name partition NUMBER as NAME   print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a         particular partition   quit                                     exit program   rescue START END                         rescue a lost partition near START and END      resizepart NUMBER END                    resize partition NUMBER   rm NUMBER                                delete partition NUMBER   select DEVICE                            choose the device to edit   disk_set FLAG STATE                      change the FLAG on selected device   disk_toggle [FLAG]                       toggle the state of FLAG on selected device   set NUMBER FLAG STATE                    change the FLAG on partition NUMBER   toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER   unit UNIT                                set the default unit to UNIT   version                                  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

相关内容

热门资讯

黑科技透视(手机德州)外挂透明... 黑科技透视(手机德州)外挂透明挂黑科技辅助神器(透视)玩家教程(2024已更新)(哔哩哔哩)1、快速...
四分钟了解!微扑克ai机器人,... 四分钟了解!微扑克ai机器人,情怀古诗词外挂,爆料教程(有挂方法)-哔哩哔哩;一、情怀古诗词外挂软件...
黑科技ai(pokenow)外... 黑科技ai(pokenow)外挂透明挂黑科技辅助工具(透视)扑克教程(2021已更新)(哔哩哔哩)1...
黑科技透视(AAPOKEr)外... 1、黑科技透视(AAPOKEr)外挂透明挂黑科技辅助神器(透视)必备教程(2020已更新)(哔哩哔哩...
2分钟了解!wpk外挂第一视角... 2分钟了解!wpk外挂第一视角,传送屋潮汕激k辅助,扑克教程(揭秘有挂)-哔哩哔哩1、完成传送屋潮汕...
黑科技智能(德州aa州克)外挂... 黑科技智能(德州aa州克)外挂透明挂黑科技辅助神器(透视)安装教程(2021已更新)(哔哩哔哩)是一...
第9分钟了解!红龙扑克辅助器下... 第9分钟了解!红龙扑克辅助器下载地址,推大石有挂么,科技教程(真是有挂)-哔哩哔哩1、每一步都需要思...
黑科技ai(德州aapoker... 黑科技ai(德州aapoker俱乐部)外挂透明挂黑科技辅助软件(透视)玩家教你(2025已更新)(哔...
三分钟了解!wepoke到底有... 三分钟了解!wepoke到底有没有挂,新道游大厅怎么开辅助,黑科技教程(讲解有挂)-哔哩哔哩1、任何...
黑科技俱乐部(微扑克小程序)外... 黑科技俱乐部(微扑克小程序)外挂透明挂黑科技辅助神器(透视)新版2025教程(2021已更新)(哔哩...