1、查看系统里是否已经有了这个磁盘,命令及结果如下:
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 35 36 37 |
[root@MyCloudServer ~]# fdisk -l Disk /dev/xvdb: 75.2 GB, 75161927680 bytes 255 heads, 63 sectors/track, 9137 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: 0x000d68a3 Device Boot Start End Blocks Id System Disk /dev/xvda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0x0000aba6 Device Boot Start End Blocks Id System /dev/xvda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/xvda2 64 1306 9972736 8e Linux LVM Disk /dev/mapper/vg_501153278-lv_root: 9135 MB, 9135194112 bytes 255 heads, 63 sectors/track, 1110 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/mapper/vg_501153278-lv_swap: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 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 |
看到了确实存在这个磁盘
1 |
Disk /dev/xvdb: 75.2 GB, 75161927680 bytes |
2、我们现在要将它建立新的分区
1 |
fdisk /dev/xvdb |
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 |
[root@MyServer ~]# fdisk /dev/xvdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-9137, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-9137, default 9137): Using default value 9137 Command (m for help): t Selected partition 1 Hex code (type L to list codes): 83 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@MyServer ~]# |
3、这样新分区就创立好了,下一步我们将该分区格式化为ext3的格式
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 |
[root@MyServer ~]# mkfs.ext3 /dev/xvdb1 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 4587520 inodes, 18348230 blocks 917411 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 560 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 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@MyServer ~]# |
4、然后我们挂载到需要的目录上,通常可以挂载在/home/web/这里,并开机自动挂载
1 2 3 |
[root@MyServer ~]# mkdir -p /home [root@MyServer ~]# mount /dev/xvdb1 /home [root@MyServer ~]# echo "/dev/xvdb1 /home ext3 defaults 1 3" >> /etc/fstab |
如果您重装系统后,想保留这个数据,那么选择默认的只格式化系统盘就可以,如图:
然后再重复第4步即可。
转载请注明:VPS大师 » LINUX系统的VPS里挂载第二个硬盘且重装系统数据也不会丢失