查看当前磁盘情况
[root@localhost subadmin]# df -hlFilesystem Size Used Avail Use% Mounted ondevtmpfs 7.8G 0 7.8G 0% /devtmpfs 7.8G 0 7.8G 0% /dev/shmtmpfs 7.8G 8.6M 7.8G 1% /runtmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/sda2 50G 2.1G 48G 5% //dev/sda5 41G 325M 41G 1% /home/dev/sda1 976M 254M 655M 28% /boottmpfs 1.6G 0 1.6G 0% /run/user/1000
查看磁盘列表
[root@localhost subadmin]# fdisk -lDisk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x1a9c6fd2Device Boot Start End Sectors Size Id Type/dev/sda1 * 2048 2099199 2097152 1G 83 Linux/dev/sda2 2099200 106956799 104857600 50G 83 Linux/dev/sda3 106956800 123734015 16777216 8G 82 Linux swap / Solaris/dev/sda4 123734016 209715199 85981184 41G 5 Extended/dev/sda5 123736064 209715199 85979136 41G 83 LinuxDisk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
新建分区
使用 fdisk /dev/sdb 新建分区(只新建一个主分区)
m 帮助,n 新建分区,p 主分区,w 保存并退出
[root@localhost subadmin]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.32.1).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition table.Created a new DOS disklabel with disk identifier 0x270203bd.Command (m for help): m...Command (m for help): nPartition typep primary (0 primary, 0 extended, 4 free)e extended (container for logical partitions)Select (default p):...Command (m for help): wThe partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.....
格式化分区
[root@localhost subadmin]# mkfs.ext4 /dev/sdb1mke2fs 1.45.6 (20-Mar-2020)Creating filesystem with 131071744 4k blocks and 32768000 inodesFilesystem UUID: 9182e309-b6b4-4226-bbf9-92c72cb76dc4Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,102400000Allocating group tables: doneWriting inode tables: doneCreating journal (262144 blocks):doneWriting superblocks and filesystem accounting information: done
挂载分区
挂载到/u01目录下,先新建目录,再挂载
[root@localhost subadmin]# mkdir /u01[root@localhost subadmin]# mount /dev/sdb1 /u01/[root@localhost subadmin]# df -hlFilesystem Size Used Avail Use% Mounted ondevtmpfs 7.8G 0 7.8G 0% /devtmpfs 7.8G 0 7.8G 0% /dev/shmtmpfs 7.8G 8.6M 7.8G 1% /runtmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/sda2 50G 2.1G 48G 5% //dev/sda5 41G 325M 41G 1% /home/dev/sda1 976M 254M 655M 28% /boottmpfs 1.6G 0 1.6G 0% /run/user/1000/dev/sdb1 492G 73M 467G 1% /u01
至此,挂载成功。
