[root@node200 ~]# fdisk /dev/sdbWelcome 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.
Command (m forhelp): m
Command action
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
q quit without saving changes
s create a new empty Sun disklabel
w write table to disk and exit
[root@node200 ~]# sgdisk -p /dev/sdbDisk /dev/sdb: 1951170560 sectors, 930.4 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): EFA3DAF2-5AF2-44A0-9AC7-D9F50E60D831
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1951170526Partitions will be aligned on 2048-sector boundaries
Total free space is 4061 sectors (2.0 MiB)Number Start (sector) End (sector) Size Code Name
1209735681951170526 920.4 GiB FFFF ceph data
2204820971520 10.0 GiB FFFF ceph journal
[root@node200 ~]# sgdisk --zap-all --clear --mbrtogpt -g /dev/sddGPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
The operation has completed successfully.
type code一般就是8300(Linux filesystem),可通过sgdisk -L来查看所有。
出错:
1
2
3
4
5
6
7
8
9
10
11
12
Could not create partition 1 from 1 to 2097152
Could not change partition 1's type code to 8300!
Disk /dev/sdd: 16777216 sectors, 8.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C2CD3A11-3C49-4DD7-B5E9-8DA6F980CA81
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 16777182
Partitions will be aligned on 2048-sector boundaries
Total free space is 16777149 sectors (8.0 GiB)
Number Start (sector) End (sector) Size Code Name
Error encountered; not saving changes.
仔细看看发现First usable sector is 34,第一个可用扇区是34(前面33个扇区不能用),
所以得往后移33再次执行:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@node200 ~]# sgdisk -n 1:34:2097185 -t 1:8300 -p /dev/sddInformation: Moved requested sector from 34 to 2048 in
order to align on 2048-sector boundaries.
Disk /dev/sdd: 16777216 sectors, 8.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C2CD3A11-3C49-4DD7-B5E9-8DA6F980CA81
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 16777182Partitions will be aligned on 2048-sector boundaries
Total free space is 14682011 sectors (7.0 GiB)Number Start (sector) End (sector) Size Code Name
120482097185 1023.0 MiB 8300The operation has completed successfully.
执行成功!
不过你可用看到就是start扇区变成了2048,原因是需要分区对齐
Moved requested sector from 34 to 2048 in order to align on 2048-sector boundaries
如果忘记设置分区名了,就用下面命令:
1
sgdisk -c 1:"ceph journal" /dev/sdd
查看下是否成功:
1
2
3
4
5
6
7
8
9
10
11
[root@node200 ~]# sgdisk -p /dev/sddDisk /dev/sdd: 16777216 sectors, 8.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C2CD3A11-3C49-4DD7-B5E9-8DA6F980CA81
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 16777182Partitions will be aligned on 2048-sector boundaries
Total free space is 14682011 sectors (7.0 GiB)Number Start (sector) End (sector) Size Code Name
120482097185 1023.0 MiB 8300 ceph journal
分区格式化
一般来讲分区的时候不要做格式化,分完区之后单独来做格式化。
1
mkfs -t xfs /dev/sdd1
分区挂载
显示系统已挂载的分区列表:
1
df -h
挂载命令格式: mount [-t fstype] [-o options] device dir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1. -t vfstype 指定文件系统的类型,通常不必指定。mount 会自动选择正确的类型。常用类型有:
光盘或光盘镜像:iso9660
DOS fat16文件系统:msdos
Windows 9x fat32文件系统:vfat
Windows NT ntfs文件系统:ntfs
Mount Windows文件网络共享:smbfs
UNIX(LINUX) 文件网络共享:nfs
2. -o options 主要用来描述设备或档案的挂接方式。常用的参数有:
loop:用来把一个文件当成硬盘分区挂接上系统
ro:采用只读方式挂接设备
rw:采用读写方式挂接设备
iocharset:指定访问文件系统所用字符集
3. device 要挂接(mount)的设备。
4. dir设备在系统上的挂接点(mount point)。