1、发现磁盘
新添加磁盘后,虚拟机需要重启,惠普服务器需要给这块盘重新做下raid,才可以识别到。
2、查看磁盘:fdisk -l
[root@zhouqixiang ~]# fdisk -l
Disk /dev/sda: 88.0 GB, 87960846336 bytes
255 heads, 63 sectors/track, 10693 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: 0x00057c82
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1306 10485760 83 Linux
/dev/sda2 1306 2611 10484736 82 Linux swap / Solaris
/dev/sda3 2611 6683 32709677+ 83 Linux
/dev/sda4 6684 10693 32210325 83 Linux
Disk /dev/sdb: 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: 0x4d3ea151
Device Boot Start End Blocks Id System
Disk /dev/mapper/disknew-lv01: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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
如上,/dev/sdb就是新加的磁盘。
3、格式化磁盘
按tab补全键,可以看到有如下几种格式化命令
[root@zhouqixiang ~]# mkfs.ext
mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.ext4dev
[root@zhouqixiang ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
格式化完成。
4、挂载磁盘
a、直接通过磁盘编号,编辑/etc/fstab,添加如下红色一行
[root@zhouqixiang ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Mar 13 10:11:00 2014
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=1875994b-151d-407b-97f2-035f2f52e386 / ext4 defaults 1 1
UUID=25b811f2-37fa-4a87-bd1b-64e1e6de6c91 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/disknew/lv01 /opt/lv01 ext4 defaults 1 2
/dev/sdb /home/sdb ext4 defaults 0 0
b、通过UUID挂载,查看磁盘UUID:
[root@zhouqixiang ~]# blkid /dev/sdb
/dev/sdb: UUID="92242649-791e-412a-a5c4-5c3cb4b13f76" TYPE="ext4"
编辑/etc/fstab,添加如下红色一行
[root@zhouqixiang ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Mar 13 10:11:00 2014
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=1875994b-151d-407b-97f2-035f2f52e386 / ext4 defaults 1 1
UUID=25b811f2-37fa-4a87-bd1b-64e1e6de6c91 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/disknew/lv01 /opt/lv01 ext4 defaults 1 2
UUID=92242649-791e-412a-a5c4-5c3cb4b13f76 /home/sdb ext4 defaults 0 0
创建磁盘挂载目录:
[root@zhouqixiang ~]# mkdir /home/sdb
5、重新读取/etc/fstab,挂载所有写入到配置文件里的磁盘:mount -a
查看当前所有文件系统可用空间和使用情况:df -h
[root@zhouqixiang ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.9G 3.0G 6.4G 32% /
tmpfs 1.9G 260K 1.9G 1% /dev/shm
/dev/mapper/disknew-lv01
60G 180M 56G 1% /opt/lv01
/dev/sr0 4.0G 4.0G 0 100% /media/CentOS_6.3_Final
[root@zhouqixiang ~]# mount -a
[root@zhouqixiang ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.9G 3.0G 6.4G 32% /
tmpfs 1.9G 260K 1.9G 1% /dev/shm
/dev/mapper/disknew-lv01
60G 180M 56G 1% /opt/lv01
/dev/sr0 4.0G 4.0G 0 100% /media/CentOS_6.3_Final
/dev/sdb 9.9G 151M 9.2G 2% /home/sdb
本文出自 “网络技术” 博客,请务必保留此出处http://zqxiang.blog.51cto.com/2806551/1572652
原文地址:http://zqxiang.blog.51cto.com/2806551/1572652