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

2015-09-27 10:27:00
hainuo
原创 2226
摘要:在linux上挂在硬盘
如何在linux上挂在硬盘这对很多新手来说很痛苦的,因为怕弄错了。其实这一点大可不必,我们的操作不会对系统产生很大的影响,哪怕你挂载在了错误位置首先我们要弄清楚```➜ ~ fdisk -lDisk /dev/xvda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000da36d Device Boot Start End Blocks Id System/dev/xvda1 * 2048 41940991 20969472 83 LinuxDisk /dev/xvdb: 107.4 GB, 107374182400 bytes43 heads, 44 sectors/track, 110843 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0b93bdf4 Device Boot Start End Blocks Id System/dev/xvdb1 2048 209715199 104856576 83 Linux```通过以上可以看到有一个硬盘 svdb1 100G需要挂在那么挂在需要先对硬盘进行格式化如何格式化呢```➜ ~ mkfs.ext4 /dev/xvdb1mke2fs 1.42.9 (4-Feb-2014)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks6553600 inodes, 26214144 blocks1310707 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296800 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done```关键看最后这个done就搞定了然后就是```mkdir /home/wwwrootmount /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```
发表评论
柒 加 伍 =
评论通过审核后显示。