1

I have a piece of equipment that has a motherboard in it which boots to a linux based operating system. I am interested in being able to clone this one hard drive so that in the case it fails i have a backup plan to keep the equipment working. So far I have been able to mount the hard disk to a different PC running linux, and was able to tar the data off the partitions. However I don't know what to make of two of the partitions- sdb2 and sdb13 which do not show up as EXT3 file systems; sdb2 is 0x05 extended, and while sdb13 is 0x83 it does not show it has any file system and I cannot mount it. And I am not sure yet how to handle GRUB if I use a new hard drive of a different size. I'm looking to find out if what I want to do is even possible... if i have enough information from the following

output from fdisk -l

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00066c45

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63      208844      104391   83  Linux
Partition 1 does not start on physical sector boundary.
/dev/sdb2          208845    31262489    15526822+   5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sdb5          208908     6650909     3221001   83  Linux
Partition 5 does not start on physical sector boundary.
/dev/sdb6         6650973     7052534      200781   83  Linux
Partition 6 does not start on physical sector boundary.
/dev/sdb7         7052598     7646939      297171   83  Linux
Partition 7 does not start on physical sector boundary.
/dev/sdb8         7647003     7855784      104391   83  Linux
Partition 8 does not start on physical sector boundary.
/dev/sdb9         7855848    15679439     3911796   83  Linux
/dev/sdb10       15679503    23503094     3911796   83  Linux
Partition 10 does not start on physical sector boundary.
/dev/sdb11       23503158    24097499      297171   83  Linux
Partition 11 does not start on physical sector boundary.
/dev/sdb12       24097563    24691904      297171   83  Linux
Partition 12 does not start on physical sector boundary.
/dev/sdb13       24691968    31262489     3285261   83  Linux

output from sfdisk -d

# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=       63, size=   208782, Id=83
/dev/sdb2 : start=   208845, size= 31053645, Id= 5
/dev/sdb3 : start=        0, size=        0, Id= 0
/dev/sdb4 : start=        0, size=        0, Id= 0
/dev/sdb5 : start=   208908, size=  6442002, Id=83
/dev/sdb6 : start=  6650973, size=   401562, Id=83
/dev/sdb7 : start=  7052598, size=   594342, Id=83
/dev/sdb8 : start=  7647003, size=   208782, Id=83
/dev/sdb9 : start=  7855848, size=  7823592, Id=83
/dev/sdb10: start= 15679503, size=  7823592, Id=83
/dev/sdb11: start= 23503158, size=   594342, Id=83
/dev/sdb12: start= 24097563, size=   594342, Id=83
/dev/sdb13: start= 24691968, size=  6570522, Id=83

I was able to mount the EXT3 file systems of sdb 1, 5, 7, 8, 9, 10, 11, 12, and save the contents of each to sdb1.tar, sdb5.tar, and so on.

I have also done dd if=/dev/sdb of=./sdb_dd bs=512 count=1 to save the MBR of the drive to a file called sdb_dd.

ron
  • 6,575
  • The DOS partitioning scheme only supported four primary partitions. sdb2 is created as an extended partition to act as a container to sdb5-sdb13 – user4556274 Dec 16 '16 at 17:54
  • 2
    Have you tried file -Ls /dev/sdb13 to see if that can identify it? I'd guess swap, but file should be able to tell. – derobert Dec 16 '16 at 18:15
  • @Christoper: clonezilla will not clone to smaller partitions, only larger ones. This poses the problem of needing another hard disk of the same size 500GB or larger. The existing drive while 500 GB in size only has 6gb of data on it I need to manage, and I want the ability to use spare hard drives i have that are between 80GB and 250GB. – ron Dec 17 '16 at 01:57

1 Answers1

-1

So, If you want to just back up the entire disk, you don't need to go through the trouble of mounting each individual partition and tar-ing up the data. As @Christopher said, you can use something like clonezilla. You can also use DD to backup to a file or do a byte-for-byte copy to a new disk. The advantage of DD is that it's a standard GNU utility and available on almost every *nix distro.

The following assumes you are booted into a live disk/other Linux OS not running on the disk to be cloned. Furthermore assumes the disk you want to backup is /dev/sdb.

Storing in a backup image/file

Backup

dd if=/dev/sdb | gzip -c /location_to_store_backup_image/myserver.img.gz

Restore

gunzip -c /location_to_store_backup_image/myserver.img.gz | dd of=/dev/sdb

Direct to other disk

Backup

dd if=/dev/sdb of=/dev/sdb

Restore

Insert the cloned disk in the box and start the system =D

Sources

http://www.linuxweblog.com/dd-image

Deff
  • 44
  • 1
    dd's option is not conf=sync, but conv=sync. It should even be conv=sync,noerror (I see no point in using sync alone in this context). Beware, along with bs=1M, the conv parameter rounds up the size of the image to 1MB. If the size of the original partition is not a multiple of 1MB, when restoring you'll end up overwriting the next partition. I would remove the conv parameter entirely and only add it when a problem occurs. – xhienne Dec 16 '16 at 23:30
  • 1
    As for the restoration phase, conv seems to me of no use at best, and dangerous at worst. What is it for? – xhienne Dec 16 '16 at 23:41
  • 1
    Don't use dd. Replace dd if=/dev/sdb conf=sync bs=1M | gzip -c by </dev/sdb gzip -c. Using dd only makes the copy slower and potentially loses data. – Gilles 'SO- stop being evil' Dec 18 '16 at 22:25
  • @xhienne, thank you for catching the /conf/conv/ typo. Additionally, I dont have a good reason for the conv argument, its what i've used in the past and hasnt burned me yet; not a good reason, but there it is. – Deff Dec 22 '16 at 17:51
  • @Gilles Thats an interesting read and seems to make perfect sense. Why post that as a comment rather than an alternative answer? – Deff Dec 22 '16 at 17:52