我想错误地将一个分区添加到/dev/sda中,我用/dev/sda2启动fdisk,并将它当作磁盘对待。我该怎么恢复呢?
ghostrider@dev1:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 800G 0 disk
├─sda1 8:1 0 953M 0 part /boot
└─sda2 8:2 0 399.1G 0 part /
ghostrider@dev1:~$ sudo fdisk /dev/sda2
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
The old ext4 signature will be removed by a write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x1d9559e3.
Command (m for help): p
Disk /dev/sda2: 399.7 GiB, 428495339520 bytes, 836904960 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: 0x1d9559e3
Command (m for help): F
Unpartitioned space /dev/sda2: 399.7 GiB, 428494290944 bytes, 836902912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Start End Sectors Size
2048 836904959 836902912 399.1G
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-836904959, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-836904959, default 836904959):
Created a new partition 1 of type 'Linux' and of size 399.1 GiB.
Command (m for help): w
The partition table has been altered.
Failed to add partition 1 to system: Invalid argument
The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
ghostrider@dev1:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 800G 0 disk
├─sda1 8:1 0 953M 0 part /boot
└─sda2 8:2 0 399.1G 0 part /编辑:在服务器稍后重新启动后,服务器被错误消息困在initramfs中
Gave up waiting for root
ALERT! UUID=xx-xx-xx-xx-xx doesn't exist dropping to shell发布于 2021-02-18 18:33:03
看起来什么都没有发生,因为fdisk未能覆盖您的文件系统。当它尝试时,它显示了错误:
Failed to add partition 1 to system: Invalid argument然而,这是一个确保备份是当前和可恢复的好时机。不管怎么说,有可能出了什么问题。
请注意,在您做任何事情之前,fdisk确实尝试过警告您这个问题。它警告说:
The old ext4 signature will be removed by a write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x1d9559e3.阅读工具打印的消息是个好主意,即使你对它们非常熟悉,因为有一天可能会出现一些意想不到的事情。如果你已经注意到了这一点,你可能已经意识到有什么地方是错误的之前,任何损害可能已经发生。
https://serverfault.com/questions/1054127
复制相似问题