2

Is am trying to make a copy of a file structure (& an image) from a drive that I have identified as

/dev/sda 

(Contains /dev/sda2 and /dev/sda5)

The drive identifying itself as /dev/sdc1 which is an external drive with 1.8TB, has 600+ Gigs of space left. When trying to manipulate it in the GUI all I got was an error saying that the space couldn't be allocated. The drive being copied and imaged is ~64GB.

The source partitions & drive list as not mounted, the target drive is mounted. The device my Ubuntu is on is /dev/sdb1 (the sd card) and is mounted.

dd if=/dev/sda of=/dev/sdc1 conv,noerror,sync 

I know from what has been said in a previous question would copy blah1 on to blah2 but one concern I have is /dev/sdc1 the target has 1.4T of files on it and I don't want to risk that data being overwritten, I need an accessible format, meaning I can open the image and read the content and extract if needed, which is likely to be a daily occurrence.

I saw a site that gave an example

dd if=/dev/sdXY | zip --compression-method bzip2 image-file.zip - 

which is zip, what I need. I don't know how to express the target /path/to/backup.img.gz to put the image in to a folder on /dev/sdc1. Would I be correct in saying that

dd if=/dev/sda conv=sync,noerror | zip --compression-method bzip2 /dev/sdc1 /folder-name/image-file.zip

is that the way to do it?

Also, can an iso be made and mounted? I am looking for the least risky route, the partition 2 in the extended partition /dev/sda2 of /dev/sda has data I need.

Using a terminal, how do I overcome these issues, what's right or wrong with my attempts?

EDIT

I get an error

cat /dev/sda | zip --compression-method bzip2 /media/mark/Seagate Expansion Drive/restore_point_image/restore/kingston_ssd_drive.img.zip
zip warning: name not matched: Expansion
zip warning: name not matched: Drive/restore_point_image/restore/kingston_ssd_drive.img.zip

zip error: Nothing to do! (/media/mark/Seagate.zip)

and trying gzip results in the same error, so I tried to refer to the drive partition by-id with

cat /dev/sda | zip --compression-method bzip /wwn-0x5000c500528232f8-part1/restore_point_image/restore/kingston_ssd_drive.img.zip

and get an error

zip error: Nothing to do! (/wwn-0x5000c500528232f8-part1/restore_point.img.zip)

The 64GB drive was unmounted, the external drive mounter, everything seemed set, but now this!

So I tried to change the drive label and that resulted in a warning that it couldn't be done, I was and still am logged in as root.

Any suggestions?

Zanna
  • 72,312

2 Answers2

2

The error was overcome with the suggestion to "quote" the path

so:

dd if=/dev/sda | gzip - c > "/media/mark/Seagate Expansion Drive/ssd.img.gz"

is currently building an archive (finally).

1

Making a copy of a drive (or whatever) is easy from terminal, less so from GUI. You can use cat or dd interchangeably for simple cases, I'll use cat here for brevity. You need to open a terminal as root (or use sudo -i)

cat /dev/sda will stream your drive contents 'as is' to a pipe. > will direct that data stream to a second process or file; so if you specify a filename after this, the data will go there; so cat /dev/sda > mydrive.img will make a copy of the entire drive, boot, partition tables, everything.

You can remount a partition image as mkdir example ; mount mydrive.img example -o loop but this won't work for a whole drive; if we had used `/dev/sda1``above, it would. This works for .iso files.

There appears to be a confusion in your question between drives/partitions, eg /dev/sdc1, and mount places in your filesystem such as /home/mark/ - you don't want to be writing to an unmounted drive at all, you need /dev/sdc1 mounted somewhere (perhaps /media/mark/something?), so you can see the files within it, and create your image there.

Insertion of a compression in the pipe (above) is simple; so my 'final answer' to your question above would be

cat /dev/sda2 | gzip >/mount/mark/somedrive/sda2.img.gz

You can gunzip this & mount with loop at your leisure - you haven't overwritten anything, just created a new file, and can access your data.