前言

最近我在研究pve + bcache ,发现了bcache默认创建的分区bcache0默认的分区是MBR

也就是说,这个分区最大只能存2T数据,我硬盘是6T的,浪费了很多空间

解决

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root@pve:~# fdisk /dev/bcache0 

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The device contains 'ext4' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Device does not contain a recognized partition table.
The size of this disk is 4.9 TiB (5368709111808 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).

Created a new DOS (MBR) disklabel with disk identifier 0xe2e809b2.

Command (m for help): p
Disk /dev/bcache0: 4.88 TiB, 5368709111808 bytes, 10485759984 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
Disklabel type: dos
Disk identifier: 0xe2e809b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@pve:~# lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 10G 0 disk
└─bcache0 251:0 0 4.9T 0 disk
sdb 8:16 0 30G 0 disk
├─sdb1 8:17 0 1007K 0 part
├─sdb2 8:18 0 512M 0 part
└─sdb3 8:19 0 29.5G 0 part
├─pve-swap 252:0 0 3.6G 0 lvm [SWAP]
├─pve-root 252:1 0 12.9G 0 lvm /
├─pve-data_tmeta 252:2 0 1G 0 lvm
│ └─pve-data 252:4 0 10.9G 0 lvm
└─pve-data_tdata 252:3 0 10.9G 0 lvm
└─pve-data 252:4 0 10.9G 0 lvm
sdc 8:32 0 4.9T 0 disk
└─bcache0 251:0 0 4.9T 0 disk
sr0 11:0 1 1.2G 0 rom

虽然分区什么的都还是可以出来的而且容量显示的是4.88T,但是显示的是dos,也就是MBR分区

显示的是4.88T其实实际只能写进去2T的数据

我的解决思路是先将bcache0分区使用gdisk转成GPT分区,然后再格式化ext4并挂载

下面放 我转成GPT格式之后查看的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@pve:~# fdisk /dev/bcache0 

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The primary GPT table is corrupt, but the backup appears OK, so that will be used.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): p
Disk /dev/bcache0: 4.88 TiB, 5368709111808 bytes, 10485759984 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
Disklabel type: gpt
Disk identifier: 0FE58467-8968-4452-85E5-EBCA7C9A2792

可以看到已经是变成GPT分区了

但是在格式化之后出现了点问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@pve:~# mkfs.ext4 /dev/bcache0
mke2fs 1.47.0 (5-Feb-2023)
Found a gpt partition table in /dev/bcache0
Proceed anyway? (y,N) y
Discarding device blocks: done
Creating filesystem with 1310719998 4k blocks and 163840000 inodes
Filesystem UUID: 30e5fe27-2d0c-4f46-ae61-23bfe2998d3b
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

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
root@pve:~# fdisk /dev/bcache0 

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The device contains 'ext4' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Device does not contain a recognized partition table.
The size of this disk is 4.9 TiB (5368709111808 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).

Created a new DOS (MBR) disklabel with disk identifier 0x929b70dc.

Command (m for help): p
Disk /dev/bcache0: 4.88 TiB, 5368709111808 bytes, 10485759984 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
Disklabel type: dos
Disk identifier: 0x929b70dc

Command (m for help):

再次查看发现又变成MBR分区了,我纳闷了,这是什么情况???

我询问了下技术群里的大佬后,发现这个应该是变成无分区表了

1
2
3
4
5
root@pve:~# fdisk -l /dev/bcache0 
Disk /dev/bcache0: 4.88 TiB, 5368709111808 bytes, 10485759984 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
1
2
3
4
5
6
7
8
9
root@pve:~# parted /dev/bcache0 print
Model: Unknown (unknown)
Disk /dev/bcache0: 5369GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number Start End Size File system Flags
1 0.00B 5369GB 5369GB ext4

fdisk -l /dev/bcache0 命令并没有显示出任何的分区表格式,而且parted /dev/bcache0 print 显示了loop

至于为什么 /dev/bcache0 格式化ext4会显示出dos也就是MBR,可能是因为linux错把ext4识别成MBR了

无分区表没有任何的容量限制

下面是无分区表的概念

  1. 无分区表指的是存储设备上没有分区表或者没有对应的分区信息。在这种情况下,整个存储设备被视为一个单一的分区,也就是说整个设备被当作一个大的逻辑存储单元来处理。
  2. 在 Linux 系统中,可以通过直接在一个设备上创建文件系统来实现无分区表的存储设备,这通常用于一些特殊的应用场景,比如直接使用一个磁盘作为整个文件系统的存储介质,而不对其进行分区划分。
  3. 无分区表的优点是简化了存储管理,减少了对分区表的管理和维护。但缺点是如果需要对存储设备进行多重分区、引导操作系统等操作时,会变得更加复杂。
  4. 大多数情况下,为了更好地管理存储空间、提高系统的灵活性和可维护性,我们会选择使用分区表来划分存储设备,但无分区表的方式在某些特定的场景下仍然具有一定的实用性。