April 14

Linux: How to access Time Machine

Recently after switching from Mac OS X to Debian, I found I needed to restore a couple files from the Time Machine backup that I kept. The drive works just fine as an HFS+ mount, but I couldn’t figure out how to retrieve anything within. When Google didn’t yield the answer, I began to explore on my own.

It turns out Apple does a couple slick things with the file system to make incremental backups work, including hard linking to directories, which isn’t allowed in Linux. So for anyone that needs to access their Time Machine from something other than its associated Mac, here’s how you do it…

  1. Mount the drive. On linux, it should automount if you have gnome-volume-manager installed. If you don’t see it in /media, then run nautilus and check the desktop. Still don’t see it? Read man mount. And then don’t forget the -t hfsplus flag.
  2. Change directory. My mount point is /media/Time Machine/. Within that path, I find the directory Backups.backupdb. This represents the directory layout of your backup system. Inside that directory is the name of your disk. Inside that are folders labeled with dates corresponding to each incremental backup that was made. Pick the one you want, or choose the Latest symlink. For example, my path is now:
    /media/Time Machine/Backups.backupdb/Drive 1/2008-06-05-073745
  3. Find your file’s folder. Within that path is a complete representation of your filesystem. Navigate to the location of your file. If it’s not too big or nested too deep, it may be plainly visible. However, there’s a good chance that its parent directory doesn’t exist. Instead you’ll see a zero-byte file for the parent that takes its name and acts as a pointer. Run ls -l and take note of the first numbered column. Example:
    ...
    -r--r--r-- 2155704 root 5791966       0 2007-06-25 02:54 Wallpaper
    -r--r--r-- 2155725 root 5791967       0 2007-06-25 02:54 Web-Identity
    -r--r--r-- 5441953 root 5791968       0 2007-06-25 02:54 Windows
    -r--r--r-- 5511926 root 5791969       0 2007-06-25 02:54 Work

    After the permissions, you’ll see the directory number that typically refers to the number of directories within that folder. For a file, it should always be 1, but here it is not. What Apple has done is adjust the information in this file’s inode to use it as a pointer to the directory that contains the actual file. That way, multiple revisions of the same drive can coexist without duplicating data.

  4. Find the data. In my case, I want to grab something out of the Wallpaper folder. First I made a note of the directory number, 2155704, and then did cd /media/Time Machine/.HFS+ Private Directory Data — this is where the data really lives. From there, I just did cd dir_2155704, and voilà!

By: CBaker

Category: Linux | Comments Off on Linux: How to access Time Machine
March 31

Linux: How to burn an iso image to a DVD

growisofs – (the main) part of dvd+rw-tools.

growisofs -Z /dev/dvdrw=image.iso

By: Peterph

or

First you have to create ISO Using dd command like

dd if=/dev/dvd of=my_test.iso bs=2048

Then write DVD Using this command

growisofs -dvd-compat -Z /dev/dvd=my_test.iso
By: Tjas
Category: Linux | Comments Off on Linux: How to burn an iso image to a DVD
February 26

Linux: error: file '/grub/i386-pc/normal.mod' not found

What you need to do is install GRUB 2. To do this you need to boot to the live instance, mount your root partition and install.

From a live instance, find the partition on which your root partition is loaded. GParted will tell you this, or you could use

sudo fdisk -l

Go for the partition in which ubuntu is installed.

Once you have your partition you need to mount it. Assuming the root partition is on /dev/sda5, that’d be:

sudo mount /dev/sda5 /mnt

Then install GRUB 2

sudo grub-install /dev/sda --root-directory=/mnt

reboot

By: J Morrissey

Category: Linux | Comments Off on Linux: error: file '/grub/i386-pc/normal.mod' not found
February 12

Linux: Unpacking and repacking U-Boot uImage files

Background:

u-boot uImage files have a 64-byte header defined in image.h as follows:

#define IH_MAGIC    0x27051956    /* Image Magic Number     */
#define IH_NMLEN    32            /* Image Name Length      */

typedef struct image_header {
    uint32_t    ih_magic;         /* Image Header Magic Number */
    uint32_t    ih_hcrc;          /* Image Header CRC Checksum */
    uint32_t    ih_time;          /* Image Creation Timestamp  */
    uint32_t    ih_size;          /* Image Data Size           */
    uint32_t    ih_load;          /* Data     Load  Address    */
    uint32_t    ih_ep;            /* Entry Point Address       */
    uint32_t    ih_dcrc;          /* Image Data CRC Checksum   */
    uint8_t     ih_os;            /* Operating System          */
    uint8_t     ih_arch;          /* CPU architecture          */
    uint8_t     ih_type;          /* Image Type                */
    uint8_t     ih_comp;          /* Compression Type          */
    uint8_t     ih_name[IH_NMLEN];    /* Image Name            */
} image_header_t;

According to the u-boot README in the section “More About U-Boot Image Types”:

“Multi-File Images” start with a list of image sizes, each
image size (in bytes) specified by an “uint32_t” in network
byte order. This list is terminated by an “(uint32_t)0″.
Immediately after the terminating 0 follow the images, one by
one, all aligned on “uint32_t” boundaries (size rounded up to
a multiple of 4 bytes).

 

Install uboot-mkimage from ports:

$ cd /usr/ports/devel/u-boot
$ make install clean

