Monday 26 September 2016

mounting drives specifying offset


$ ls /dev/sda*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5

$ sudo fdisk -l /dev/sda
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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: 0x5c7f4b84

Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1          2048    999423    997376   487M 83 Linux
/dev/sda2       1001470 976771071 975769602 465.3G  5 Extended
/dev/sda5       1001472 976771071 975769600 465.3G 8e Linux LVM

$ sudo mount /dev/sda2 /mnt/sda2
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
The offset here is 1001470*512 bytes = 512752640 to get to the second partition:

sudo mount -o ro,loop,offset=512752640 /dev/sda /mnt/sda2/
If using an image file, use the filename instead of /dev/sda

Wednesday 14 September 2016

Yet another backup rsync script. This one works on Ubuntu, 2016 September.

For some reason, my old backup scripts aren't working. A simpler approach is to add this sort of thing to a script called by cron:

rsync -vrmxz --progress --include='*.ipynb' 
  --include='*/' --exclude='*' /home/me /mnt/J/backup/
which starts at the current directory and works through all sub-directories, grabbing each .ipynb file and copying it to /backup. The parameters: a: archive mode. Preserve attributes. v: verbose. Not needed for the silent cron version. z: compress during transfer. Not needed if creating a first copy locally but useful for network xfer. x: one filesystem: don't cross file-system boundaries. r: recursive. m: prune empty directories. Essential. progress: live feedback. Not needed for silent cron version. include: files to include exclude: files to exclude. This is required even though we used an include command. *.* is essential. Make neater using variables:

hour=`date +%H`
i="ipynb"
rsync -vrmxz --progress --include="*.$i" --include='*/' 
  --exclude='*' /home/me /mnt/J/backup/hour$hour/
Regarding ddrescue solutions, watch for squashfs: it will create a compressed backup image that can be mounted. Seems better than ddrescue piped to gzip or so.