ProDave Posted January 28, 2020 Author Share Posted January 28, 2020 So I now have my Zorin PC working well and all configured as I like it, but as yet not much data on it. I thought this would be a perfect time to take a backup in a fashion that if the machine crashed I could restore to this point, rather than installing an off the shelf zorin install and then configuring it all. So I thought dd if=/dev/sda of=zorin.img would create an image file that I could restore to a clean disk. the disk is a 120GB SSD with about 15GB in use. It soon became clear as the image file just grew and grew that it was trying to image the whole 120GB disk, not just the used bit, so I had to abort that. How else can I take a copy of just the used disk, that I can restore to a blank disk and everything will work? Link to comment Share on other sites More sharing options...
bgmill Posted January 28, 2020 Share Posted January 28, 2020 dd if=/dev/sda of=zorin.img bs=512 conv=sparse Link to comment Share on other sites More sharing options...
Onoff Posted January 28, 2020 Share Posted January 28, 2020 Partclone? Link to comment Share on other sites More sharing options...
Ed Davies Posted January 28, 2020 Share Posted January 28, 2020 39 minutes ago, bgmill said: conv=sparse I tried that on a 1GB disk image I have for a VM on my SSD and it came out exactly the same number of bytes which didn't surprise me given what the man page says about conv=sparse. How about just compressing the output? dd if=/dev/sda | gzip -c - > zorin.img.gz The -c switch to gzip tells it to write its output to stdout. The lone “-” parameter means to use stdin as the input file. dd just copies its input byte for byte. When given a block device like /dev/sda it'll do as it's told and just copy the blocks not taking a moment's notice of the file system involved. If you've got a fairly fresh disk (or one you've zeroed before formatting it with the file system) then the empty blocks which haven't been used will be all zero and should compress well. If the disk has had a long and hard life then the unused blocks will still have fragments of old files, directories, etc, in them so won't compress so much. I used dd/gzip on the image file mentioned above: $ dd if=max.raw | gzip -c - > max.img.gz which gave a compression of ~7:1, -rw-rw-r-- 1 edavies edavies 138077740 Jan 28 20:03 max.img.gz -rw-r--r-- 1 edavies edavies 1073741824 Sep 25 2018 max.raw Restore with something like: gunzip -c zorin.img.gz | dd of=/dev/sdb or whatever. The alternative would be some utility which understands the file system and only copies the directories, files, etc. But it would also have to understand the partitioning and copy the partition table with the flags to make the right partition bootable and what have you. Such a utility wouldn't be entirely mad but I don't know of one. But then, I don't know what Partclone is either. Link to comment Share on other sites More sharing options...
Onoff Posted January 28, 2020 Share Posted January 28, 2020 2 minutes ago, Ed Davies said: But then, I don't know what Partclone is either. https://partclone.org/ 1 Link to comment Share on other sites More sharing options...
ProDave Posted January 28, 2020 Author Share Posted January 28, 2020 Okay my problem was a "senior moment" I was trying to write the output file to the same disk. Now when I try the same, but sending the output file to the network drive I get "permission denied" Yet I can read and write to the network drive. Link to comment Share on other sites More sharing options...
Onoff Posted January 28, 2020 Share Posted January 28, 2020 Hold that thought ref Partclone. Try Clonezilla (that includes Partclone). Link to comment Share on other sites More sharing options...
Ed Davies Posted January 28, 2020 Share Posted January 28, 2020 (edited) 17 minutes ago, ProDave said: Now when I try the same, but sending the output file to the network drive I get "permission denied" Yet I can read and write to the network drive. Because you're running dd under sudo so running as root which might not have permission to access that particular network drive? If it's that then something like: sudo dd if=/dev/sda | dd of=<whatever>/zorin.img would be my first thought. Exactly that would still be copying 120 GB, though. Edited January 28, 2020 by Ed Davies Link to comment Share on other sites More sharing options...
bgmill Posted January 28, 2020 Share Posted January 28, 2020 14 minutes ago, Ed Davies said: I tried that on a 1GB disk image I have for a VM on my SSD and it came out exactly the same number of bytes which didn't surprise me given what the man page says about conv=sparse. It will all depend on the block size and whether you have many empty blocks to seek, I'm guessing you probably had very few. Here's the results from a ~100GB partition with ~80GB free on my machine with and without conv=sparse: bgm@wintermute ~ % du -sh *.dd 12G sparse.dd 98G test.dd Link to comment Share on other sites More sharing options...
ProDave Posted January 28, 2020 Author Share Posted January 28, 2020 10 minutes ago, Ed Davies said: Because you're running dd under sudo so running as root which might not have permission to access that particular network drive? If it's that then something like: sudo dd if=/dev/sda | dd of=<whatever>/zorin.img would be my first thought. That "worked" in so far as I did not get the permission error, but it was sooooooo sloooooow after about 5 minutes it had written only a few 10's of MB and would take forever. I will try again another time to a USB drive plugged into the laptop rather than a network drive. I thought SUDO had permission to read and write everything? Link to comment Share on other sites More sharing options...
Ed Davies Posted January 28, 2020 Share Posted January 28, 2020 14 minutes ago, bgmill said: It will all depend on the block size and whether you have many empty blocks to seek You're right - the copied file was a tiny bit smaller according to du though ls showed them the same size. I didn't realise it was actually creating a sparse file on the destination rather than just doing a sparse copy. 5 minutes ago, ProDave said: I thought SUDO had permission to read and write everything? Root does on its own system but permissions on the network drive will be different depending on how it's set up and authenticated. Link to comment Share on other sites More sharing options...
ProDave Posted January 28, 2020 Author Share Posted January 28, 2020 10 minutes ago, Ed Davies said: Root does on its own system but permissions on the network drive will be different depending on how it's set up and authenticated. The disk that's now on the network was a new disk, set up partitioned and formatted on the W10 pc, then plugged into the network. Normal users on the Zoron pc can read and write to it without problem, so I can't understand why sudo can't. Link to comment Share on other sites More sharing options...
ProDave Posted February 4, 2020 Author Share Posted February 4, 2020 Sometimes I despair at the thought process of programmers. If I let the battery on the laptop get too low, up pops a box, telling me I must either choose to shut down or suspend the computer. All very logical. Except they forgot the third option. Plug the bloody charger in. Even if you do that, there is no way to dismiss that pop up box from your screen, other than by shutting down, or suspending the computer. Link to comment Share on other sites More sharing options...
Ed Davies Posted February 4, 2020 Share Posted February 4, 2020 A genuine error message I have seen: “No keyboard connected, press F1 to continue”. Link to comment Share on other sites More sharing options...
Onoff Posted February 5, 2020 Share Posted February 5, 2020 Have a look at Slimbook Battery 3, gives "advanced" power management options. https://slimbook.es/tutoriales/aplicaciones-slimbook/100-slimbook-battery-3-app-optimizar-bateria-portatil Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now