使用虚拟机时发现磁盘空间不够了,需要挂载一个磁盘以供继续使用,但是磁盘不是添加就可以使用的,还需要进行挂载。
一、添加磁盘
添加加新硬盘重启服务器
添加完之后就可以重启机器了,如果你机器是开启的,进入系统并不能看见你刚添加的那块磁盘,只有等系统重启,重新加载之后才会显示安装的那块磁盘
二、进入系统
使用root用户进入系统
三、 查看硬盘信息
[root@localhost ~]
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000c4cb5
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xd0f5c869
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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
-
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
可以看到这台机器加载了三个磁盘sda、sdb、sdc 其中sda是初始磁盘,sdb已经初始化且经过使用,sdc是刚刚加载的,未格式化的新磁盘
四、创建新硬盘分区
[root@localhost ~]
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x45a3cadb.
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): 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
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
-
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
知道命令之后就可以进行分区了
Command (m for help): p
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x45a3cadb
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extende
p primary partition (1-4)
p
Partition number (1-4):
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610
Command (m for help): p
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x45a3cadb
Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
-
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
-
38
-
39
再次使用”fdisk -l”命令查看磁盘信息
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x406a4c58
Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux
第三块磁盘/dev/sdc已经分区好了
五、格式化分区
[root@localhost ~]
//将/dev/sdc1格式化为ext3类型,好像大部分的磁盘都是格式化为ext3类型,具体为什么没有深入研究,暂时不清楚,想了解的朋友可以自己查一下
[root@localhost ~]
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
160 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
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
-
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
格式化完毕,此时就可以使用“mount”命令挂载分区了,然后使用这个磁盘空间了
六、挂载分区以及开机自动挂载
[root@localhost ~]
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 18G 15G 1.5G 92% /
tmpfs 932M 76K 932M 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/sdb1 20G 1.2G 18G 7% /disk/diskone
/dev/sr0 4.2G 4.2G 0 100% /media/CentOS_6.5_Final
[root@localhost /]# cd /disk/
[root@localhost disk]
总用量 4
drwxr-xr-x. 4 root root 4096 7月 28 17:04 diskone
[root@localhost disk]
[root@localhost diskone]
总用量 20
drwx------. 2 root root 16384 7月 28 16:12 lost+found
drwxr-xr-x. 2 root root 4096 7月 28 17:09 software
[root@localhost diskone]
[root@localhost disk]
[root@localhost disk]
总用量 8
drwxr-xr-x. 4 root root 4096 7月 28 17:04 diskone
drwxr-xr-x. 2 root root 4096 8月 1 16:48 disktwo
[root@localhost disk]
[root@localhost disk]
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 18G 15G 1.5G 92% /
tmpfs 932M 76K 932M 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/sdb1 20G 1.2G 18G 7% /disk/diskone
/dev/sr0 4.2G 4.2G 0 100% /media/CentOS_6.5_Final
/dev/sdc1 20G 173M 19G 1% /disk/disktwo
-
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
磁盘已经挂载上了 下面设置开机自动挂载 编辑/etc/fstab文件,再最后面添加 /dev/sdc1(磁盘分区) /disk/disktwo(挂载目录) ext3(文件格式)defaults 0 0
vim /etc/fstab
/dev/sdc1(磁盘分区) /disk/disktwo(挂载目录) ext3(文件格式)defaults 0 0
之后重启就OK啦!!!
(责任编辑:yang) |