Fau*_*ult 14 windows linux clone partitioning
所以我有一个 120 GB 的 Intel SSD,一个分区用于 Windows,另一个用于 Ubuntu。Ubuntu 是我的主要操作系统,Windows 用于游戏。但现在我想安装 Mac OS X,我希望它在 SSD 上,所以我想将 Windows 移动到另一个驱动器(旧的 160GB 外部驱动器,我从它的外壳中取出并已用作测试驱动器。无论如何,我将我的游戏保存在另一个外部设备上,因此除了启动时间外,性能不应该受到影响)。
解决这个问题的最佳方法是什么?有什么好的克隆分区的工具吗?我问这个是因为谷歌在克隆你实际使用/安装了 Ubuntu 的驱动器方面得到了很多结果,而不是告诉我如何将一个完全不相关的分区克隆到另一个不相关的位置。
哦,新的 Windows 分区会让我在没有任何事先的克隆后调整的情况下运行它吗?任何与此相关的其他信息将不胜感激。
(我这样做是因为我需要在 XCode 上使用我的爪子,而我的 MacBook Pro 正在慢慢消亡)。
您将需要使用dd克隆 2 个分区- 一个是引导加载程序/引导管理器所在的位置(需要以链式加载操作系统)[系统保留,通常为 100M],另一个是实际的 W7 安装。
使用cfdisk检查分区表- 它会给你一个直观的表示。然后删除目标驱动器上的所有分区 - cfdisk是您的朋友。
克隆的语法可以在 wiki 上找到。您还需要一个合适的MBR(它可能已经存在于您的测试驱动器中)。
您可能还需要为[System Reserved] 分区分配一个可引导标志(这应该是第一个克隆的) - cfdisk可以实现这一点。
如果失败 - 只需从 W7 安装光盘启动并按照此处的 Vista指南进行操作。
更新:
忘记提及整个过程中可能不那么明显的一个重要部分。您要么必须从原始驱动器中克隆分区表并删除除 2 个与 Windows 相关的分区之外的所有内容,要么使用cfdisk / parted以相同的大小重新创建它们。
下面是一些示例(假设sda是您的源驱动器,而sdb是目标驱动器):
dd if=/dev/sda bs=1 skip=446 count=66 of=/dev/sdb seek=446(这将有效地将您当前的 DOS 分区表连同 MBR 签名复制到输出驱动器)
dd if=/dev/sda bs=1 skip=440 count=72 of=/dev/sdb seek=440(这也会复制磁盘ID,如果丢失有时会导致启动失败——但是,这样的磁盘不会能够在 Windows 环境中协同工作,直到更改 ID)
parted /dev/sda usp(这是您可以检查源驱动器上当前分区表和扇区大小的方法,以便稍后使用cfdisk或parted自身复制到目标驱动器上)
看一下
IIRC,Trinity Rescue Kit包含必要的软件以及许多其他软件(ssh、partimage、fdisk、fdisk、cfdisk、parted、gparted、testdisk、ntfsfix;ntfs-3g 安装、rsync 等)。
/*
* fixntfs: change some attributes of an NTFS bootsector
*
* brought to you by Phoenix
* url: www.grhack.gr/phoenix
* mail: phoenix@grhack.gr
* irc: phoenix -> #grhack -> undernet
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
FILE *fd;
FILE *idfd;
struct stat fst;
unsigned char cab[32];
unsigned short log_heads;
unsigned short ntfs_heads;
unsigned short force_heads;
unsigned short ntfs_cab;
unsigned long long sectors;
unsigned long long new_sectors;
log_heads = 0;
ntfs_heads = 0;
force_heads = 0;
ntfs_cab = 0;
if(argc < 2)
{
fprintf(stderr, "Usage:\n\t%s <device> <total_sectors> <force_heads>\n", argv[0]);
exit(0);
}
fprintf(stderr, "Stating file %s... ", argv[1]);
stat(argv[1], &fst);
if(!S_ISBLK(fst.st_mode))
{
fprintf(stderr, "not a block device\n");
exit(-1);
}
fprintf(stderr, "a block device\n");
fprintf(stderr, "Opening device %s rw... ", argv[1]);
fd = fopen(argv[1], "r+");
if(!fd)
{
perror("open device");
exit(-1);
}
fprintf(stderr, "ok\n");
fprintf(stderr, "Checking partition... ");
fseek(fd, 3, SEEK_SET);
if(fread(cab, 1, 4, fd) != 4)
{
perror("read system_id");
exit(-1);
}
cab[5] = 0;
if(strncmp(cab, "NTFS", 4))
{
fprintf(stderr, "%s\n", cab);
exit(-1);
}
fprintf(stderr, "%s\n", cab);
fprintf(stderr, "Reading NTFS bootsector heads... ");
fseek(fd, 0x1a, SEEK_SET);
ntfs_heads = 0;
fread(&ntfs_heads, 1, 2, fd);
fprintf(stderr, "%u\n", ntfs_heads);
fprintf(stderr, "Reading NTFS bootsector sectors... ");
fseek(fd, 0x18, SEEK_SET);
ntfs_cab = 0;
fread(&ntfs_cab, 1, 2, fd);
fprintf(stderr, "%u\n", ntfs_cab);
fprintf(stderr, "Reading NTFS bootsector sectors_per_cluster... ");
fseek(fd, 0x0d, SEEK_SET);
ntfs_cab = 0;
fread(&ntfs_cab, 1, 1, fd);
fprintf(stderr, "%u\n", ntfs_cab);
fprintf(stderr, "Reading NTFS bootsector sectors_size... ");
fseek(fd, 0x0b, SEEK_SET);
ntfs_cab = 0;
fread(&ntfs_cab, 1, 2, fd);
fprintf(stderr, "%u\n", ntfs_cab);
fprintf(stderr, "Reading NTFS bootsector boot_loader_routine_jump... ");
fseek(fd, 0, SEEK_SET);
bzero(cab, sizeof(cab));
fread(cab, 1, 3, fd);
fprintf(stderr, "0x%x 0x%x 0x%x\n", cab[0], cab[1], cab[2]);
fprintf(stderr, "Reading NTFS bootsector total_sectors... ");
fseek(fd, 0x28, SEEK_SET);
sectors = 0;
fread(§ors, 1, 8, fd);
fprintf(stderr, "%Lu\n", sectors);
fprintf(stderr, "Reading device logical heads... ");
sprintf(cab, "/proc/ide/hd%c/geometry", *(strrchr(argv[1],'/') + 3));
idfd = fopen(cab, "r");
if(!idfd)
{
perror(cab);
exit(-1);
}
fscanf(idfd, "%*s %*s\n");
fscanf(idfd, "%*s %s\n", cab);
*(strrchr(cab, '/')) = 0;
log_heads = (unsigned short) atoi(strchr(cab, '/') + 1);
fprintf(stderr, "%u\n", log_heads);
if(argc == 4)
{
force_heads=atoi(argv[3]);
fprintf(stderr, "Forcing heads to %u\n", force_heads);
log_heads=force_heads;
}
if(fclose(fd) == EOF)
{
perror("close device");
exit(-1);
}
if(log_heads != ntfs_heads)
{
fprintf(stderr, "Heads are different... Logical=%u NTFS=%u\n\n"
"Update NTFS bootsector? (y/n) ",
log_heads, ntfs_heads);
if(getc(stdin) == 'y')
{
fd = fopen(argv[1], "r+");
if(!fd)
{
perror("open device");
exit(-1);
}
ntfs_heads = log_heads;
fseek(fd, 0x1a, SEEK_SET);
fwrite(&ntfs_heads, 1, 2, fd);
fprintf(stderr, "\nBootsector updated... Verifying... ");
fclose(fd);
fd = fopen(argv[1], "r");
if(!fd)
{
perror("open device");
exit(-1);
}
fseek(fd, 0x1a, SEEK_SET);
ntfs_heads = 0;
fread(&ntfs_heads, 1, 2, fd);
if(ntfs_heads == log_heads)
{
fprintf(stderr, "ok\n\n");
}
else
{
fprintf(stderr, "error [%u]\n", ntfs_heads);
exit(-1);
}
fclose(fd);
}
else
{
fprintf(stderr, "\nHeads update cancelled...\n");
}
getc(stdin);
}
if(argc >= 3 && atoll(argv[2]))
{
fprintf(stderr, "Update NTFS bootsector total_sectors from %Lu to %Lu? (y/n) ",
sectors, atoll(argv[2]));
if(getc(stdin) == 'y')
{
fd = fopen(argv[1], "r+");
if(!fd)
{
perror("open device");
exit(-1);
}
new_sectors = atoll(argv[2]);
fseek(fd, 0x28, SEEK_SET);
fwrite(&new_sectors, 1, 8, fd);
fprintf(stderr, "\nBootsector updated... Verifying... ");
fclose(fd);
fd = fopen(argv[1], "r");
if(!fd)
{
perror("open device");
exit(-1);
}
fseek(fd, 0x28, SEEK_SET);
sectors = 0;
fread(§ors, 1, 8, fd);
if(sectors == new_sectors)
{
fprintf(stderr, "ok\n\n");
}
else
{
fprintf(stderr, "error [%Lu]\n", sectors);
exit(-1);
}
fclose(fd);
}
else
{
fprintf(stderr, "\nTotal_sectors update cancelled...\n");
}
getc(stdin);
}
return(1);
}
Run Code Online (Sandbox Code Playgroud)