How can I move a single partition to another empty drive?
up vote
2
down vote
favorite
I've got a partition P1 (which contains my Linux OS) on a drive A.
I've just gotten a completely new drive B (that is larger than partition P1 AND the entire drive A).
I'd like to copy across the partition from drive A to drive B, and possible resize it later on.
Can this be done with dd
? I could easily create a new parition table on drive B, and just cp
the files across - but this seems like it might be slightly slower due to the filesystem overhead.
Output of `parted --list`:
It would be the partition 4 that I want to copy to another drive.
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sdb: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1049kB 1031kB BIOS boot partition bios_grub
2 1049kB 1074MB 1073MB fat32 EFI System boot, esp
3 1075MB 183GB 181GB ext4 Linux filesystem
4 183GB 250GB 67.5GB ext4 Basic data partition
Please ignore any reference to the boot drive / functionality (which I'll worry about later on) - keeps this question concise.
partition dd move-partition
add a comment |
up vote
2
down vote
favorite
I've got a partition P1 (which contains my Linux OS) on a drive A.
I've just gotten a completely new drive B (that is larger than partition P1 AND the entire drive A).
I'd like to copy across the partition from drive A to drive B, and possible resize it later on.
Can this be done with dd
? I could easily create a new parition table on drive B, and just cp
the files across - but this seems like it might be slightly slower due to the filesystem overhead.
Output of `parted --list`:
It would be the partition 4 that I want to copy to another drive.
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sdb: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1049kB 1031kB BIOS boot partition bios_grub
2 1049kB 1074MB 1073MB fat32 EFI System boot, esp
3 1075MB 183GB 181GB ext4 Linux filesystem
4 183GB 250GB 67.5GB ext4 Basic data partition
Please ignore any reference to the boot drive / functionality (which I'll worry about later on) - keeps this question concise.
partition dd move-partition
Favour returned! Question upvoted! ;-)
– Fabby
Nov 21 at 21:45
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I've got a partition P1 (which contains my Linux OS) on a drive A.
I've just gotten a completely new drive B (that is larger than partition P1 AND the entire drive A).
I'd like to copy across the partition from drive A to drive B, and possible resize it later on.
Can this be done with dd
? I could easily create a new parition table on drive B, and just cp
the files across - but this seems like it might be slightly slower due to the filesystem overhead.
Output of `parted --list`:
It would be the partition 4 that I want to copy to another drive.
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sdb: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1049kB 1031kB BIOS boot partition bios_grub
2 1049kB 1074MB 1073MB fat32 EFI System boot, esp
3 1075MB 183GB 181GB ext4 Linux filesystem
4 183GB 250GB 67.5GB ext4 Basic data partition
Please ignore any reference to the boot drive / functionality (which I'll worry about later on) - keeps this question concise.
partition dd move-partition
I've got a partition P1 (which contains my Linux OS) on a drive A.
I've just gotten a completely new drive B (that is larger than partition P1 AND the entire drive A).
I'd like to copy across the partition from drive A to drive B, and possible resize it later on.
Can this be done with dd
? I could easily create a new parition table on drive B, and just cp
the files across - but this seems like it might be slightly slower due to the filesystem overhead.
Output of `parted --list`:
It would be the partition 4 that I want to copy to another drive.
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sdb: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1049kB 1031kB BIOS boot partition bios_grub
2 1049kB 1074MB 1073MB fat32 EFI System boot, esp
3 1075MB 183GB 181GB ext4 Linux filesystem
4 183GB 250GB 67.5GB ext4 Basic data partition
Please ignore any reference to the boot drive / functionality (which I'll worry about later on) - keeps this question concise.
partition dd move-partition
partition dd move-partition
edited Nov 21 at 21:17
asked Nov 21 at 19:46
Chris Stryczynski
469317
469317
Favour returned! Question upvoted! ;-)
– Fabby
Nov 21 at 21:45
add a comment |
Favour returned! Question upvoted! ;-)
– Fabby
Nov 21 at 21:45
Favour returned! Question upvoted! ;-)
– Fabby
Nov 21 at 21:45
Favour returned! Question upvoted! ;-)
– Fabby
Nov 21 at 21:45
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Yes ,that's what dd
is for. Assuming:
sxb
is the drive to copy from
sxc
is the drive to copy to
sxb4
is the fourth partition on the second drive that you want to copy from
sxc1
is the partition you've created to be of equal size tosxb4
do :
parted /dev/sxc
GNU Parted 3.2
Using /dev/sxc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
Warning: The existing disk label on /dev/sxc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0.0 67.5GB
(parted) quit
dd if=/dev/sxb4 of=/dev/sxc1 bs=16M
As that will duplicate the UUID of the partition, in order to change the UUID of the new partition (make sure the partition is not mounted) run the following:
e2fsck -f /dev/sxc1
tune2fs /dev/sxc1 -U random
if sxb
is an old drive and you expect it to have read errors, use ddrescue
instead.
Note: as dd
is known as d
isk d
estroyer, and creating a partition table is dangerous, not putting the exact command in the above as some random idiot on the Internet might see this question and copy-paste the codez without understanding what it does...
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
1
Yes, correct. And if you edit your question and provide the output ofparted --list
and leave another comment, I'll add that bit too. 0:-)
– Fabby
Nov 21 at 21:11
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
1
Urgh. Sorry: need it in bytes to be exact...sudo parted /dev/sdb unit B p
@ChrisStryczynski
– Fabby
Nov 21 at 21:41
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Yes ,that's what dd
is for. Assuming:
sxb
is the drive to copy from
sxc
is the drive to copy to
sxb4
is the fourth partition on the second drive that you want to copy from
sxc1
is the partition you've created to be of equal size tosxb4
do :
parted /dev/sxc
GNU Parted 3.2
Using /dev/sxc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
Warning: The existing disk label on /dev/sxc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0.0 67.5GB
(parted) quit
dd if=/dev/sxb4 of=/dev/sxc1 bs=16M
As that will duplicate the UUID of the partition, in order to change the UUID of the new partition (make sure the partition is not mounted) run the following:
e2fsck -f /dev/sxc1
tune2fs /dev/sxc1 -U random
if sxb
is an old drive and you expect it to have read errors, use ddrescue
instead.
Note: as dd
is known as d
isk d
estroyer, and creating a partition table is dangerous, not putting the exact command in the above as some random idiot on the Internet might see this question and copy-paste the codez without understanding what it does...
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
1
Yes, correct. And if you edit your question and provide the output ofparted --list
and leave another comment, I'll add that bit too. 0:-)
– Fabby
Nov 21 at 21:11
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
1
Urgh. Sorry: need it in bytes to be exact...sudo parted /dev/sdb unit B p
@ChrisStryczynski
– Fabby
Nov 21 at 21:41
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
|
show 2 more comments
up vote
2
down vote
accepted
Yes ,that's what dd
is for. Assuming:
sxb
is the drive to copy from
sxc
is the drive to copy to
sxb4
is the fourth partition on the second drive that you want to copy from
sxc1
is the partition you've created to be of equal size tosxb4
do :
parted /dev/sxc
GNU Parted 3.2
Using /dev/sxc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
Warning: The existing disk label on /dev/sxc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0.0 67.5GB
(parted) quit
dd if=/dev/sxb4 of=/dev/sxc1 bs=16M
As that will duplicate the UUID of the partition, in order to change the UUID of the new partition (make sure the partition is not mounted) run the following:
e2fsck -f /dev/sxc1
tune2fs /dev/sxc1 -U random
if sxb
is an old drive and you expect it to have read errors, use ddrescue
instead.
Note: as dd
is known as d
isk d
estroyer, and creating a partition table is dangerous, not putting the exact command in the above as some random idiot on the Internet might see this question and copy-paste the codez without understanding what it does...
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
1
Yes, correct. And if you edit your question and provide the output ofparted --list
and leave another comment, I'll add that bit too. 0:-)
– Fabby
Nov 21 at 21:11
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
1
Urgh. Sorry: need it in bytes to be exact...sudo parted /dev/sdb unit B p
@ChrisStryczynski
– Fabby
Nov 21 at 21:41
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
|
show 2 more comments
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Yes ,that's what dd
is for. Assuming:
sxb
is the drive to copy from
sxc
is the drive to copy to
sxb4
is the fourth partition on the second drive that you want to copy from
sxc1
is the partition you've created to be of equal size tosxb4
do :
parted /dev/sxc
GNU Parted 3.2
Using /dev/sxc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
Warning: The existing disk label on /dev/sxc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0.0 67.5GB
(parted) quit
dd if=/dev/sxb4 of=/dev/sxc1 bs=16M
As that will duplicate the UUID of the partition, in order to change the UUID of the new partition (make sure the partition is not mounted) run the following:
e2fsck -f /dev/sxc1
tune2fs /dev/sxc1 -U random
if sxb
is an old drive and you expect it to have read errors, use ddrescue
instead.
Note: as dd
is known as d
isk d
estroyer, and creating a partition table is dangerous, not putting the exact command in the above as some random idiot on the Internet might see this question and copy-paste the codez without understanding what it does...
Yes ,that's what dd
is for. Assuming:
sxb
is the drive to copy from
sxc
is the drive to copy to
sxb4
is the fourth partition on the second drive that you want to copy from
sxc1
is the partition you've created to be of equal size tosxb4
do :
parted /dev/sxc
GNU Parted 3.2
Using /dev/sxc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
Warning: The existing disk label on /dev/sxc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0.0 67.5GB
(parted) quit
dd if=/dev/sxb4 of=/dev/sxc1 bs=16M
As that will duplicate the UUID of the partition, in order to change the UUID of the new partition (make sure the partition is not mounted) run the following:
e2fsck -f /dev/sxc1
tune2fs /dev/sxc1 -U random
if sxb
is an old drive and you expect it to have read errors, use ddrescue
instead.
Note: as dd
is known as d
isk d
estroyer, and creating a partition table is dangerous, not putting the exact command in the above as some random idiot on the Internet might see this question and copy-paste the codez without understanding what it does...
edited Nov 21 at 23:10
answered Nov 21 at 20:53
Fabby
3,11411127
3,11411127
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
1
Yes, correct. And if you edit your question and provide the output ofparted --list
and leave another comment, I'll add that bit too. 0:-)
– Fabby
Nov 21 at 21:11
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
1
Urgh. Sorry: need it in bytes to be exact...sudo parted /dev/sdb unit B p
@ChrisStryczynski
– Fabby
Nov 21 at 21:41
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
|
show 2 more comments
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
1
Yes, correct. And if you edit your question and provide the output ofparted --list
and leave another comment, I'll add that bit too. 0:-)
– Fabby
Nov 21 at 21:11
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
1
Urgh. Sorry: need it in bytes to be exact...sudo parted /dev/sdb unit B p
@ChrisStryczynski
– Fabby
Nov 21 at 21:41
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
Good to hear, I guess the only issue is I'm not sure how to create a partition with the exact same size? Is the 'size' the 'difference' between the start/end blocks of the partition?
– Chris Stryczynski
Nov 21 at 21:03
1
1
Yes, correct. And if you edit your question and provide the output of
parted --list
and leave another comment, I'll add that bit too. 0:-)– Fabby
Nov 21 at 21:11
Yes, correct. And if you edit your question and provide the output of
parted --list
and leave another comment, I'll add that bit too. 0:-)– Fabby
Nov 21 at 21:11
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
Many thanks, I've updated it now.
– Chris Stryczynski
Nov 21 at 21:18
1
1
Urgh. Sorry: need it in bytes to be exact...
sudo parted /dev/sdb unit B p
@ChrisStryczynski– Fabby
Nov 21 at 21:41
Urgh. Sorry: need it in bytes to be exact...
sudo parted /dev/sdb unit B p
@ChrisStryczynski– Fabby
Nov 21 at 21:41
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
I've just done it! Thanks for pointing me in the right direction though.
– Chris Stryczynski
Nov 21 at 21:44
|
show 2 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483288%2fhow-can-i-move-a-single-partition-to-another-empty-drive%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Favour returned! Question upvoted! ;-)
– Fabby
Nov 21 at 21:45