使用 Clonezilla 克隆 Linux fedora

使用 Clonezilla 克隆 Linux fedora

实际上,这是我第一次使用 Clonezilla,而且我不是系统管理员。我的机器上有(Win7 & Fedora22 工作站)。

Fedora 每次运行都会向我显示分区大小消息,因此我需要克隆它来调整我的 HD 大小,并使用我的所有软件包重新安装它。为此,我使用了 Clonezilla,但事实上,当使用 Clonezilla 启动时,Clonezilla 只能看到 Windows 分区和我的分区数据,而看不到 Fedora 的 EXT4 分区。

注意:另外,如果有任何其他简单的方法可以代替 Clonezilla 来实现我的要求,那就太好了。

答案1

resize2fs您可以使用forext-x文件系统和ntfsresizefor调整分区大小ntfs

dd是一个不错的选择左边分区有 10% 的空白空间。

例如,要缩小/dev/sda1,请向左移动并展开/dev/sda2

  • lsblk:识别分区并检查它们是否已卸载。
  • fdisk /dev/sda或者根据您的分区表类型,然后使用gdisk /dev/sda字母pq: 来标识sector sizealignment和块。startend
  • ntfsresize -s (new size) /dev/sda1:缩小/dev/sda1文件系统。
  • dd if=/dev/sda2 of=/dev/sda bs=(sector size) seek=(new start):将/dev/sda2文件系统移动到左侧。
  • 使用或缩小/dev/sda1、向左移动和展开/dev/sda2分区。fdiskgdisk
  • 使用扩展/dev/sda2文件系统resize2fs

的计算公式new start/dev/sda2: (( /dev/sda1 start sector) * sector size+ new size of /dev/sda1 in bytes→ 对齐到partition table alignment) / ( sector size)

现实生活中的例子(移动和调整大小/dev/sdc1以及/dev/sdc2):

#identifying partitions and checking if they are unmounted
> lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdc      8:32   1   1.9G  0 disk 
|-sdc1   8:33   1     1G  0 part 
`-sdc2   8:34   1 910.5M  0 part

#identifying partition type, sector size, alignment, start and end blocks
> gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sdc: 3963904 sectors, 1.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D276E14A-5EB2-42FB-89DF-A742B6199BC3
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3963870
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem
   2         2099200         3963870   910.5 MiB   8300  Linux filesystem

Command (? for help): q

#shrinking /dev/sdc1 filesystem to 100M
> ntfsresize -s 100M /dev/sdc1
ntfsresize v2012.1.15AR.5 (libntfs-3g)
Failed to set locale, using default 'C'.
Device name        : /dev/sdc1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 1073738240 bytes (1074 MB)
Current device size: 1073741824 bytes (1074 MB)
New volume size    : 99996160 bytes (100 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 6 MB (0.5%)
Collecting resizing constraints ...
Needed relocations : 1412 (6 MB)
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/sdc1'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
  1)  create it at the same disk sector (use sector as the unit!)
  2)  create it with the same partition type (usually 7, HPFS/NTFS)
  3)  do not make it smaller than the new NTFS filesystem size
  4)  set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.

#calculating the new start of /dev/sdc2 in bytes (/dev/sdc1 start block)*(sector size)+(new size of /dev/sdc1 in bytes)
> echo $((2048*512+100*1024*1024))
105906176

#checking alignment (new start in sectors)%(alignment*(sector size)) 0=aligned, >0=not aligned
> echo $((206848%(2048*512)))
0

#calculating the new start of /dev/sdc2 in sectors (new start in bytes)/(sector size)
> echo $((105906176/512))
206848

#moving /dev/sdc2 filesystem to the left bs=(sector size), seek=(new start in sectors)
> dd if=/dev/sdc2 of=/dev/sdc bs=512 seek=206848
1864671+0 records in
1864671+0 records out
954711552 bytes (955 MB) copied, 80.6772 s, 11.8 MB/s

#resizing and moving partitions preserving GUIDs (new start sector of /dev/sdc2 must match)
> gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): i
Partition number (1-2): 1
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 359B474B-0EE0-46B5-A105-A57C1D60E863
First sector: 2048 (at 1024.0 KiB)
Last sector: 2099199 (at 1.0 GiB)
Partition size: 2097152 sectors (1024.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'Linux filesystem'

Command (? for help): i
Partition number (1-2): 2
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
First sector: 2099200 (at 1.0 GiB)
Last sector: 3963870 (at 1.9 GiB)
Partition size: 1864671 sectors (910.5 MiB)
Attribute flags: 0000000000000000
Partition name: 'Linux filesystem'

Command (? for help): d
Partition number (1-2): 1

Command (? for help): d
Using 2

Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-3963870, default = 2048) or {+-}size{KMGTP}: 2048
Last sector (2048-3963870, default = 3963870) or {+-}size{KMGTP}: +100M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-3963870, default = 206848) or {+-}size{KMGTP}: 206848
Last sector (206848-3963870, default = 3963870) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): x

Expert command (? for help): c
Partition number (1-2): 1
Enter the partition's new unique GUID ('R' to randomize): 359B474B-0EE0-46B5-A105-A57C1D60E863
New GUID is 359B474B-0EE0-46B5-A105-A57C1D60E863

Expert command (? for help): c
Partition number (1-2): 2
Enter the partition's new unique GUID ('R' to randomize): 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
New GUID is 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3

Expert command (? for help): p
Disk /dev/sdc: 3963904 sectors, 1.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D276E14A-5EB2-42FB-89DF-A742B6199BC3
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3963870
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          206847   100.0 MiB   8300  Linux filesystem
   2          206848         3963870   1.8 GiB     8300  Linux filesystem

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.

#expanding /dev/sdc2 filesystem
> resize2fs /dev/sdc2
resize2fs 1.42.5 (29-Jul-2012)
Resizing the filesystem on /dev/sdc2 to 469627 (4k) blocks.
The filesystem on /dev/sdc2 is now 469627 blocks long.

DOS分区表示例:

#resizing and moving partitions preserving IDs and active flags (new start sector of /dev/sdc2 must match)
> fdisk /dev/sdc

Command (m for help): p

Disk /dev/sdb: 2029 MB, 2029518848 bytes
63 heads, 62 sectors/track, 1014 cylinders, total 3963904 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
Disk identifier: 0x81dc6c28

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     2099199     1048576    7  HPFS/NTFS/exFAT
/dev/sdb2         2099200     3963903      932352   83  Linux

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Selected partition 2

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-3963903, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-3963903, default 3963903): +100M

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (206848-3963903, default 206848): 206848
Last sector, +sectors or +size{K,M,G} (206848-3963903, default 3963903): 
Using default value 3963903

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 07
Changed system type of partition 1 to 7 (HPFS/NTFS/exFAT)

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sdb: 2029 MB, 2029518848 bytes
63 heads, 62 sectors/track, 1014 cylinders, total 3963904 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
Disk identifier: 0x81dc6c28

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sdb2          206848     3963903     1878528   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

警告

确保不间断地运行dd和命令。ntfsresize

保存IDsGUIDs可以帮助您保持BCD健康Windows Bootloader。在最坏的情况下,使用WindowsRE或环境修复它相对容易WindowsPE

相关内容