[root@-znzj-app-1 /]# sudo fdisk /dev/vdc Welcome to fdisk (util-linux 2.23.2).
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 Building a new DOS disklabel with disk identifier 0xe4e64bc8.
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): First sector (2048-629145599, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): Using default value 629145599 Partition 1 of type Linux and of size 300 GiB is set
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
[root@-znzj-app-1 /]# sudo mkfs -t ext4 /dev/vdc mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 19660800 inodes, 78643200 blocks 3932160 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2227175424 2400 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
创建挂载目录
创建挂载目录,使用 mkdir 命令
1
$ sudo mkdir -p /mnt/data
挂载分区
挂载分区,使用 mount 命令
1
$ sudo mount /dev/vdc /mnt/data
卸载磁盘
在 Linux 中,卸载磁盘的命令为 umount 。卸载磁盘之前,需要先检查磁盘上是否有进程在使用它。如果有,则需要先终止相应的进程,才能安全地卸载磁盘。
挂载磁盘是 Linux 系统中一个基本的操作,它可以帮助我们扩展存储空间,管理数据文件,备份和存储重要文件等。在挂载磁盘之前,我们需要先对磁盘进行分区,并且在分区上创建文件系统。然后,我们需要使用 mount 命令将设备挂载到指定的目录下,并在必要时使用 /etc/fstab 文件配置开机自动挂载。最后,在卸载磁盘之前,需要先检查是否有进程在使用磁盘,并终止相应的进程。