Linux系统挂载阿里云“多余的”数据盘步骤
微魔最近刚刚从外地出差回来,也终于可以恢复更新了~今天和大家分享的是如何挂载阿里云的“数据硬盘”(阿里云开通后默认只挂载了“系统盘”),说到这个所谓的“数据盘”,因为微魔属于阿里云的早期的用户,曾经在之前的促销中订购了这个多余的数据盘(40G),但一直没有挂载,遗憾的是这个数据盘一旦订购就不能取消(即使没挂载也不能取消!),这个问题对于微魔这样的小用户而言无疑是一种莫大的浪费(特别是金钱上的浪费…),既然无法取消,那就既来之则安之吧。接下来就和大家分享一下这个挂载数据盘的方法吧。
另外插播一条消息,阿里云在4月29日的时候上线了北京的数据中心,这也是继杭州、青岛之后的第三个数据中心,至于大家一直期待的香港机房,一直在剧透,但一直没有实现…
1.使用命令”df -h”查看你是否有可用的数据盘,如果存在,返回如下,
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
224 heads, 56 sectors/track, 3343 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992cadc0
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 3343 20967268 83 Linux
Disk /dev/xvdb: 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: 0x00000000
Disk /dev/xvdb doesn't contain a valid partition table
2.使用如下命令对数据盘进行分区
fdisk -S 56 /dev/xvdb
依次输入【n】->【p】->【1】->【回车】->【回车】->【wq】
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc3137cf3.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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-5874, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-5874, default 5874):
Using default value 5874
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3.使用“fdisk -l”命令可以看到新的分区xvdb1。
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
224 heads, 56 sectors/track, 3343 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992cadc0
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 3343 20967268 83 Linux
Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
255 heads, 56 sectors/track, 5874 cylinders
Units = cylinders of 14280 * 512 = 7311360 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3137cf3
Device Boot Start End Blocks Id System
/dev/xvdb1 1 5874 41940332 83 Linux
4.使用如下命令格式化分区
mkfs.ext4 /dev/xvdb1
root@AY121002102934f589042:~# mkfs.ext4 /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
2621440 inodes, 10485083 blocks
524254 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
320 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5.使用如下命令,添加分区信息(将数据盘挂载在/mnt,也可自行修改)
echo '/dev/xvdb1 /mnt ext4 defaults 0 0' >> /etc/fstab
6.使用如下命令查看挂载的分区
cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#
proc /proc proc defaults 0 0
# / was on /dev/xvda1 during installation
UUID=34e4b8c4-016a-4003-8b4d-92aeb3cdc3c5 / ext3 errors=remount-ro 0 1
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
xenfs /proc/xen xenfs defaults 0 0
/dev/xvdb1 /mnt ext4 defaults 0 0
7.使用“mount -a”命令挂载新分区,并用“df -h”命令查看,出现如下信息则证明成功了
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 4.2G 16G 22% /
tmpfs 501M 0 501M 0% /lib/init/rw
udev 497M 116K 496M 1% /dev
tmpfs 501M 0 501M 0% /dev/shm
/dev/xvdb1 40G 176M 38G 1% /mnt
以后重装系统的话,系统盘会被清除,但是这个数据盘上的数据是不受影响的,只是需要重新挂载,直接使用如下命令即可,
echo '/dev/xvdb1 /mnt ext4 defaults 0 0' >> /etc/fstab
mount -a