检查磁盘情况
[root@VM_100_8_centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 1.1G 18G 6% /
查看硬盘个数及分区
[root@VM_100_8_centos ~]# fdisk -l
Disk /dev/vda: 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: 0x000736d7
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux
Disk /dev/vdb: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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
对这块500GB的硬盘进行分区
[root@VM_100_8_centos ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1bad5276.
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-1040253, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1040253, default 1040253):
Using default value 1040253
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次查看磁盘个数及分区
[root@VM_100_8_centos ~]# fdisk -l
Disk /dev/vda: 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: 0x000736d7
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux
Disk /dev/vdb: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 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: 0x1bad5276
Device Boot Start End Blocks Id System
/dev/vdb1 1 1040253 524287480+ 83 Linux
可以看到新的分区:/dev/vdb1已经创建完成。
格式化新分区(使用ext3扩展文件系统)
[root@VM_100_8_centos ~]# mkfs.ext4 /dev/vdb1
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
32768000 inodes, 131071870 blocks
6553593 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
4000 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, 71663616, 78675968,
102400000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
创建挂载目录
[root@VM_100_8_centos /]# mkdir /u01
[root@VM_100_8_centos /]# ls
bin data etc lib lost+found mnt proc sbin srv tmp usr
boot dev home lib64 media opt root selinux sys u01 var
[root@VM_100_8_centos /]#
挂载分区到目录
[root@VM_100_8_centos ~]# mount /dev/vdb1 /u01
[root@VM_100_8_centos ~]#
[root@VM_100_8_centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 1.1G 18G 6% /
/dev/vdb1 493G 198M 467G 1% /u01
设置开机自动挂载
[root@VM_100_8_centos ~]#
[root@VM_100_8_centos ~]# cat /etc/fstab
/dev/vda1 / ext3 noatime,acl,user_xattr 1 1
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
[root@VM_100_8_centos ~]# vim /etc/fstab
[root@VM_100_8_centos ~]#
[root@VM_100_8_centos ~]# cat /etc/fstab
/dev/vda1 / ext3 noatime,acl,user_xattr 1 1
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/vdb1 /u01 ext3 defaults 0 0
[root@VM_100_8_centos ~]#
重启
[root@VM_100_8_centos ~]# reboot
查看现在磁盘情况
[root@VM_100_8_centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 1.1G 18G 6% /
/dev/vdb1 493G 198M 467G 1% /u01
[root@VM_100_8_centos ~]#
查看操作系统版本
添加swap文件:
转换swap格式:
挂载Swap:
设置开机自动挂载
vim /etc/fstab
添加如下内容:
/u01/mem.swap swap swap defaults 0 0