ECS服务器挂在磁盘命令

发布时间 2023-06-15 17:38:46作者: 迎风2023
  1 1.在根目录创建挂载文件夹
  2 进入/目录 mkdir data
  3 
  4 --2.查看挂载信息
  5 --[root@ecs-a08d-0001 /]# fdisk -l
  6 Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
  7 Units: sectors of 1 * 512 = 512 bytes
  8 Sector size (logical/physical): 512 bytes / 512 bytes
  9 I/O size (minimum/optimal): 512 bytes / 512 bytes
 10 Disklabel type: dos
 11 Disk identifier: 0x5e9a7bb5
 12 
 13 Device     Boot Start      End  Sectors Size Id Type
 14 /dev/sda1  *     2048 83886079 83884032  40G 83 Linux
 15 
 16 
 17 --Disk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
 18 Units: sectors of 1 * 512 = 512 bytes
 19 Sector size (logical/physical): 512 bytes / 512 bytes
 20 I/O size (minimum/optimal): 512 bytes / 512 bytes
 21 --3.开始分区 
 22 [root@ecs-a08d-0001 /]# fdisk /dev/sdb
 23 
 24 Welcome to fdisk (util-linux 2.32.1).
 25 Changes will remain in memory only, until you decide to write them.
 26 Be careful before using the write command.
 27 
 28 Device does not contain a recognized partition table.
 29 Created a new DOS disklabel with disk identifier 0xab1da7a8.
 30 
 31 --Command (m for help): n
 32 Partition type
 33    p   primary (0 primary, 0 extended, 4 free)
 34    e   extended (container for logical partitions)
 35 --Select (default p): p
 36 --Partition number (1-4, default 1):
 37 --First sector (2048-1048575999, default 2048):
 38 --Last sector, +sectors or +size{K,M,G,T,P} (2048-1048575999, default 1048575999):
 39 
 40 Created a new partition 1 of type 'Linux' and of size 500 GiB.
 41 
 42 --Command (m for help): p
 43 Disk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
 44 Units: sectors of 1 * 512 = 512 bytes
 45 Sector size (logical/physical): 512 bytes / 512 bytes
 46 I/O size (minimum/optimal): 512 bytes / 512 bytes
 47 Disklabel type: dos
 48 Disk identifier: 0xab1da7a8
 49 
 50 Device     Boot Start        End    Sectors  Size Id Type
 51 /dev/sdb1        2048 1048575999 1048573952  500G 83 Linux
 52 
 53 --Command (m for help): w
 54 The partition table has been altered.
 55 Calling ioctl() to re-read partition table.
 56 Syncing disks.
 57 
 58 
 59 
 60 ---执行以下命令,将新建分区文件系统设为系统所需格式。
 61 --4.mkfs -t ext4 /dev/sdb1   创建文件系统
 62 
 63 [root@ecs-a08d-0001 /]# mkfs -t ext4 /dev/sdb1
 64 mke2fs 1.45.6 (20-Mar-2020)
 65 Creating filesystem with 131071744 4k blocks and 32768000 inodes
 66 Filesystem UUID: 3b84b95d-0fb2-4703-8253-d9ed1aaaaa70
 67 Superblock backups stored on blocks:
 68         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 69         4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
 70         102400000
 71 
 72 Allocating group tables: done
 73 Writing inode tables: done
 74 Creating journal (262144 blocks): done
 75 Writing superblocks and filesystem accounting information: done
 76 
 77 
 78 
 79 
 80 --5. blkid /dev/sdb1         查看uuid
 81 [root@ecs-a08d-0001 /]# blkid /dev/sdb1
 82 /dev/sdb1: UUID="3b84b95d-0fb2-4703-8253-d9ed1aaaaa70" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="ab1da7a8-01"
 83 
 84 
 85 6.写入开机文件
 86 vi /etc/fstab
 87 yyp复制
 88 
 89 #
 90 # /etc/fstab
 91 # Created by anaconda on Fri Jul  8 03:25:39 2022
 92 #
 93 # Accessible filesystems, by reference, are maintained under '/dev/disk/'.
 94 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
 95 #
 96 # After editing this file, run 'systemctl daemon-reload' to update systemd
 97 # units generated from this file.
 98 #
 99 UUID=d63bd68b-59b5-4917-a1d8-b9b03af9ae24 /                       ext4    defaults        1 1
100 UUID=3b84b95d-0fb2-4703-8253-d9ed1aaaaa70 /data                   ext4    defaults        1 1
101 ~
102 wq!
103 
104 8.mount -a  
105 执行如下命令,将“/etc/fstab”文件所有内容重新加载。
106 
107 9.umount /dev/sdb1  --卸载