运行 fdisk -l命令查看实例上的数据盘:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# fdisk -l Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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 Disklabel type: dos Disk identifier: 0x2621112d Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 83886046 83883999 40G 83 Linux Disk /dev/vdb: 20 GiB, 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 root@hadoop001:~/hadoop-3.2.1/etc/hadoop# |
执行命令后一般是/dev/vdb、/dev/vdb-/dev/vdz,若没有则需要确认数据盘是否已挂载。
依次运行以下命令,创建一个分区。运行
fdisk -u /dev/vdb命令分区数据盘:
1 2 3 4 5 6 7 8 9 10 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# fdisk -u /dev/vdb Welcome to fdisk (util-linux 2.31.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 0x96aaa545. Command (m for help): |
输入p查看数据盘的分区情况:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# fdisk -u /dev/vdb Welcome to fdisk (util-linux 2.31.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 0x96aaa545. Command (m for help): p Disk /dev/vdb: 20 GiB, 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 Disklabel type: dos Disk identifier: 0x96aaa545 Command (m for help): |
本示例中,数据盘没有分区。输入n创建一个新分区、输入p选择分区类型为主分区、输入1仅创建一个分区、输入第一个可用的扇区编号或按回车键采用默认值2048、输入最后一个扇区编号或按回车键采用默认值:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# fdisk -u /dev/vdb Welcome to fdisk (util-linux 2.31.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 0x96aaa545. Command (m for help): p Disk /dev/vdb: 20 GiB, 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 Disklabel type: dos Disk identifier: 0x96aaa545 Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): Created a new partition 1 of type 'Linux' and of size 20 GiB. Command (m for help): |
创建一个单分区数据盘可以只创建主分区,如果要创建四个以上分区则应该至少选择一次e(extended),创建至少一个扩展分区。
输入w保存分区,并在完成分区后退出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# fdisk -u /dev/vdb Welcome to fdisk (util-linux 2.31.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 0x96aaa545. Command (m for help): p Disk /dev/vdb: 20 GiB, 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 Disklabel type: dos Disk identifier: 0x96aaa545 Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): Created a new partition 1 of type 'Linux' and of size 20 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. root@hadoop001:~/hadoop-3.2.1/etc/hadoop# |
运行 fdisk -lu /dev/vdb命令查看新分区,如果出现/dev/vdb1的相关信息,表示新分区已创建完成。然后运行 mkfs.ext4 /dev/vdb1命令在新分区上创建一个文件系统。其他文件系统格式请自行修改mkfs.ext4命令。例如,如果需要在Linux、Windows和Mac系统之间共享文件,可以运行 mkfs.vfat /dev/vdb1命令创建VFAT文件系统:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# fdisk -lu /dev/vdb Disk /dev/vdb: 20 GiB, 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 Disklabel type: dos Disk identifier: 0x96aaa545 Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 41943039 41940992 20G 83 Linux root@hadoop001:~/hadoop-3.2.1/etc/hadoop# mkfs.ext4 /dev/vdb1 mke2fs 1.44.1 (24-Mar-2018) Creating filesystem with 5242624 4k blocks and 1310720 inodes Filesystem UUID: 5fc65c45-6289-4bea-98f7-98c03338622d Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done |
运行 echo /dev/vdb1 /data ext4 defaults 0 0 >> /etc/fstab命令向/etc/fstab写入新分区信息,这样在系统重启后才能实现自动挂载。
运行 mount /dev/vdb1 /data命令挂载文件系统,如果运行df -h命令后出现新建文件系统的信息,表示文件系统挂载成功:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
root@hadoop001:~/hadoop-3.2.1/etc/hadoop# echo /dev/vdb1 /mnt ext4 defaults 0 0 >> /etc/fstab root@hadoop001:~/hadoop-3.2.1/etc/hadoop# mkdir /data root@hadoop001:~/hadoop-3.2.1/etc/hadoop# mount /dev/vdb1 /data/ root@hadoop001:~/hadoop-3.2.1/etc/hadoop# df -h Filesystem Size Used Avail Use% Mounted on udev 976M 0 976M 0% /dev tmpfs 200M 2.7M 197M 2% /run /dev/vda1 40G 4.5G 33G 12% / tmpfs 997M 0 997M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 997M 0 997M 0% /sys/fs/cgroup tmpfs 200M 0 200M 0% /run/user/0 /dev/vdb1 20G 45M 19G 1% /data |
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » ECS Linux云盘挂载及格式化