linux 下ssd分区,4k对齐

1、查看磁盘

fdisk -l
image.png

2、开始分区

fdisk -c -u /dev/sdc

通过停用DOS兼容模式和设置扇区单元可以实现正确的对齐(分区将从LBA地址2,048开始。对于页面大小为4096字节的SSD,在开始时将有256个空页。磁盘分区将在第257页处开始)。

[root@dgw-zw-jmkfw-dbserver-02 ~]# fdisk -c -u /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xb875f3eb.

Command (m for help): p

Disk /dev/sdc: 549.8 GB, 549755813888 bytes, 1073741824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb875f3eb

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-1073741823, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1073741823, default 1073741823): 
Using default value 1073741823
Partition 1 of type Linux and of size 512 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3、格式化

查看分区:

fdisk -l
Disk /dev/sdc: 549.8 GB, 549755813888 bytes, 1073741824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x6c9ca88b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048  1073741823   536869888   83  Linux

格式化为ext4

mkfs -t ext4 /dev/sdc1
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
33554432 inodes, 134217472 blocks
6710873 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2281701376
4096 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

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done  

4、挂载

mount /dev/sdc1 /home

配置开机自动挂载:
获取分区UUID

>blkid /dev/sdc1
/dev/sdc1: UUID="45cce841-d4ba-4dae-bb23-dd3a8a89e015" TYPE="ext4" 

修改启动挂载配置文件:
添加一行
UUID=45cce841-d4ba-4dae-bb23-dd3a8a89e015 /home ext4 defaults 0 2

vi /etc/fstab

保存
结束!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容