如何将系统移动到一个新的,更小的驱动器?


0

我有一个320G硬盘(有很多可用空间),但计划将我的系统移动到更小的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执行此操作,但因为目标驱动器较小而失败

Answers:


0

我一直都在用 的GParted 现场CD / USB 为了这种任务。

启动后,首先 收缩 现有的LVM卷到所需的大小 (即目标磁盘上我想要的大小)。打开一个终端并做(你可能需要sudo,我记不起来了!):

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

可能你需要缩小它 home 分区,真的。不要忘记调整物理卷的大小:

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

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

作为额外的奖励, GParted 从旧磁盘保留分区的相同UUID。


但问题是LVM,我无法缩小LVM物理卷
George

@George是的,抱歉,我错过了 lvm 部分。它实际上应该通过cli可行。我会更新我的答案。
Mr Shunz
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.