LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   4K sector disk, need help cloning (https://www.linuxquestions.org/questions/linux-newbie-8/4k-sector-disk-need-help-cloning-915474/)

pantronic 11-25-2011 05:50 AM

4K sector disk, need help cloning
 
Dear all,

I am a newbie with Linux but I have to clone a disk. I'm using Ubuntu 10.04.

The system is 4 years old and was using a 80gb disk with 512B sectors, and I would like to clone it before it's dead with a new disk, that has unfortunately 4K/sectors... I'm stuck there.
Do you know if there is a possibility to clone a 512b/sector disk with a 4K/sector disk?

Thank you!

_bsd 11-25-2011 06:06 AM

here is a good article on the 512->4096 sector evolution.
In particular, you want to take note that the OS provides a 512b emulation so the applications don't see the 4096
The underlying differences between the two physical disks should be hidden.

You could use plain old dd, but writing many 512b chunks would be inefficient so you should specify a block size of 4k (or multiples thereof).

I suggest you use ddrescue, which will copy/clone a disk and uses a default 65536b soft block size while copying. It has many additional features and can be more aggressive attempting to read/recover from a failing disk.

Good luck

pantronic 11-25-2011 07:42 AM

Thanks for your quick reply, I’m looking further for DDrescue.
But as I can’t even create a partition or a filesystem on the new disk because of the 4k sectors, I don’t see how it would help (using parted). I dont know how to deal with this.

pantronic 11-25-2011 08:44 AM

ok I am now cloning from the old 512B/sector disk to the new 4K/sector disk using ddrescue -n

but i still dont see how it will manage the partition table. I will come back to report when it’s finished.
thanks

_bsd 11-25-2011 09:15 AM

It (ddrescue) will copy the partition table block by block.

You'll have to fix the table afterwards.

I would take a look at gdisk rather than gnu parted, I've had better success with gdisk (since I prefer GPT partitions).
In the expert menu you can change sizes (carefully).

If this fails, and you have backup space, fsarchiver can archive entire filesystems into a file.
Then you create a new MBR or GPT, partition as you see fit and then restore from the fsarchived file.
eg
Code:

fsarchive savefs /path2storeage/backup-2011-11-25.gpt /dev/sda1 /dev/sda2
install new disk, make new partions
Code:

fsarchive restfs /path2storeage/backup-2011-11-25.gpt id=0,dest=/dev/sda1,mkfs=ext3 id=1,dest=/dev/sda2,mkfs=btrfs
Code:

fsarchive -h
shows lots of examples of its usage

pantronic 11-28-2011 02:55 AM

So i did a ddrescue of the 80gb 512b/sector to a 250gb 4k/sector disk.
Then if i check it I have :

Command (? for help): i
Using 1
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Linux/Windows data)
Partition unique GUID: BE9C9B24-3F2F-2874-8B96-348890A5EA06
First sector: 63 (at 252.0 KiB)
Last sector: 32129999 (at 122.6 GiB)
Partition size: 32129937 sectors (122.6 GiB)
Attribute flags: 0000000000000000
Partition name: Linux/Windows data

One partition of 122gb? But the source disk is 80gb...

Also when I start gdisk it says :
GPT fdisk (gdisk) version 0.5.1

WARNING! Sector size is not 512 bytes! This program is likely to misbehave!
Proceed at your own risk!

Partition table scan:
WARNING! Sector size is not 512 bytes! This program is likely to misbehave!
Proceed at your own risk!

pantronic 11-28-2011 03:02 AM

So I think I will try your second option and start backing up to a file.
The problem is still I don't know how to create a partition table on this 4K/sector disk... :(

About fsarchiver, the disk has an extended partition sda2, which has inside sda5 as the swap and sda6 ext3. Should I archiver sda1 and sda2 or sda1 and sda6 ?

Thanks a lot for your help.

_bsd 11-28-2011 05:29 AM

