Score:0

Is there a proper syntax for copying and creating an image from command line?

bq flag

I have a failing HDD that I want to fully backup and replace withing the next few days. I am running OMV6 with my Plex Server attached to it. I watched a video on YouTube how to copy the content of mt HDD. I also was reading on how to compress the content of my drive and save it as an image, and then decompress it again when I am ready to restore it.

I did modify this to represent my current drives, The command I saw to use on YouTube is as follows:

sudo dd if=/dev/sdk of=/dev/sdf1 bs=1M status=progress.

My question is when reading if I'm to understand this correctly, to compress and make an image the command would be, take note I'm not writing to a SD card but rather an HDD:

sudo dd bs=1M if=/dev/sdk | gzip -c > /dev/sdn-copy.img.gz

And to decompress it:

gunzip -c dev/sdn-copy.img.gz | dd of=/dev/sdk bs=1M
FedKad avatar
cn flag
The first `/` in `gzip -c > /dev...` in your second command is not good. You can or should save the output of the `gzip` command to a file under your _home_ directory.
FedKad avatar
cn flag
You should also consider using `ddrescue` instead of `dd`.
Bruce-Wayne avatar
bq flag
@ FedKad Thanks, but the problem with saving anything else on the drive, is that it is failing, and i will be replacing it within the next few days once the new one arrives. In the mean while i probably will have the system shutdown to prevent any further damage to the drive. It's a WD spindle drive being replaced with a Samsun SSD.
Bruce-Wayne avatar
bq flag
So should it be : gunzip -c /dev/sdn-copy.img.gz | dd of=/dev/sdk bs=1M. But you are saying i can also saying this is also a viable method of getting the same results: gunzip -c /dev/sdn-copy.img.gz | ddrescue of=/dev/sdk bs=1M
FedKad avatar
cn flag
Why are you saving your gzipped file into a root-owned system directory (`/dev`)? Save it somewhere in your home directory or to an external disk.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.