I have Windows and Fedora in Dualboot on my Notebook. My 1TB HDD is not very fast, so i installed a new additional 275GB SSD and i moved Windows C:\ and Fedora Root to the SSD.
It was very tricky and i am sure that i will forget the commands i used in the future, so i will write it down.
This is the initial Partitioning of the HDD (/dev/sdb):
[root@fedora ~]# fdisk -l /dev/sdb Festplatte /dev/sdb: 931,5 GiB, 1000204886016 Bytes, 1953525168 Sektoren Einheiten: Sektoren von 1 * 512 = 512 Bytes Sektorgröße (logisch/physikalisch): 512 Bytes / 4096 Bytes E/A-Größe (minimal/optimal): 4096 Bytes / 4096 Bytes Festplattenbezeichnungstyp: gpt Festplattenbezeichner: 28542C82-BC46-4DFB-8B09-11B412039DEE Gerät Anfang Ende Sektoren Größe Typ /dev/sdb1 2048 411647 409600 200M EFI-System /dev/sdb2 411648 444415 32768 16M Microsoft reserviert /dev/sdb3 444416 265320447 264876032 126,3G Microsoft Basisdaten /dev/sdb4 418920448 419842047 921600 450M Windows-Wiederherstellungsumgebung /dev/sdb5 419842048 453396479 33554432 16G Linux Swap /dev/sdb6 453396480 455493631 2097152 1G Linux-Dateisystem /dev/sdb7 455493632 663111679 207618048 99G Linux-Dateisystem /dev/sdb8 663111680 1953525134 1290413455 615,3G Microsoft Basisdaten
You can see that sdb2, sdb3 and sdb4 are the Windows Partitions and everything after it is Linux stuff. I already shrank /dev/sdb3 to an appropriate size (in Windows with the built in Disk Management Tool).
/dev/sdb8 is some ordinary NTFS-Partition with Music, Videos, Downloads, installed Applications etc.. This should stay on the HDD.
Preparing Windows
As i said before, i already shrank the Windows C:\ Partition on the HDD to an approriate size for the SSD (126GB). That is important because i will copy every Byte of the Partition with dd, it will have the same size after migrating to the SSD.
Additionally we have to disable the Windows Recovery Environment stuff on /dev/sdb4, because that thing is very unreliable and doesn’t behave well in Dualboot.
Boot Windows, start cmd with admin rights and type:
reagentc /disable
AND we need to create a Windows 10 Recovery Media (This is important! We need it to install the EFI-Bootloader.).
Create Partitions on the SSD
I use gdisk and fdisk to create and modify partitions in Linux.
Start gdisk as root on the SSD (here /dev/sda)
gdisk /dev/sda
Start with an empty GPT Partiton Table by pressing o, and create a EFI System Partition with 260MiB:
n -> (Partition Number) 1 -> (Startsector) Enter -> (Endsector) +270M -> (Type) EF00 (EFI System Partition)
Now we need to create 3 Partitions on the SSD with exactly the same Size (same amount of Sectors with the same size) , Type, Name AND Attributes as sdb2, sdb3 and sdb4 from the HDD.
Use gdisk -l /dev/sdb and fdisk -l /dev/sdb to get the proper information. If you want to know some Details (like the full Name and Attributes), press i in gdisk and enter the Partition Number. You will have to go to Expert Mode x in gdisk to change the Attributes. When you are done, write the Partition Table with w.
The Partition Table of the SSD now looks like this:
[root@fedora ~]# fdisk -l /dev/sda Festplatte /dev/sda: 256,2 GiB, 275064201216 Bytes, 537234768 Sektoren Einheiten: Sektoren von 1 * 512 = 512 Bytes Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes Festplattenbezeichnungstyp: gpt Festplattenbezeichner: E3CAB581-554A-4657-974F-84E34627D6B4 Gerät Anfang Ende Sektoren Größe Typ /dev/sda1 2048 534527 532480 260M EFI-System /dev/sda2 534528 567295 32768 16M Microsoft reserviert /dev/sda3 567296 265443327 264876032 126,3G Microsoft Basisdaten /dev/sda4 265443328 266364927 921600 450M Windows-Wiederherstellungsumgebung [root@fedora ~]# gdisk -l /dev/sda GPT fdisk (gdisk) version 1.0.1 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Disk /dev/sda: 537234768 sectors, 256.2 GiB Logical sector size: 512 bytes Disk identifier (GUID): E3CAB581-554A-4657-974F-84E34627D6B4 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 537234734 Partitions will be aligned on 2048-sector boundaries Total free space is 270871821 sectors (129.2 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 534527 260.0 MiB EF00 EFI System Partition 2 534528 567295 16.0 MiB 0C01 Microsoft reserved ... 3 567296 265443327 126.3 GiB 0700 Basic data partition 4 265443328 266364927 450.0 MiB 2700
Format EFI System Partition and Clone Windows
We will format the EFI System Partition in FAT32:
mkfs.fat -F32 /dev/sda1
And clone the three Windows Partitions
dd if=/dev/sdb2 of=/dev/sdb2 bs=2M dd if=/dev/sdb3 of=/dev/sdb3 bs=2M dd if=/dev/sdb4 of=/dev/sdb4 bs=2M
Change GUID of Windows Partitions
Windows does access it’s Partitions by their UUID (Linux does the same on most Distributions, but in Linux we can just change /etc/fstab and reinstall GRUB — you can’t do this with Windows). If you don’t change the UUIDs, your system will either be not bootable or it will have some strange Bugs like a flickering screen.
List Partitions UUIDs
Start fdisk, on the HDD (fdisk /dev/sdb) go to expert mode (x) and print the partition table (p):
Expertenbefehl (m für Hilfe): p Festplatte /dev/sdb: 931,5 GiB, 1000204886016 Bytes, 1953525168 Sektoren Einheiten: Sektoren von 1 * 512 = 512 Bytes Sektorgröße (logisch/physikalisch): 512 Bytes / 4096 Bytes E/A-Größe (minimal/optimal): 4096 Bytes / 4096 Bytes Festplattenbezeichnungstyp: gpt Festplattenbezeichner: 28542C82-BC46-4DFB-8B09-11B412039DEE Erster LBA: 34 Letzter LBA: 1953525134 Alternative LBA: 1953525167 LBA mit Partitionseinträgen: 2 Zugeordnete Partitionseinträge: 128 Gerät Anfang Ende Sektoren Typ-UUID UUID Name Attr. /dev/sdb1 2048 411647 409600 C12A7328-F81F-11D2-BA4B-00A0C93EC93B AE710130-C001-42B2-8237-E688B102E731 EFI System Partition /dev/sdb2 411648 444415 32768 E3C9E316-0B5C-4DB8-817D-F92DF00215AE 0310D237-5287-46A3-A41A-9409C78232FC Microsoft reserved partition /dev/sdb3 444416 265320447 264876032 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 8A273F28-7483-4972-9D21-5EA1E3326EE9 Basic data partition /dev/sdb4 418920448 419842047 921600 DE94BBA4-06D1-4D40-A16A-BFD50179D6AC EAA2D666-3BB9-410F-A1BD-B7CB5F140375 RequiredPartiton /dev/sdb5 419842048 453396479 33554432 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F 731861D8-7515-4AAA-9907-51E3B3FECCE6 /dev/sdb6 453396480 455493631 2097152 0FC63DAF-8483-4772-8E79-3D69D8477DE4 7E2D59C3-C10E-427F-B9F2-A84031F9FA53 /dev/sdb7 455493632 663111679 207618048 0FC63DAF-8483-4772-8E79-3D69D8477DE4 7E869168-7C7D-427D-881D-89E18094F601 /dev/sdb8 663111680 1953525134 1290413455 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 B39A1F99-BD8D-4EAD-AB73-EBAF2101A5CF
We can’t have multiple partitions with the same UUID, so it’s best to delete them from the HDD.
You can BackUp the Partitiontable with dd if=/dev/sdb of=./path/to/backup.img bs=512 count=4 before doing that. When you fuck up, just restore it with dd if=./path/to/backup.img of=/dev/sdb bs=512 count=4 and your Windows Partitions will be back.
Copy the UUIDs of sdb2, sdb3 and sdb4 to some file and DELETE the 3 Partitions in fdisk wit d.
Now enter fdisk on the HDD, go to Expert Mode (x) and change the UUID (u) of sda2, sda3 and sda4 (SSD) to the ones you copied from the deleted sdb2, sdb3 and sdb4.
Note: This are the UUIDs (or GUIDs) of the Partitions. Every Filesystem has an UUID too, you can view them witk blkid.
The UUIDs of the three NTFS/FAT32-Filesystems on sda2, sda3 and sda4 are already the same as sdb2,sdb3 and sdb4, because dd copied the whole partition, including the UUID, Bootsector, Extended Attributes, etc.
If you want to change NTFS or FAT32 UUIDs, you need to do it with an hexeditor like hexedit /dev/sdb3. They are at the beginning of the partition.
Boot to Win10 recovery and install EFI-Bootloader
Boot the Windows 10 recovery media and open the command prompt in the Advanced screen.
Check if C:\ is your Systempartition from the SSD (cd /d C: and dir — if there is some Windows and Application folder, it should be correct).
Execute diskpart and enter sel disk 0 and list partition.
C:\Windows\system32>diskpart Microsoft DiskPart-Version 10.0.14393.0 Copyright (C) 1999-2013 Microsoft Corporation. Auf Computer: ACERNETBOOK DISKPART> sel disk 0 Datenträger 0 ist jetzt der gewählte Datenträger. DISKPART> list volume Volume ### Bst Bezeichnung DS Typ Größe Status Info ---------- --- ----------- ----- ---------- ------- --------- -------- Volume 1 C NTFS Partition 126 GB Fehlerfre Startpar Volume 2 FAT32 Partition 260 MB Fehlerfre System Volume 3 NTFS Partition 450 MB Fehlerfre Versteck Volume 4 Data NTFS Partition 615 GB Fehlerfre DISKPART>
Volume 2 is our EFI System Partition (FAT32 and 260MiB), we will assign it a Drive Letter and exit diskpart
DISKPART> sel vol 2 Volume 2 ist jetzt das gewählte Volume. DISKPART> assign letter=v: Der Laufwerkbuchstabe oder der Bereitstellungspunkt wurde zugewiesen. DISKPART> exit Datenträgerpartitionierung wird beendet... C:\Windows\system32>
And install the Bootloader to the EFI Parition
bcdboot C:\Windows /s v: /f ALL
Reboot and Windows should start from the SSD.
Done 🙂