could you please post
Code:

fdisk -l /dev/sda
along with distro you're using
your level of comfort with a chroot style repair
Is this machine dual booted with windows?

_bsd 11-28-2011 05:46 AM

I ask because you no longer need to use extended partitions.
If you use gdisk or gnu parted you can create GPT style partions and have up to 128 primary partitions, HOWEVER to change from one style partition table to the other is medium level linux. All the partitions will get new GUID and you'll need to boot from a livecd or sysrescuecd (good to learn). You'll have to fix grub, and /etc/fstab at a minimum. I do it regularly, cloning disks, etc but you can just as easily ruin an installation if you don't have the skills. There are many online tutorials, but it's not an entry level task. Don't let that scare you, it's worth the effort.

I previously suggested ddrescue because you indicated the primary disk was failing. In that case it's more important to copy the data to a good disk, then work with the good disk to restore the OS. It depends on how many spare disks you have lying around.

Read up on fsarchiver
and if you're interested GPT partitions
general backup/restore

pantronic 11-28-2011 08:23 AM

I am using a laptop with Ubuntu 10.04LTS, no dual boot.
My goal is to clone a hard-drive 80gb that comes with a system I bought 5 years ago, but not supported anymore as the company's closed. So I have the old disk and the new one connected with USB adapters to my laptop.

Old disk :

Disque /dev/sdb: 80.0 Go, 80026361856 octets
255 têtes, 63 secteurs/piste, 9729 cylindres
Unités = cylindres de 16065 * 512 = 8225280 octets
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Identifiant de disque : 0x00000000

Périphérique Amorce Début Fin Blocs Id Système
/dev/sdb1 * 1 2000 16064968+ 83 Linux
/dev/sdb2 2001 9729 62083192+ 5 Etendue
/dev/sdb5 2001 2128 1028128+ 82 Linux swap / Solaris
/dev/sdb6 2129 9729 61055001 83 Linux

New disk :

Note: taille de secteur 4096 (et non pas 512)

Disque /dev/sdc: 250.1 Go, 250059350016 octets
255 têtes, 63 secteurs/piste, 3800 cylindres
Unités = cylindres de 16065 * 4096 = 65802240 octets
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Identifiant de disque : 0x000af53d

Périphérique Amorce Début Fin Blocs Id Système


I am just a basic user, but I can follow a tutorial... It's just this 4K sector disk that annoys me.
So I backed up the old disk with fsarchiver. Now I'm going to read your links to learn how to work with a 4K/sector disk. Usually I use the DiskTool from Ubuntu, but it doesnt work with this disk since it's 4K.

pantronic 11-28-2011 08:31 AM

I have to tell you that I don't have root access to that old system, this is also why I need to clone it before the disk is completely dead.
I already tried with Clonezilla, but it fails to restore the backupb because it fails to create a partition table on the new 4K/sector disk... I could try with SystemRescueCD also.

_bsd 11-28-2011 08:56 AM

you claim to not have root access, so, yes use sysrescuecd and fsarchiver, archive all partitions individually.

This will ensure you have your data from the old disk, partition by partition, and stored to a safe place.

I would recreate partitions using gdisk, follow a tutorial that includes the necessary chroot and editing of /etc/fstab

(feel free to email me off the thread if you need to)

pantronic 11-29-2011 03:02 AM

Thx a lot for your help ! Following the links you gave me, I anderstood that I needed to update my distribution cause my partition tools were too old to manage the 4k/sectors disk...
So it means Clonezilla is outdated as it doenst manage such disks. I am wondering if RescueDisc is outdated too.

With parted updated I am now able to create the partition table and I am confident I will be able to restore everything easily :)

Thanks a lot for your help!

_bsd 11-29-2011 05:14 AM

SysRescueCD is not outdated, it's updated regularly and a very useful linux recovery tool to have in your arsenal.


All times are GMT -5. The time now is 04:36 AM.