新增存儲用Parted分區並建LVM卷
一,Parted分區
1,parted分區 www.2cto.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為實際讀寫速度。