rocky linux:为新磁盘做分区/格式化/挂载(Rocky Linux 9.1)

一,查看所有磁盘

查看磁盘的分区
[root@blog ~]# fdisk -l
Disk /dev/vda: 50 GiB, 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
Disklabel type: gpt
Disk identifier: CDEEAA24-BF4D-4FEA-965A-75143EC1F765


Device      Start       End   Sectors  Size Type
/dev/vda1    2048      4095      2048    1M BIOS boot
/dev/vda2    4096    208895    204800  100M EFI System
/dev/vda3  208896 104857566 104648671 49.9G Linux filesystem




Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 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
查看已挂载的分区,可以看到/dev/vdb未挂载
[root@blog ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        4.0M     0  4.0M   0% /dev
tmpfs           3.7G     0  3.7G   0% /dev/shm
tmpfs           1.5G  544K  1.5G   1% /run
/dev/vda3        50G  3.1G   47G   7% /
/dev/vda2       100M  7.0M   93M   7% /boot/efi
tmpfs            50M     0   50M   0% /usr/local/aegis/cgroup
tmpfs           742M     0  742M   0% /run/user/0

二,分区:

[root@blog ~]# parted /dev/vdb
GNU Parted 3.5
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
  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]            display the partition table, or available devices, or free space, or all found partitions
  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
  type NUMBER TYPE-ID or TYPE-UUID         type set TYPE-ID or TYPE-UUID of partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print
Error: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:


Number  Start  End  Size  File system  Name  Flags


(parted) mkpart primary 0 107GB
Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s
Ignore/Cancel? C
(parted) mkpart primary 1MiB 107GB

说明:刘宏缔的架构森林是一个专注架构的博客,

网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/06/06/rocky-linux-wei-xin-ci-pan-zuo-fen-qu-ge-shi-hua-gua-zai/

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

三,格式化

[root@blog ~]# mkfs.ext4 /dev/vdb1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 26213888 4k blocks and 6553600 inodes
Filesystem UUID: d25c9fa0-6123-45d2-bbeb-adf1c21ee6c6
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872


Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done

四,挂载

[root@blog ~]# mount /dev/vdb1 /web
[root@blog ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        4.0M     0  4.0M   0% /dev
tmpfs           3.7G     0  3.7G   0% /dev/shm
tmpfs           1.5G  544K  1.5G   1% /run
/dev/vda3        50G  3.1G   47G   7% /
/dev/vda2       100M  7.0M   93M   7% /boot/efi
tmpfs            50M     0   50M   0% /usr/local/aegis/cgroup
tmpfs           742M     0  742M   0% /run/user/0
/dev/vdb1        98G   24K   93G   1% /web

五,编辑fstab配置文件,实现启动时自动挂载:

[root@blog ~]# blkid
/dev/vdb1: UUID="d25c9fa0-6123-45d2-bbeb-adf1c21ee6c6" TYPE="ext4" PARTLABEL="primary" PARTUUID="980c51af-a08b-4f3e-932a-2f0b6ced4a46"
/dev/vda2: SEC_TYPE="msdos" UUID="54F8-66C8" TYPE="vfat" PARTUUID="a5b87af5-0a78-4a81-a97e-79ff22a64bc9"
/dev/vda3: LABEL="root" UUID="87d48954-0eea-4e64-8c6e-27a537d26032" TYPE="xfs" PARTUUID="78a160b6-9409-479c-91ce-10f0989470b6"
/dev/vda1: PARTUUID="dfead5b8-c2c1-41f6-b3d4-0fdc094b74f4”


[root@blog ~]# vi /etc/fstab
增加一行:
UUID=d25c9fa0-6123-45d2-bbeb-adf1c21ee6c6 /web                ext4     defaults        0 2

六,查看linux的版本:

[root@blog ~]# cat /etc/redhat-release
Rocky Linux release 9.1 (Blue Onyx)

 

posted @ 2023-05-09 15:14  刘宏缔的架构森林  阅读(2263)  评论(0编辑  收藏  举报