List image header:

$ mkimage -l nova-installer-image-broadway.uImage
Image Name:   nova-installer-image-broadway-43
Created:      Wed Dec 31 16:00:00 1969
Image Type:   ARM Linux Multi-File Image (uncompressed)
Data Size:    12566392 Bytes = 12271.87 kB = 11.98 MB
Load Address: 0x00000000
Entry Point:  0x00000000
Contents:
   Image 0:  2610004 Bytes = 2548 kB = 2 MB
   Image 1:  9956376 Bytes = 9723 kB = 9 MB

This image contains two files, so it is a multi-file image.  To extract the two child image files, we must first chop off or skip over the 64-byte header + 4-byte image 0 size + 4 byte image 1 size + 4 byte null terminator = first 76 bytes.  Next we’ll extract Image 0  (2610004 bytes long in this example) and image 1 (9956376 bytes long in this example).  Note that these two files are also uImage files!

Skip first 76 bytes and extract length of first image:

$ dd if=nova-installer-image-broadway.uImage of=kernel.uImage bs=1 skip=76 count=2610004
2610004+0 records in
2610004+0 records out
2610004 bytes transferred in 46.503855 secs (56124 bytes/sec)

Now I’ll skip 76 bytes + the size of the first image to get the second image:

$ dd if=nova-installer-image-broadway.uImage of=ramdisk.uImage bs=1 skip=2610080
9956376+0 records in
9956376+0 records out
9956376 bytes transferred in 168.836628 secs (58970 bytes/sec)

Let’s look at the kernel image header:

$ mkimage -l kernel.uImage
Image Name:   Linux-2.6.29-palm-shank
Created:      Wed Dec 31 16:00:00 1969
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    2609940 Bytes = 2548.77 kB = 2.49 MB
Load Address: 0x00208000
Entry Point:  0x00208000

And the ramdisk image header:

$ mkimage -l ramdisk.uImage
Image Name:   ramdisk
Created:      Wed Dec 31 16:00:00 1969
Image Type:   ARM Linux RAMDisk Image (uncompressed)
Data Size:    9956312 Bytes = 9722.96 kB = 9.50 MB
Load Address: 0x00000000
Entry Point:  0x00000000

Now let’s pluck off the 64-byte header from the ramdisk:

$ dd if=ramdisk.uImage of=ramdisk bs=64 skip=1
155567+1 records in
155567+1 records out
9956312 bytes transferred in 2.952196 secs (3372511 bytes/sec)

And examine it:

$ file ramdisk
ramdisk: gzip compressed data, was "nova-installer-image-broadway-4", from Unix, last modified: Fri Apr 15 12:01:11 2011, max compression

Now extract it:

 zcat ramdisk > nova-installer-image-broadway-4

And examine it again:

$ file nova-installer-image-broadway-4
nova-installer-image-broadway-4: Linux rev 0.0 ext2 filesystem data

So it’s an ext2 filesystem.  Let’s mount it under FreeBSD:

$ kldload ext2fs
$ mdconfig -a -t vnode -f nova-installer-image-broadway-4
md0
$ mount -t ext2fs /dev/md0 /mnt

Let’s add a file full of random garbage just for fun:

$ dd if=/dev/random of=/mnt/garbage bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes transferred in 0.237938 secs (4406931 bytes/sec)
$ ls /mnt
bin        dev        garbage    lib        media      opt        sbin       tmp        var
boot       etc        home       md5sums.gz mnt        proc       sys        usr

Now it’s time to unmount the file and package everything back together:

$ umount /mnt
$ mdconfig -d -u 0

Don’t forget to gzip the ramdisk image…

$ gzip nova-installer-image-broadway-4

First create the ramdisk uImage:

$ mkimage -A arm -T ramdisk -C none -n ramdisk -d nova-installer-image-broadway-4.gz ramdisk.uImage
Image Name:   ramdisk
Created:      Wed Jun 20 23:34:59 2012
Image Type:   ARM Linux RAMDisk Image (uncompressed)
Data Size:    11036471 Bytes = 10777.80 kB = 10.53 MB
Load Address: 0x00000000
Entry Point:  0x00000000

Now combine the kernel image and ramdisk image into the final one:

$ mkimage -A arm -T multi -C none -n Linux-2.6.29-palm-shank -d kernel.uImage:ramdisk.uImage nova-installer-image-broadway.uImage
Image Name:   Linux-2.6.29-palm-shank
Created:      Wed Jun 20 23:40:05 2012
Image Type:   ARM Linux Multi-File Image (uncompressed)
Data Size:    13646551 Bytes = 13326.71 kB = 13.01 MB
Load Address: 0x00000000
Entry Point:  0x00000000
Contents:
   Image 0:  2610004 Bytes = 2548 kB = 2 MB
   Image 1: 11036535 Bytes = 10777 kB = 10 MB

Note how the overall image size and image 1 size are 1MB larger than the original from the beginning.

 

Now let’s test it with novacom.  Restart the phone and hold the volume-up key to enter bootie the bootloader.  now:

novacom boot mem:// < nova-installer-image-broadway.uImage

 

Wait a few seconds, then launch novaterm and verify that we booted to the new ramdisk with the 1M garbage file:

By: Rick

Category: Linux | Comments Off on Linux: Unpacking and repacking U-Boot uImage files