查看当前磁盘情况

  1. [root@localhost subadmin]# df -hl
  2. Filesystem Size Used Avail Use% Mounted on
  3. devtmpfs 7.8G 0 7.8G 0% /dev
  4. tmpfs 7.8G 0 7.8G 0% /dev/shm
  5. tmpfs 7.8G 8.6M 7.8G 1% /run
  6. tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
  7. /dev/sda2 50G 2.1G 48G 5% /
  8. /dev/sda5 41G 325M 41G 1% /home
  9. /dev/sda1 976M 254M 655M 28% /boot
  10. tmpfs 1.6G 0 1.6G 0% /run/user/1000

查看磁盘列表

  1. [root@localhost subadmin]# fdisk -l
  2. Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
  3. Units: sectors of 1 * 512 = 512 bytes
  4. Sector size (logical/physical): 512 bytes / 512 bytes
  5. I/O size (minimum/optimal): 512 bytes / 512 bytes
  6. Disklabel type: dos
  7. Disk identifier: 0x1a9c6fd2
  8. Device Boot Start End Sectors Size Id Type
  9. /dev/sda1 * 2048 2099199 2097152 1G 83 Linux
  10. /dev/sda2 2099200 106956799 104857600 50G 83 Linux
  11. /dev/sda3 106956800 123734015 16777216 8G 82 Linux swap / Solaris
  12. /dev/sda4 123734016 209715199 85981184 41G 5 Extended
  13. /dev/sda5 123736064 209715199 85979136 41G 83 Linux
  14. Disk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
  15. Units: sectors of 1 * 512 = 512 bytes
  16. Sector size (logical/physical): 512 bytes / 512 bytes
  17. I/O size (minimum/optimal): 512 bytes / 512 bytes

/dev/sdb磁盘为新的磁盘

新建分区

使用 fdisk /dev/sdb 新建分区(只新建一个主分区)
m 帮助,n 新建分区,p 主分区,w 保存并退出

  1. [root@localhost subadmin]# fdisk /dev/sdb
  2. Welcome to fdisk (util-linux 2.32.1).
  3. Changes will remain in memory only, until you decide to write them.
  4. Be careful before using the write command.
  5. Device does not contain a recognized partition table.
  6. Created a new DOS disklabel with disk identifier 0x270203bd.
  7. Command (m for help): m
  8. ...
  9. Command (m for help): n
  10. Partition type
  11. p primary (0 primary, 0 extended, 4 free)
  12. e extended (container for logical partitions)
  13. Select (default p):
  14. ...
  15. Command (m for help): w
  16. The partition table has been altered.
  17. Calling ioctl() to re-read partition table.
  18. Syncing disks.
  19. ....

格式化分区

  1. [root@localhost subadmin]# mkfs.ext4 /dev/sdb1
  2. mke2fs 1.45.6 (20-Mar-2020)
  3. Creating filesystem with 131071744 4k blocks and 32768000 inodes
  4. Filesystem UUID: 9182e309-b6b4-4226-bbf9-92c72cb76dc4
  5. Superblock backups stored on blocks:
  6. 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  7. 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
  8. 102400000
  9. Allocating group tables: done
  10. Writing inode tables: done
  11. Creating journal (262144 blocks):
  12. done
  13. Writing superblocks and filesystem accounting information: done

挂载分区

挂载到/u01目录下,先新建目录,再挂载

  1. [root@localhost subadmin]# mkdir /u01
  2. [root@localhost subadmin]# mount /dev/sdb1 /u01/
  3. [root@localhost subadmin]# df -hl
  4. Filesystem Size Used Avail Use% Mounted on
  5. devtmpfs 7.8G 0 7.8G 0% /dev
  6. tmpfs 7.8G 0 7.8G 0% /dev/shm
  7. tmpfs 7.8G 8.6M 7.8G 1% /run
  8. tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
  9. /dev/sda2 50G 2.1G 48G 5% /
  10. /dev/sda5 41G 325M 41G 1% /home
  11. /dev/sda1 976M 254M 655M 28% /boot
  12. tmpfs 1.6G 0 1.6G 0% /run/user/1000
  13. /dev/sdb1 492G 73M 467G 1% /u01

至此,挂载成功。