如何将系统移动到新的、更小的驱动器?

如何将系统移动到新的、更小的驱动器?

我有一个 320G 的 HDD(有大量可用空间),但计划将我的系统移至较小的 275G SSD。我该如何做才能不丢失数据?fdisk -l 输出

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 3ADBB6B9-D132-427F-B2C5-9D3666CDB354

Device       Start       End   Sectors   Size Type
/dev/sda1     2048    411647    409600   200M EFI System
/dev/sda2   411648   2508799   2097152     1G Linux filesystem
/dev/sda3  2508800 625141759 622632960 296.9G Linux LVM




Disk /dev/mapper/fedora-root: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora-swap: 7.8 GiB, 8317304832 bytes, 16244736 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora-home: 189.1 GiB, 203092393984 bytes, 396664832 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

pvs 输出

  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda3  fedora lvm2 a--  296.89g 50.00g

VGS 输出

  VG     #PV #LV #SN Attr   VSize   VFree 
  fedora   1   3   0 wz--n- 296.89g 50.00g

lvs 输出

  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home fedora -wi-ao---- 189.14g                                                    
  root fedora -wi-ao----  50.00g                                                    
  swap fedora -wi-ao----  <7.75g      

parted -l 输出

Disk /dev/sda: 320GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  211MB   210MB   fat16        EFI System Partition  boot, esp
 2      211MB   1285MB  1074MB  ext4
 3      1285MB  320GB   319GB                                      lvm

尝试使用 clonezilla 执行此操作,但由于目标驱动器较小而失败

答案1

我一直用分区 直播 CD/USB对于这类任务

启动后,首先收缩将现有的 LVM 卷设置为所需的大小(即我想要的目标磁盘大小)。打开终端并执行(您可能需要 sudo,我记不清了!):

lvresize --verbose --resizefs -L NEWSIZE /dev/mapper/fedora-home

也许你真的只需要缩小home分区。别忘了也调整物理卷的大小:

pvresize --setphysicalvolumesize {some-space} /dev/sda3

然后将相关分区从旧磁盘简单复制/粘贴到新磁盘。

作为额外的好处,GParted保留旧磁盘分区的相同 UUID。

相关内容