linux挂载硬盘不分区方法

查看所有硬盘信息

下面可以看到有一个/dev/vdb硬盘没有挂载

    1. [root@123456 ~]# fdisk -l

    1. Disk/dev/vda:42.9 GB,42949672960 bytes,83886080 sectors

    1. Units= sectors of 1*512=512 bytes

    1. Sector size (logical/physical):512 bytes /512 bytes

    1. I/O size (minimum/optimal):512 bytes /512 bytes

    1. Disk label type: dos

    1. Disk identifier:0x0008d73a

    1. DeviceBootStartEndBlocksIdSystem

    1. /dev/vda1 *2048838840314194099283Linux

    1. Disk/dev/vdb:21.5 GB,21474836480 bytes,41943040 sectors

    1. Units= sectors of 1*512=512 bytes

    1. Sector size (logical/physical):512 bytes /512 bytes

    1. I/O size (minimum/optimal):512 bytes /512 bytes

格式化硬盘

硬盘比较小,直接格式化,不分区

    1. [root@123456 ~]# mkfs.ext4 /dev/vdb

    1. mke2fs 1.42.9(28-Dec-2013)

    1. Filesystem label=

    1. OS type:Linux

    1. Block size=4096(log=2)

    1. Fragment size=4096(log=2)

    1. Stride=0 blocks,Stripe width=0 blocks

    1. 1310720 inodes,5242880 blocks

    1. 262144 blocks (5.00%) reserved for the super user

    1. First data block=0

    1. Maximum filesystem blocks=2153775104

    1. 160 block groups

    1. 32768 blocks per group,32768 fragments per group

    1. 8192 inodes per group

    1. Superblock backups stored on blocks:

    1. 32768,98304,163840,229376,294912,819200,884736,1605632,2654208,

    1. 4096000

    1. Allocatinggroup tables:done

    1. Writing inode tables:done

    1. Creating journal (32768 blocks):done

    1. Writing superblocks and filesystem accounting information:done

 

挂载硬盘到指定目录

这里把硬盘挂载到根目录下的/data

    1. [root@123456 ~]# mount /dev/vdb /data

    1. mount: mount point /data does not exist

    1. [root@123456 ~]# mkdir /data

    1. [root@123456 ~]# mount /dev/vdb /data

 

修改启动文件

保证系统启动时,自动挂载硬盘

  1. vim /etc/fstab

/etc/fstab文件末尾添加上:

  1. /dev/vdb /data ext4 defaults 00

重启系统

  1. init 6

重启后检查挂载

    1. [root@123456 ~]# df -h

    1. FilesystemSizeUsedAvailUse%Mounted on

    1. devtmpfs 909M0909M0%/dev

    1. tmpfs 919M0919M0%/dev/shm

    1. tmpfs 919M444K919M1%/run

    1. tmpfs 919M0919M0%/sys/fs/cgroup

    1. /dev/vda1 40G12G27G30%/

    1. /dev/vdb 20G45M19G1%/data

    1. tmpfs 184M0184M0%/run/user/0

 

重新挂载到新目录

    1. # 解除旧的挂载

    1. umount /data

    1. # 挂载到新目录

    1. mount /dev/vdb /data-new

    1. # 修改启动文件

    1. vim /etc/fstab

    1. /dev/vdb /data-new ext4 defaults 00

    1. `

以上是 linux挂载硬盘不分区方法 的全部内容, 来源链接: www.h5w3.com/123047.html

回到顶部