在我的辅助驱动器上,我使用Gparted删除EFI (/dev/sda1 1)和Ubuntu (/dev/sda1 2)分区。第三个分区(/dev/sda3 3)用于数据,因此我调整了它的大小,以便通过删除前两个分区来使用所有未分配的空间。现在,在磁盘上只有一个唯一的部分,为了获得/dev/sda1 1,我想修复它的编号。对于有GPT分区表的磁盘来说,最简单的方法是什么?谢谢!
发布于 2017-05-26 18:06:34
由于发现了最后一个链接,我很想学习一些新的东西,我用一个32 my的USB驱动器重放Generoso在我的系统上的分区情况。以下是我的发现,但首先我:
结论:我的例子是针对1 (final)分区的,最后我只是更改了它的名称。我没有触及实际的部门。在我上面评论中的链接中,有一个例子显示了扇区号被移动的地方。我跟着它,悲惨地愚弄和破坏了USB磁盘,证明玩分区是多么危险!!
也许我的场景也适用于多个分区,您可以自己尝试一下。我敢说你可以用你的主分区..。哈哈。
好的,这是我的:
发现:使用G期,我创建了3个分区,每个分区1GB。
# fdisk -l /dev/sdc
Disk /dev/sdc: 30 GiB, 32176472064 bytes, 62844672 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: 0xf33657fc
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 2099199 2097152 1G 83 Linux
/dev/sdc2 2099200 4196351 2097152 1G 83 Linux
/dev/sdc3 4196352 6293503 2097152 1G 83 Linux使用磁盘挂载分区3。
手动将一个文件放在上面。
# ls -l /media/willem/cd4746ac-6d9f-4057-9396-a593ce2f301d/
total 21436
drwx------ 2 root root 16384 May 27 00:12 lost+found
-rw-r--r-- 1 root root 21930117 May 27 00:14 SomeFile.txt使用磁盘卸载分区3。
使用G以来删除分区1和2,并增长分区3使用整个磁盘。
# fdisk -l /dev/sdc
Disk /dev/sdc: 30 GiB, 32176472064 bytes, 62844672 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: 0xf33657fc
Device Boot Start End Sectors Size Id Type
/dev/sdc3 8192 62844671 62836480 30G 83 Linux使用磁盘挂载分区3。
检查分区3上的文件。
# ls -l /media/willem/cd4746ac-6d9f-4057-9396-a593ce2f301d/
total 21436
drwx------ 2 root root 16384 May 27 00:12 lost+found
-rw-r--r-- 1 root root 21930117 May 27 00:14 SomeFile.txt使用磁盘卸载分区3。
从驱动器复制分区表。
显示分区表。
# sfdisk -d /dev/sdc > sdc.tab
# cat sdc.tab
label: dos
label-id: 0xf33657fc
device: /dev/sdc
unit: sectors
/dev/sdc3 : start= 8192, size= 62836480, type=83使用vi sdc.tab将sdc3转换为sdc1。
应用更改的分区表。
# sfdisk --no-reread -f /dev/sdc < sdc.tab
Disk /dev/sdc: 30 GiB, 32176472064 bytes, 62844672 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: 0xf33657fc
Old situation:
Device Boot Start End Sectors Size Id Type
/dev/sdc3 8192 62844671 62836480 30G 83 Linux
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0xf33657fc.
Created a new partition 1 of type 'Linux' and of size 30 GiB.
/dev/sdc2:
New situation:
Device Boot Start End Sectors Size Id Type
/dev/sdc1 8192 62844671 62836480 30G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.命令一完成,分区1就自动挂载.
查一下文件。
# ls -l /media/willem/cd4746ac-6d9f-4057-9396-a593ce2f301d/
total 21436
drwx------ 2 root root 16384 May 27 00:12 lost+found
-rw-r--r-- 1 root root 21930117 May 27 00:14 SomeFile.txt使用磁盘卸载分区1。
好了。
PS。我每次都做cat SomeFile.txt,但是我觉得没有必要包括这个输出。
发布于 2017-05-26 10:05:52
您应该调整/dev/sda3 1的大小,使其大于/dev/sda3 3。然后将sda3复制到sda1上。文件检查sda1,如果没有问题,删除sda3,相应地调整sda1大小。
https://askubuntu.com/questions/919072
复制相似问题