Errors Linux Software

Mounting a whole disk with partitions

I reinstalled one of my RPis (moving from 32 to 64 bit).

Before doing the full reinstall, I took a dump (dd) of my disk.

Usually, I create one per partition, but this was the Christmas season, and I was half occupied with feasting and half occupied with entertaining Ila. So, mistakes were made.

I ran dd if=/dev/sdb of=backup.img — but this means I can’t mount the disk directly, as it’s not a partition:

# mount backup.img /tmp/disk
mount: /tmp/disk: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.

I should’ve dd’d /dev/sdb2 instead of the entire disk.

All right, so let’s figure out what can be done… First, let’s look at the content of the image:

# fdisk -l backup.img
Disk backup.img: 111.8 GiB, 120040980480 bytes, 234455040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8297a463

Device          Boot  Start      End  Sectors  Size Id Type
backup.img1 *      8192   532479   524288  256M  c W95 FAT32 (LBA)
backup.img2      532480 34078199 33545720   16G 83 Linux

So, we can probably mount starting from sector 532480.

We can see that the sector size is 512 (which, I think, is the default for most). So, if we multiply 512 * 532480 we get 272629760.

Now we can mount the disk using the following command:

mount -o loop,offset=272629760 backup.img /tmp/disk

And that should do it.

The 2nd partition (the one with data) is now mounted and accessible under /tmp/disk.

If you need the first partition, the same can be done by running 512 * 8192 = 4194304; the following command mounts the boot partition:

mount -o loop,offset=4194304 backup.img /tmp/disk.
Apple Errors Linux Networking Software

Unable to complete backup. An error occurred while creating the backup folder.

5 or so days ago, this error suddenly popped up:

Unable to complete backup. An error occurred while creating the backup folder.

I have a Raspberry Pi, acting as TimeMachine (using afp/Bonjour/Netatalk).

There are several things I tried to solve this, including messing in the sparebundle from Linux (chowning) and deleting my TM .plist. This probably messed up my backup a bit.

But what seemed to ‘solve’ it for me was:

  1. Start a backup manually (it will fail after a minute or two with the above mentioned error)
  2. Open finder, and go to the now mounted disk
  3. In my case, there was a <date>.inProgress file

    Screen Shot 2013-05-22 at 15.32.19

  4. If TimeMachine mounted the share for you, you will have write access (see notes below)
  5. Delete the inProgress file
  6. Empty your trash
  7. It should be gone:

    Screen Shot 2013-05-22 at 15.43.13

  8. Unmount everything
  9. Try backing up again

In my case it changed to this error, which happens to me every so often due to corrupt backups (loss of network (because the drive is on VPN, and when I connect to my VPN Mac starts backing up, eventhough I actually don’t really need/want that, it just happens to find the LAN), sleeping at the wrong moment, and Apple just generally not supporting DIY-TimeMachine). So this does mean I have to start from scratch anyhow… 🙁

Screen Shot 2013-05-22 at 15.58.35

Notes: I’ve tried to manually mount the afp or smb share first, and open  the .sparebundle myself via finder.

Like this:

Screen Shot 2013-05-22 at 15.45.04

Screen Shot 2013-05-22 at 15.43.21

However, both via Finder as via terminal (including sudo) gave permission errors (partly reading, mostly writing) such as:

Screen Shot 2013-05-22 at 15.32.38

Apple Hardware Linux Networking Software

Home made TimeMachine


Used my Raspberry Pi, with an USB disk as TimeMachine. Another disk as NAS/storage. It’s just quite slow… Not sure whether it’s my WiFi or RPi that can’t keep up.

But for now, it’s working.

Apple Linux Software

Rsync backups

My own simple rsync backup ‘script’.

You’ll need a rsync server, something to backup, and ssh-agent running to ease the process (or, fill in your password each time).

Add the following lines (using a terminal text editor) to a text file (“.rsync” for example, hidden files under Unix-like systems), and chmod +x $file.

rsync --archive -uv --exclude-from=/home/you/.rsync_exclude \
--rsh="ssh -p 222" --delete --stats --progress /Users/you/Documents/ \

This will upload any files in /Users/you/Documents to /home/you/remote-backup-directory.

It will use ssh on port 222 to transfer the files.

Just execute ./.rsync (if that’s the name of your file) to run it.

If you make any changes (locally), and run this, the changes will be applied on the remote server (e.g. file changes, renames, deletes, …) — this will delete files on the remote server if you’ve deleted them locally!

The file .rsync_exclude is optional, it includes all files or directories that should NOT be uploaded

This is what I have in my .rsync_exclude:

Nazgul:~ yeri$ cat .rsync_exclude

Simple as hell, and yet so handy!