买的虚拟机需要自己挂载硬盘,下面列下简单步骤,作为记录:
1、查看下当前文件系统
[root@VM_28_226_centos ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 8254240 1099340 6735608 15% /
只有一个/dev/vda1挂在了根下边,也就是系统软件装在这里
2、查看下当前硬盘情况
[root@VM_28_226_centos ~]# fdisk -l
Disk /dev/vda: 8589 MB, 8589901824 bytes
255 heads, 63 sectors/track, 1044 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: 0xcd6e8236
Device Boot Start End Blocks Id System
/dev/vda1 * 1 1044 8385898+ 83 Linux
Disk /dev/vdb: 268.4 GB, 268435456000 bytes
16 heads, 63 sectors/track, 520126 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/vdb doesn’t contain a valid partition table
Disk /dev/vdc: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/vdc doesn’t contain a valid partition table
看到一个盘,/dev/vdb,270G。现在格式化下。
3、格式化
[root@VM_28_226_centos ~]# mkfs -t ext3 /dev/vdb
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
16384000 inodes, 65536000 blocks
3276800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2000 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 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
-t 是指分区类型 这里用ext3
4、把磁盘挂载到/data
mount /dev/vdb /data
[root@VM_28_226_centos ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 8254240 1099384 6735564 15% /
/dev/vdb 258030980 191708 244732072 1% /data
5、设置开机自动挂载
vim /etc/fstab
添加一条
/dev/vdb /data ext3 noatime,acl,user_xattr 1 0
———————————————————–
分区
———————————————————–
1. 虚拟机–设置–添加,选择硬盘添加
2. 首先为磁盘创建文件系统:mkfs.ext3 /dev/sdb
3. 创建挂载点:mkdir /mnt/sdb
4. 挂载:mount /dev/sdb /mnt/sdb
5. fdisk -l
发现有问题:
Disk /dev/sdb doesn’t contain a valid partition table
6. fdisk /dev/sdb
跟着向导一步步做下去(如果不知道该输入什么,就输入“m”并回车,可以打印出菜单):
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
(后面的菜单省略,太长了)
这里我们要添加一个新的分区,所以输入“n”:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-14098, default 1): (此处直接回车)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-14098, default 14098): (此处直接回车)
Using default value 14098
Command (m for help): p
Disk /dev/sdb: 115.9 GB, 115964116992 bytes
255 heads, 63 sectors/track, 14098 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 14098 113242153+ 83 Linux
现在可以写入分区表了,所以输入“w”:
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
现在再fdisk -l,结果正常
转载随意~:陶醉 » linux挂载硬盘方法