Lunix 系统挂在云盘
查看现在的系统挂载目录情况
df -h Filesystem Size Used Avail Use% Mounted on udev 7.7G 0 7.7G 0% /dev tmpfs 1.6G 3.2M 1.6G 1% /run /dev/vda1 40G 3.3G 35G 9% / tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup tmpfs 1.6G 0 1.6G 0% /run/user/0
查看当前服务器下的云盘列表
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: 0xc0f4f2f1 Device Boot Start End Sectors Size Id Type #已挂载 /dev/vda1 * 2048 83886046 83883999 40G 83 Linux Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 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
接下来我们将/dev/vdb 磁盘挂载到 /mnt 目录中
#创建 /mnt 目录 mkdir -p /mnt
硬盘分区(依次输入:n -> p -> 回车 ->回车-> 回车 -> wq)
fdisk /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 0x8b3ada07. 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-209715199, default 2048): # 回车 Last sector, +sectors or +size{K,M,G,T,P} (2048-209715199, default 209715199): # 回车 Created a new partition 1 of type 'Linux' and of size 100 GiB. Command (m for help): wq The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
查看磁盘的设备
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: 0xc0f4f2f1 Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 83886046 83883999 40G 83 Linux Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 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: 0x8b3ada07 Device Boot Start End Sectors Size Id Type # 新磁盘 /dev/vdb1 2048 209715199 209713152 100G 83 Linux
格式化 /dev/vdb1 格式为ext4
mkfs.ext4 /dev/vdb1 mke2fs 1.44.1 (24-Mar-2018) Creating filesystem with 26214144 4k blocks and 6553600 inodes Filesystem UUID: 5c751782-a33e-4650-8407-1caafbfb29a8 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done
挂载 /dev/vdb1 到/mnt
echo /dev/vdb1 /mnt ext4 defaults 0 0 >> /etc/fstab # 向 /etc/fstab 写入新分区信息
mount /dev/vdb1 /mnt # 挂载文件系统
查看系统挂载目录
df -h Filesystem Size Used Avail Use% Mounted on udev 7.7G 0 7.7G 0% /dev tmpfs 1.6G 3.2M 1.6G 1% /run /dev/vda1 40G 3.3G 35G 9% / tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup tmpfs 1.6G 0 1.6G 0% /run/user/0 /dev/vdb1 98G 61M 93G 1% /mnt
可以看到最后一行多了磁盘目录,说明已经挂载成功

浙公网安备 33010602011771号