[root@dns ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_dns-LogVol03
100G 34G 61G 36% /
tmpfs 3.8G 72K 3.8G 1% /dev/shm
/dev/sda1 188M 114M 61M 66% /boot
/dev/mapper/vg_dns-LogVol01
9.1G 45M 8.6G 1% /tmp
通过 fdisk -l
查看新加入的磁盘
Disk /dev/sda: 211 MB, 211812352 bytes
4 heads, 32 sectors/track, 3232 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1dc3657a
Device Boot Start End Blocks Id System
/dev/sda1 * 2 3201 204800 83 Linux
Disk /dev/sdc: 3298.5 GB, 3298534883328 bytes
255 heads, 63 sectors/track, 401024 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
Disk /dev/sdb: 135.3 GB, 135297761280 bytes
197 heads, 4 sectors/track, 335347 cylinders
Units = cylinders of 788 * 512 = 403456 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3372e156
Device Boot Start End Blocks Id System
/dev/sdb1 1 335342 132124672 8e Linux LVM
我们可以看到 /dev/sdc 这块为新增加的磁盘,他并没有分区
我们下面开始分区,使用 fdisk /dev/sdc
命令初始化分区,输入m
可以获取帮助
[root@dns ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x49a73bdf.
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: The size of this disk is 3.3 TB (3298534883328 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
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)
分析:各个参数的解析
- 输入 m 显示所有命令列示。
- 输入 p 显示硬盘分割情形,打印分区表。
- 输入 a 设定硬盘启动区。
- 输入 n 设定新的硬盘分割区。
4.1. 输入 e 硬盘为[延伸]分割区(extend)。
4.2. 输入 p 硬盘为[主要]分割区(primary)。 - 输入 t 改变硬盘分割区属性。
t:分区系统id号:L:82:linux swap 83:linux 86:NTFS window分区 - 输入 d 删除硬盘分割区属性。
- 输入 q 结束不存入硬盘分割区属性。
- 输入 w 结束并写入硬盘分割区属性
输入 p
以查看分区表,此时无分区,分区表为空
Command (m for help): p
Disk /dev/sdc: 3298.5 GB, 3298534883328 bytes
255 heads, 63 sectors/track, 401024 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: 0x49a73bdf
Device Boot Start End Blocks Id System
输入 n
以创建分区表
1.选择分区类型,e:扩展分区,p:主分区(可以创建四个主分区)
2.输入主分区编号
3.输入分区的第一个柱面
4.输入分区的最后一个柱面,或者直接输入分区大小(单位:K,M,G)
5.分区表设置完成后,输入 w
以保存分区表
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-401024, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):
Using default value 267349
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
分区创建完毕
Disk /dev/sdc: 3298.5 GB, 3298534883328 bytes
255 heads, 63 sectors/track, 401024 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: 0xcc008e5f
Device Boot Start End Blocks Id System
/dev/sdc1 1 267349 2147480811 83 Linux
接下来,我们指定分区的文件系统,我们可以通过 df -hT
查询当前系统下其他分区的文件系统
[root@dns ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_dns-LogVol03
ext4 100G 34G 61G 36% /
tmpfs tmpfs 3.8G 72K 3.8G 1% /dev/shm
/dev/sda1 ext4 188M 114M 61M 66% /boot
/dev/mapper/vg_dns-LogVol01
ext4 9.1G 45M 8.6G 1% /tmp
这里其他的分区都是ext4的,这里也为我们创建的分区指定ext4的文件系统,通过 mkfs
命令
-t
参数后面跟上要指定的文件系统
最后跟上要指定的分区名称,我们这里是 /dev/sdc1
[root@dns ~]# mkfs -t ext4 /dev/sdc1
mke2fs 1.43-WIP (20-Jun-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
134217728 inodes, 536870202 blocks
26843510 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
16384 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, 214990848, 512000000
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
指定文件系统后,我们就可以挂载磁盘了,可以选择永久挂载或临时挂载
永久挂载
[root@dns ~]# vim /etc/fstab
在文件末尾新增以下内容
/dev/sdc1 /data ext4 defaults 1 1
临时挂载
[root@dns ~]# mount -t ext4 /dev/sdc1 /data
OK,至此文件挂载完毕,可以通过 df -h
查询一下挂载情况
[root@dns ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_dns-LogVol03
100G 34G 61G 36% /
tmpfs 3.8G 72K 3.8G 1% /dev/shm
/dev/sda1 188M 114M 61M 66% /boot
/dev/mapper/vg_dns-LogVol01
9.1G 45M 8.6G 1% /tmp
/dev/sdc1 2.0T 71M 1.9T 1% /data
END