Linux_Centos6_新增硬盘分区,格式化和加载
此次操作是在VM虚拟机环境中进行:
- 首先需要添加一块硬盘–>点击编辑虚拟机设置–>点击弹框下面的添加–>选择硬盘–>点击下一步
- 选择SCSI类型–>点击下一步
- 默认–>下一步
- 选择下面的多文件–>下一步
- 点击完成–>确定–>左边的虚拟机就会多一块20G的硬盘
然后虚拟机开机,在进行分区操作之前先简单介绍下磁盘分区工具fdisk,有几个常用的命令,例:
fdisk + 新增磁盘:对指定的硬盘进行分区操作
fdisk -l :显示指定硬盘分区表信息
fdisk -d:删除一个硬盘分区
fdisk -n:创建一个分区
fdisk -p:列出硬盘分区表
fdisk -q:退出fdisk,不保存更改
fdisk -w:把设置写入硬盘分区表,然后退出。
介绍完命令我们开始操作,首先查看一下我们现在的分区情况
[root@root ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 17G 3.2G 13G 20% /
tmpfs 503M 72K 503M 1% /dev/shm
/dev/sda1 504M 39M 440M 9% /boot
/dev/sda2 5.8G 140M 5.4G 3% /home
/dev/sda3 4.9G 222M 4.4G 5% /var
[root@root ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes #第一块硬盘30G
255 heads, 63 sectors/track, 3916 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: 0x0007c967
#具体的分区情况
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 831 6144000 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 831 1468 5120000 83 Linux
/dev/sda4 1468 3917 19667968 5 Extended
/dev/sda5 1468 1723 2048000 82 Linux swap / Solaris
/dev/sda6 1723 3917 17617920 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes #这是新增的20G硬盘
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个主分区,4个逻辑分区,主分区大小为8G,逻辑分区大小分别为2G、3G、3G、2G
[root@root ~]# fdisk /dev/sdb #执行分区命令
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x543c4b70.
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 #N 新建分区
Command action
e extended
p primary partition (1-4)
p #P 主分区 E 扩展分区
Partition number (1-4): 1