Guide technique complet pour migrer d'un disque dur vers SSD. Clonage sécurisé, optimisation des performances et amélioration de l'expérience utilisateur.
Client : Cabinet d'avocats (Marseille)
Problème : PC lents, temps de démarrage de 3-4 minutes
Objectif : Migration vers SSD sans perte de données
Avant la migration, j'ai analysé les postes de travail :
Pour cette migration, j'ai sélectionné :
Cet article contient des techniques avancées de clonage, des scripts d'optimisation et des procédures de migration sécurisées.
# Script PowerShell pour vérifier la compatibilité
# check-compatibility.ps1
Write-Host "=== Vérification de la compatibilité SSD ===" -ForegroundColor Green
# Vérifier le type de disque actuel
$disk = Get-Disk | Where-Object {$_.Number -eq 0}
Write-Host "Type de disque actuel: $($disk.BusType)" -ForegroundColor Yellow
# Vérifier l'espace utilisé
$partition = Get-Partition | Where-Object {$_.DiskNumber -eq 0 -and $_.Type -eq "Basic"}
$usedSpace = (Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DeviceID -eq "C:"}).Size - (Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DeviceID -eq "C:"}).FreeSpace
$usedSpaceGB = [math]::Round($usedSpace / 1GB, 2)
Write-Host "Espace utilisé: $usedSpaceGB GB" -ForegroundColor Yellow
# Vérifier la version de Windows
$osVersion = (Get-WmiObject -Class Win32_OperatingSystem).Version
Write-Host "Version Windows: $osVersion" -ForegroundColor Yellow
# Vérifier le mode de démarrage (UEFI/Legacy)
$firmware = Get-WmiObject -Class Win32_ComputerSystem | Select-Object -ExpandProperty BootupState
Write-Host "Mode de démarrage: $firmware" -ForegroundColor Yellow
# Vérifier les slots M.2 disponibles
$m2Slots = Get-WmiObject -Class Win32_PnPEntity | Where-Object {$_.Name -like "*M.2*"}
if ($m2Slots) {
Write-Host "Slots M.2 disponibles: $($m2Slots.Count)" -ForegroundColor Green
} else {
Write-Host "Aucun slot M.2 détecté" -ForegroundColor Red
}
Write-Host "=== Vérification terminée ===" -ForegroundColor Green
# Script de sauvegarde complète
# backup-before-migration.ps1
$backupPath = "D:\Backup_Pre_Migration_$(Get-Date -Format 'yyyyMMdd_HHmm')"
$excludeFolders = @("$env:TEMP", "$env:TMP", "C:\Windows\Temp", "C:\$Recycle.Bin")
Write-Host "=== Sauvegarde préventive ===" -ForegroundColor Green
Write-Host "Dossier de destination: $backupPath" -ForegroundColor Yellow
# Créer le dossier de sauvegarde
New-Item -ItemType Directory -Path $backupPath -Force
# Sauvegarder les profils utilisateurs
$users = Get-ChildItem "C:\Users" -Directory | Where-Object {$_.Name -notin @("Public", "Default", "All Users")}
foreach ($user in $users) {
Write-Host "Sauvegarde du profil: $($user.Name)" -ForegroundColor Yellow
$userBackupPath = Join-Path $backupPath "Users\$($user.Name)"
New-Item -ItemType Directory -Path $userBackupPath -Force
# Exclure les dossiers temporaires
$excludePattern = $excludeFolders -join "|"
robocopy "C:\Users\$($user.Name)" $userBackupPath /E /XD $excludeFolders /R:3 /W:10
}
# Sauvegarder les données système importantes
$systemBackupPath = Join-Path $backupPath "System"
New-Item -ItemType Directory -Path $systemBackupPath -Force
# Sauvegarder la base de registre
reg export "HKEY_CURRENT_USER" "$systemBackupPath\HKCU.reg" /y
reg export "HKEY_LOCAL_MACHINE\SOFTWARE" "$systemBackupPath\HKLM_Software.reg" /y
# Sauvegarder les drivers
pnputil /export-driver * "$systemBackupPath\Drivers"
Write-Host "=== Sauvegarde terminée ===" -ForegroundColor Green
# Script de clonage automatisé
# clone-disk.sh
#!/bin/bash
# Configuration
SOURCE_DISK="/dev/sda"
TARGET_DISK="/dev/sdb"
LOG_FILE="/var/log/clone-$(date +%Y%m%d_%H%M%S).log"
echo "=== Début du clonage ===" | tee -a $LOG_FILE
echo "Source: $SOURCE_DISK" | tee -a $LOG_FILE
echo "Cible: $TARGET_DISK" | tee -a $LOG_FILE
# Vérifier que les disques sont connectés
if [ ! -b "$SOURCE_DISK" ]; then
echo "ERREUR: Disque source $SOURCE_DISK non trouvé" | tee -a $LOG_FILE
exit 1
fi
if [ ! -b "$TARGET_DISK" ]; then
echo "ERREUR: Disque cible $TARGET_DISK non trouvé" | tee -a $LOG_FILE
exit 1
fi
# Afficher les informations des disques
echo "=== Informations des disques ===" | tee -a $LOG_FILE
fdisk -l $SOURCE_DISK | tee -a $LOG_FILE
fdisk -l $TARGET_DISK | tee -a $LOG_FILE
# Cloner le disque secteur par secteur
echo "=== Début du clonage secteur par secteur ===" | tee -a $LOG_FILE
dd if=$SOURCE_DISK of=$TARGET_DISK bs=4M status=progress 2>&1 | tee -a $LOG_FILE
# Vérifier l'intégrité
echo "=== Vérification de l'intégrité ===" | tee -a $LOG_FILE
md5sum $SOURCE_DISK > /tmp/source_md5
dd if=$TARGET_DISK bs=4M count=$(($(stat -c%s $SOURCE_DISK) / 4194304)) | md5sum > /tmp/target_md5
if diff /tmp/source_md5 /tmp/target_md5; then
echo "SUCCÈS: Clonage vérifié avec succès" | tee -a $LOG_FILE
else
echo "ERREUR: Échec de la vérification du clonage" | tee -a $LOG_FILE
exit 1
fi
# Redimensionner les partitions si nécessaire
echo "=== Redimensionnement des partitions ===" | tee -a $LOG_FILE
parted $TARGET_DISK resizepart 1 100%
# Étendre le système de fichiers
echo "=== Extension du système de fichiers ===" | tee -a $LOG_FILE
resize2fs ${TARGET_DISK}1
echo "=== Clonage terminé avec succès ===" | tee -a $LOG_FILE
# Script de clonage avec ddrescue pour disques défaillants
# clone-with-ddrescue.sh
#!/bin/bash
SOURCE_DISK="/dev/sda"
TARGET_DISK="/dev/sdb"
MAP_FILE="/tmp/clone.map"
LOG_FILE="/var/log/ddrescue-$(date +%Y%m%d_%H%M%S).log"
echo "=== Clonage avec ddrescue ===" | tee -a $LOG_FILE
# Première passe - copie des secteurs faciles
ddrescue -f -n $SOURCE_DISK $TARGET_DISK $MAP_FILE 2>&1 | tee -a $LOG_FILE
# Deuxième passe - tentative de récupération des secteurs difficiles
ddrescue -f -r3 $SOURCE_DISK $TARGET_DISK $MAP_FILE 2>&1 | tee -a $LOG_FILE
# Vérification finale
ddrescue -f -t $SOURCE_DISK $TARGET_DISK $MAP_FILE 2>&1 | tee -a $LOG_FILE
echo "=== Clonage avec ddrescue terminé ===" | tee -a $LOG_FILE
# Script d'optimisation Windows pour SSD
# optimize-ssd.ps1
Write-Host "=== Optimisation Windows pour SSD ===" -ForegroundColor Green
# Désactiver la défragmentation automatique
Write-Host "Désactivation de la défragmentation automatique..." -ForegroundColor Yellow
Disable-ScheduledTask -TaskName "ScheduledDefrag" -ErrorAction SilentlyContinue
# Activer TRIM
Write-Host "Activation de TRIM..." -ForegroundColor Yellow
fsutil behavior set DisableDeleteNotify 0
# Désactiver l'indexation sur les SSD
Write-Host "Désactivation de l'indexation..." -ForegroundColor Yellow
$ssdDrives = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3 -and $_.MediaType -eq 12}
foreach ($drive in $ssdDrives) {
$indexService = Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq "WSearch"}
if ($indexService) {
$indexService.ChangeStartMode("Disabled")
$indexService.StopService()
}
}
# Optimiser les paramètres de cache
Write-Host "Optimisation des paramètres de cache..." -ForegroundColor Yellow
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "LargeSystemCache" -Value 0
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" -Name "EnablePrefetcher" -Value 0
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" -Name "EnableSuperfetch" -Value 0
# Désactiver l'hibernation (optionnel)
Write-Host "Désactivation de l'hibernation..." -ForegroundColor Yellow
powercfg -h off
# Optimiser les paramètres d'alimentation
Write-Host "Optimisation des paramètres d'alimentation..." -ForegroundColor Yellow
powercfg -setacvalueindex SCHEME_CURRENT 0012ee47-9041-4b5d-9b77-535fba8b1442 6738e2c4-e8a5-4a42-b16a-e040e769756e 1
powercfg -setactive SCHEME_CURRENT
# Nettoyer les fichiers temporaires
Write-Host "Nettoyage des fichiers temporaires..." -ForegroundColor Yellow
Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem -Path "C:\Windows\Temp" -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
# Optimiser le registre
Write-Host "Optimisation du registre..." -ForegroundColor Yellow
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_ShowMyComputer" /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_ShowMyGames" /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_ShowMyMusic" /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_ShowMyPics" /t REG_DWORD /d 0 /f
Write-Host "=== Optimisation terminée ===" -ForegroundColor Green
# Script de test de performance
# benchmark-ssd.ps1
Write-Host "=== Test de performance SSD ===" -ForegroundColor Green
# Test de vitesse de lecture/écriture
$testFile = "C:\temp\speedtest.tmp"
$testSize = 1GB
$iterations = 3
Write-Host "Test de vitesse d'écriture..." -ForegroundColor Yellow
$writeTimes = @()
for ($i = 1; $i -le $iterations; $i++) {
$startTime = Get-Date
$null = New-Object byte[] $testSize | Out-File -FilePath $testFile -Encoding Byte
$endTime = Get-Date
$writeTime = ($endTime - $startTime).TotalSeconds
$writeTimes += $writeTime
Write-Host "Test $i : $([math]::Round($writeTime, 2)) secondes" -ForegroundColor Cyan
}
$avgWriteTime = ($writeTimes | Measure-Object -Average).Average
$writeSpeed = [math]::Round(($testSize / 1MB) / $avgWriteTime, 2)
Write-Host "Vitesse d'écriture moyenne: $writeSpeed MB/s" -ForegroundColor Green
Write-Host "Test de vitesse de lecture..." -ForegroundColor Yellow
$readTimes = @()
for ($i = 1; $i -le $iterations; $i++) {
$startTime = Get-Date
$null = Get-Content -Path $testFile -Encoding Byte
$endTime = Get-Date
$readTime = ($endTime - $startTime).TotalSeconds
$readTimes += $readTime
Write-Host "Test $i : $([math]::Round($readTime, 2)) secondes" -ForegroundColor Cyan
}
$avgReadTime = ($readTimes | Measure-Object -Average).Average
$readSpeed = [math]::Round(($testSize / 1MB) / $avgReadTime, 2)
Write-Host "Vitesse de lecture moyenne: $readSpeed MB/s" -ForegroundColor Green
# Test de temps de démarrage
Write-Host "Test de temps de démarrage..." -ForegroundColor Yellow
$bootTime = (Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime
$currentTime = Get-DmiObject -Class Win32_OperatingSystem).LocalDateTime
$uptime = $currentTime - $bootTime
Write-Host "Temps de démarrage: $([math]::Round($uptime.TotalMinutes, 2)) minutes" -ForegroundColor Cyan
# Nettoyage
Remove-Item $testFile -Force -ErrorAction SilentlyContinue
Write-Host "=== Tests terminés ===" -ForegroundColor Green
# Script de maintenance SSD
# ssd-maintenance.ps1
Write-Host "=== Maintenance SSD ===" -ForegroundColor Green
# Vérifier l'état de santé du SSD
$ssdHealth = Get-PhysicalDisk | Where-Object {$_.MediaType -eq "SSD"}
foreach ($disk in $ssdHealth) {
Write-Host "SSD: $($disk.FriendlyName)" -ForegroundColor Yellow
Write-Host "État de santé: $($disk.HealthStatus)" -ForegroundColor Cyan
Write-Host "Utilisation: $($disk.Usage)" -ForegroundColor Cyan
}
# Vérifier l'espace libre
$drives = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}
foreach ($drive in $drives) {
$freeSpacePercent = [math]::Round(($drive.FreeSpace / $drive.Size) * 100, 2)
Write-Host "Disque $($drive.DeviceID) : $freeSpacePercent% libre" -ForegroundColor Cyan
if ($freeSpacePercent -lt 10) {
Write-Host "ATTENTION: Espace libre faible sur $($drive.DeviceID)" -ForegroundColor Red
}
}
# Optimiser le SSD
Write-Host "Optimisation du SSD..." -ForegroundColor Yellow
Optimize-Volume -DriveLetter C -ReTrim -Verbose
# Nettoyer les fichiers temporaires
Write-Host "Nettoyage des fichiers temporaires..." -ForegroundColor Yellow
Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "=== Maintenance terminée ===" -ForegroundColor Green
Chaque configuration a ses spécificités. Contactez-moi pour une migration SSD sur-mesure et sécurisée.
Discuter de votre projet