A-A+
linux 挂载新硬盘,重启后自动挂载
1.新拿到一台liux主机,默认增加的硬盘没有挂载。所以需要创建文件系统同时挂载到一个目录下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#首先查看一下当前系统下有几块硬盘 [root@localhost tmp]# fdisk -l Disk /dev/xvda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000b5248 Device Boot Start End Blocks Id System /dev/xvda1 * 1 5197 41737216 83 Linux /dev/xvda2 5197 5222 204800 82 Linux swap / Solaris Disk /dev/xvde: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/xvde doesn't contain a valid partition table |
2.然后创建文件系统格式化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[root@localhost tmp]# mkfs -t ext4 /dev/xvde mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214400 blocks 1310720 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 800 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 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
3.创建一个目录,将格式后的硬盘挂载到这个目录下
1 2 3 4 5 6 7 8 9 10 |
[root@localhost tmp]# mount /dev/xvd xvda xvda1 xvda2 xvde [root@localhost tmp]# mount /dev/xvde /var/yuqing #df 看一下,就可以看到后面挂载的硬盘了。 [root@localhost tmp]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 40G 3.9G 34G 11% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/xvde 99G 188M 94G 1% /var/yuqing |
4. 然后,最后一步就是将挂载信息写入到fstab中。
1 2 3 |
[root@localhost tmp]# vim /etc/fstab #增加一下内容,即可 /dev/xvde /var/yuqing ext4 defaults 1 2 |