阿里云主机linux系统如何挂在云硬盘

2015-09-27 10:27:00
hainuo
原创 2328
摘要:在linux上挂在硬盘
如何在linux上挂在硬盘这对很多新手来说很痛苦的,因为怕弄错了。 其实这一点大可不必,我们的操作不会对系统产生很大的影响,哪怕你挂载在了错误位置 首先我们要弄清楚 ``` ➜ ~ fdisk -l Disk /dev/xvda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 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 Disk identifier: 0x000da36d Device Boot Start End Blocks Id System /dev/xvda1 * 2048 41940991 20969472 83 Linux Disk /dev/xvdb: 107.4 GB, 107374182400 bytes 43 heads, 44 sectors/track, 110843 cylinders, total 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 Disk identifier: 0x0b93bdf4 Device Boot Start End Blocks Id System /dev/xvdb1 2048 209715199 104856576 83 Linux ``` 通过以上可以看到有一个硬盘 svdb1 100G需要挂在 那么挂在需要先对硬盘进行格式化 如何格式化呢 ``` ➜ ~ mkfs.ext4 /dev/xvdb1 mke2fs 1.42.9 (4-Feb-2014) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214144 blocks 1310707 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 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done ``` 关键看最后这个done 就搞定了 然后就是 ``` mkdir /home/wwwroot mount /dev/xvdb1 /home/wwwroot ``` 将硬盘挂在到web分区中,保证web的容量 挂在错了怎么取消挂载呢 ``` umount /home/wwwroot ``` Ps 我们需要注意的是,当前这种方式不能够及时挂载相应的分区, 需要我们作如下处理 在`/etc/fstab`文件末尾写入自动挂载处理命令 ``` /dev/xvdb1 /home/wwwroot ext4 defaults 1 2 ``` 也可以使用命令 ``` echo '/dev/xvdb1 /home/wwwroot ext4 defaults 1 2' >> /etc/fstab ```
发表评论
捌 加 叁 =
评论通过审核后显示。