Linux磁盘挂载

warning: 这篇文章距离上次修改已过805天,其中的内容可能已经有所变动。
  1. 终止以下程序:nginx、apache、mysql、php-fpm、ftp

    /etc/init.d/nginx stop

    /etc/init.d/httpd stop

    /etc/init.d/mysqld stop

    /etc/init.d/php-fpm stop

    /etc/init.d/vsftpd stop

  2. 查看磁盘分区

    fdisk -l

    Disk /dev/vda: 53.7 GB, 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
    Disk label type: dos
    Disk identifier: 0x0008d73a

    Device Boot Start End Blocks Id System
    /dev/vda1 * 2048 104855551 52426752 83 Linux

    Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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

  3. 磁盘分区

    fdisk /dev/vdb

  4. 格式化磁盘

    mkfs.ext4 /dev/vdb

  5. 挂载磁盘

    mount /dev/vdb /home

  6. 查看磁盘空间

    df -lh

  7. 设置重启服务器后自动挂载

    vi /etc/fstab
    插入一行
    /dev/vdb /home ext4 defaults 0 0

    取消挂载
    umount /dev/vdb

    若想直接直接格式化数据盘,也可以使用mkfs.ext4 /dev/vdb 格式化整个数据盘,然后再进行挂载

最后修改于:2022年03月07日 17:04

添加新评论