关于4k对齐

Get the alignment parameters for your array (remember to replace sdb with the name of your device as seen by the kernel).

# cat /sys/block/sdb/queue/optimal_io_size

1048576

# cat /sys/block/sdb/queue/minimum_io_size

262144

# cat /sys/block/sdb/alignment_offset

0

# cat /sys/block/sdb/queue/physical_block_size

512

Add optimal_io_size to alignment_offset and divide the result by physical_block_size. In my case this was (1048576 + 0) / 512 = 2048.This number is the sector at which the partition should start. Your new parted command should look like

mkpart primary 2048s 100%

The trailing ‘s’ is important: it tells parted that you’re talking about sectors, not bytes or megabytes. If all went well, the partition will have been created with no warnings. You can check the alignment thusly (replacing ‘1’ with the partition number if necessary):

(parted) align-check optimal 1

1 aligned

磁盘分区4k对齐问题,开始位置设置为“0%”,结束位置设置为“100%”,可以保证使用最大空间的前提下4k对齐。

参考文章:

https://blog.csdn.net/open_data/article/details/44828741

3. 格式化新的分区

服务器数据盘一般格式化xfs,一般桌面的系统可以用ext4,xfs单个分区的容量比ext4同等条件下大。

> sudo mkfs.xfs /dev/sdb1 // xfs硬盘格式化

> sudo mkfs.ext4 /dev/sdb1 // ext4硬盘格式化

4. LVM划分加载硬盘

创建物理卷

# pvcreate /dev/sdb1

将物理设备加入卷组

# vgcreate vg_data /dev/sdb1

说明:可以将多个分区和到一起,如下

# vgcreate vg_data /dev/sdb1 /dev/sdc1

使用整个卷组空间创建逻辑卷

# lvcreate -l 100%FREE -n lv_data vg_data

5. 挂载逻辑卷设备

# mount /dev/vg_data/lv_data /vol/data

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