新增存储用Parted分区并建LVM卷
一,Parted分区
1,parted分区 www.zhishiwu.com
# parted /dev/sda
GNU Parted 2.1
使用 /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help 首先看看帮助熟悉下
align-check TYPE N check partition N for TYPE(min|opt) alignment
check NUMBER do a simple check on the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkfs NUMBER FS-TYPE make a FS-TYPE file system on partition NUMBER
mkpart PART-TYPE [FS-TYPE] START END make a partition
mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system
move NUMBER START END move partition NUMBER
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions,
or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
resize NUMBER START END resize partition NUMBER and its file system
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
(parted) mktable
新的磁盘标签类型? gpt GPT就是GRUB分区表,如果是MBR,最大支持2T分区
(parted) p 打印一下信息这里的4398GB是磁盘容量
Model: DELL MD32xx (scsi)
Disk /dev/sda: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name 标志
(parted) mkpart #新建分区
分区名称? []? #默认
文件系统类型? [ext2]? #默认
起始点? 0G #起点
结束点? 4398G #终点
(parted) p
Model: DELL MD32xx (scsi)
Disk /dev/sda: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name 标志
1 1049kB 4398GB 4398GB
(parted) toggle 1 lvm #标记成lvm
(parted) p
Model: DELL MD32xx (scsi)
Disk /dev/sda: 4398GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name 标志
1 1049kB 4398GB 4398GB lvm
(parted) quit
信息: You may need to update /etc/fstab.
2,同样的方法对sdb,sdc,sdd 分区
二,创建LVM,分三大步,分别建PV,VG,LVM
1,建PV
# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
Writing physical volume data to disk "/dev/sda1"
Physical volume "/dev/sda1" successfully created
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
Writing physical volume data to disk "/dev/sdd1"
Physical volume "/dev/sdd1" successfully created
2,建VG
# vgcreate md3200 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
Volume group "md3200" successfully created
# lvcreate -n md3200lv1 -L 8T md3200
Logical volume "md3200lv1" created
You have new mail in /var/spool/mail/root
3,建LVM
#lvcreate -n md3200lv1 -L 8T md3200
Logical volume "md3200lv1" created
#lvcreate -n md3200lv2 -L 8T md3200
Logical volume "md3200lv2" created
三,格式化文件系统
# mkfs.ext4 /dev/md3200/md3200lv1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
536870912 inodes, 2147483648 blocks
107374182 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
65536 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, 550731776, 644972544, 1934917632
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
四,设置开机自动挂载
# mkdir md3200lv1 md3200lv2
# mount /dev/md3200/md3200lv1 /md3200lv1/
# ls /md3200lv1/
lost+found
#tail -n 2 /etc/fstab
/dev/md3200/md3200lv1 /md3200lv1 ext4 defaults 1 2
/dev/md3200/md3200lv2 /md3200lv2 ext4 defaults 1 2
五,重启验证
#reboot
# df -hl
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/md3200-md3200lv1
7.9T 175M 7.5T 1% /md3200lv1
/dev/mapper/md3200-md3200lv2
7.9T 175M 7.5T 1% /md3200lv2
六,最后顺便测试一下存储的读写速度
# dd if=/dev/zero of=./test bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,8.83453 秒,1.2 GB/秒
# free -g
total used free shared buffers cached
Mem: 62 11 51 0 0 9
-/+ buffers/cache: 1 61
Swap: 7 0 7
# dd if=./test of=./test1 bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,12.3038 秒,852 MB/秒
# dd if=./test1 of=./test2 bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,19.0357 秒,551 MB/秒
# dd if=./test2 of=./test3 bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,18.641 秒,563 MB/秒
# free -g
total used free shared buffers cached
Mem: 62 41 21 0 0 39
-/+ buffers/cache: 2 60
Swap: 7 0 7
# dd if=./test3 of=./test4 bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,17.3797 秒,603 MB/秒
# dd if=./test4 of=./test5 bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,22.8714 秒,458 MB/秒
# dd if=./test5 of=./test6 bs=10M count=1000
记录了1000+0 的读入
记录了1000+0 的写出
10485760000字节(10 GB)已复制,100.246 秒,105 MB/秒
因为内存是64G,故前面测试有缓存,最后105为实际读写速度。