I have taken a backup from my Linux disk using dd command and I've uploaded it to a website.

Now there is a kernel panic in my VPS and I open the rescue mode and I want to download and restore that backup image.

My question: Since my kernel is not booting and The I can't mount the disk that I want to restore, where I can download the disk image to restore it? (The disk image is about 5 GB)


  • You verified that the disk image is good right? You'll probably need "about 5 GB" of space somewhere to download the image, unless the website will let you stream the download to dd... will it? – Xen2050 Oct 11 '18 at 21:50
  • Actually, I'm using gdrive to get the image from Google drive. I don't know if it can stream it or not – seco Oct 12 '18 at 8:19

A raw dd disk image is good if you need every sector of the disk in the same place, empty sectors and "erased" sectors and all, but it takes up a lot of space. You could compress the image with gz, xz, etc but then can't mount or browse it as easily.

Linux doesn't usually care what sector it's files are in, so a files-only backup would work too (and just restore the boot loader afterwards) and probably take up a LOT less space, just a .tar.gz/.tar.xz or squashfs is nice and mountable too.

But for now you're stuck with a 5GB disk image, the easiest thing to do is just download it the same way you uploaded it - I'm assuming you used temporary storage on some other drive to save the image in the first place. But booting's now a problem so just:

  1. Boot a live linux disk
  2. Download the 5GB image to the same other temporary storage (another drive, USB drive, even another networked computer, etc) you used when creating it.
  3. Use dd again to restore the drive image.

Since it's on a google drive, one of these answers might let you stream / pipe the download directly to dd, but it looks like techniques change over time and might not work anymore. This answer says it should work recently, it's:

June 2018 The easiest way that works for me

  1. pip install gdown
  2. gdown https://drive.google.com/uc?id=file_id

The file_id should look something like 0Bz8a_Dbh9QhbNU3SGlFaDg

You can get it by right clicking on the file and then Get shareable link. Tested on open access files. I'm not sure whether it works for directory.

Or this one slightly less recently, the heart of the answer appears to use curl and a cookie (see the full answer for more details):

curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
  • First of all, thanks for the detailed answer! I'm using a VPS. so I can't boot with a USB. I agree to back up the files only OK, but shall I backup all root (/) directory then mount and overwrite the entire root? – seco Oct 13 '18 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.