New IT forum
13 August 2022, 12:45:16 pm *
Welcome, %1$s. Please login or register.

: PiHub now in stock.
 
Pages: [1] 2

Author Topic: backup ubuntu SD card to pc using card reader  (Read 18574 times)

KenMG

  • Newbie
  • *
  • Posts: 12
backup ubuntu SD card to pc using card reader
« on: 03 March 2010, 04:18:59 pm »

Hi,
Is it possible to backup the ubuntu SD card to a linux PC using a card reader ?

I don't seem to be able to mount the device.

Has anyone done this ?

Thanks,
Mike

**********************************************************
[email protected]:/dev$ sudo fdisk -l

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x41ab2316

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        7295    58597056   83  Linux
/dev/sda2            7296        9726    19527007+   5  Extended
/dev/sda5            7296        9726    19526976   82  Linux swap / Solaris
[email protected]:/dev$


[169679.408279] usb-storage: device scan complete
[169679.408864] scsi 10:0:0:0: Direct-Access     Generic  USB SD Reader    1.00 PQ: 0 ANSI: 0
[169679.409487] scsi 10:0:0:1: Direct-Access     Generic  USB CF Reader    1.01 PQ: 0 ANSI: 0
[169679.410108] scsi 10:0:0:2: Direct-Access     Generic  USB SM Reader    1.02 PQ: 0 ANSI: 0
[169679.410610] scsi 10:0:0:3: Direct-Access     Generic  USB MS Reader    1.03 PQ: 0 ANSI: 0
[169710.112048] usb 1-8: reset high speed USB device using ehci_hcd and address 7
[169720.356042] usb 1-8: reset high speed USB device using ehci_hcd and address 7
[169736.600050] usb 1-8: reset high speed USB device using ehci_hcd and address 7
[169736.848022] usb 1-8: reset high speed USB device using ehci_hcd and address 7
[169747.092043] usb 1-8: reset high speed USB device using ehci_hcd and address 7
[169747.227927] sd 10:0:0:0: Device offlined - not ready after error recovery
[169747.227992] sd 10:0:0:0: rejecting I/O to offline device
[169747.228595] sd 10:0:0:0: rejecting I/O to offline device
[169747.228612] sd 10:0:0:0: rejecting I/O to offline device
[169747.228618] sd 10:0:0:0: [sdb] READ CAPACITY failed
[169747.228620] sd 10:0:0:0: [sdb] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK,SUGGEST_OK
[169747.228625] sd 10:0:0:0: [sdb] Sense not available.
[169747.228634] sd 10:0:0:0: rejecting I/O to offline device
[169747.228640] sd 10:0:0:0: [sdb] Write Protect is off
[169747.228643] sd 10:0:0:0: [sdb] Mode Sense: 00 00 00 00
[169747.228646] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[169747.233694] sd 10:0:0:0: [sdb] Attached SCSI removable disk
[169747.233818] sd 10:0:0:0: Attached scsi generic sg2 type 0
[169747.237590] sd 10:0:0:1: [sdc] Attached SCSI removable disk
[169747.237710] sd 10:0:0:1: Attached scsi generic sg3 type 0
[169747.240634] sd 10:0:0:2: [sdd] Attached SCSI removable disk
[169747.240749] sd 10:0:0:2: Attached scsi generic sg4 type 0
[169747.245609] sd 10:0:0:3: [sde] Attached SCSI removable disk
[169747.245733] sd 10:0:0:3: Attached scsi generic sg5 type 0
[171353.000123] e100: eth0: e100_watchdog: link up, 100Mbps, full-duplex
[171353.000245] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[171363.292015] eth0: no IPv6 routers present
[email protected]:/dev$

[email protected]:/dev$ sudo mount /dev/sdb /media/sdcard
mount: /dev/sdb is not a valid block device
[email protected]:/dev$
******************************************************

Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: backup ubuntu SD card to pc using card reader
« Reply #1 on: 04 March 2010, 12:19:12 am »

Code: [Select]
sudo mount /dev/sdb1 /media/sdcard-kernel-partition
sudo mount /dev/sdb2 /media/sdcard-rootfs-partition
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #2 on: 04 March 2010, 08:50:33 am »

Hi Marcus,
sdb1 and sdb2 don't exist. Only sdb and when I try to mount this I get the error not a valid block device.
Could it be the card reader I have is not supported by ubuntu ? (Alcor Micro Corp)
Is there a particular card reader I should get ?

Regards,
Mike.
Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: backup ubuntu SD card to pc using card reader
« Reply #3 on: 04 March 2010, 06:02:42 pm »

If you can't get your reader to work, remember that you have one in your plug.

  • Boot from NAND.
  • Insert and mount your SD card: sudo mount /dev/sda2 /media/sdcard-rootfs-partition
  • Insert a USB device, or network connection to remote storage
  • Copy files as required to USB or network

I have a (very) old reader that doesn't work with SDHC cards, and a newer one that gives these errors on a Sheevaplug:

Code: [Select]
Buffer I/O error on device sda, logical block 5
Buffer I/O error on device sda, logical block 6
Buffer I/O error on device sda, logical block 7
Buffer I/O error on device sda, logical block 8
Buffer I/O error on device sda, logical block 9
Buffer I/O error on device sda, logical block 10
Buffer I/O error on device sda, logical block 11
Buffer I/O error on device sda, logical block 12

but auto-mounts as /media/usb0 and /media/usb1 on an Ubuntu desktop. YMMV, but I've never really needed a reader (or writer) other than the one that is built in to the Sheevaplug.

Anyway, the one that works on my Ubuntu desktop (but fails on a Sheevaplug) is this one:

http://www.amazon.co.uk/Integral-Single-Slot-SDHC-Reader/dp/B000VY80AM

(£0.59 plus £0.99 shipping).
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #4 on: 05 March 2010, 01:59:52 pm »

HI Marcus,
Thanks for the feedback.
I have backed up the 2 partitions on the supplied SD card.
Using:
[email protected]:/media# sudo mount /dev/mmcblk0p2 /media/sdcard-rootfs-partition
[email protected]:/media# sudo mount /dev/mmcblk0p1 /media/sdcard-boot-partition

[email protected]:/media/sdcard-rootfs-partition# sudo tar -cpszf /home/nfs_files/rootfs.tar.gz *
[email protected]:/media/sdcard-rootfs-partition# cd ../sdcard-boot-partition/
[email protected]:/media/sdcard-boot-partition# sudo tar -cpszf /home/nfs_files/boot.tar.gz *

I'm trying to fdisk a new SD card and it has a different cylinder size.
Please could you outline the fdisk commands used to create the original SD card partitions.
Thanks,
Mike
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #5 on: 05 March 2010, 02:58:11 pm »

Hi Marcus,
I did a mkfs.ext2 on /dev/mmcblk0 and then repeated fdisk and the cylinder size was correct (32768).
I've now created a backup SD card.
Can I just replace the uImage in the boot partition with the 2.6.32.9 to try the latest kernel ?

Thanks ,
Mike
Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: backup ubuntu SD card to pc using card reader
« Reply #6 on: 05 March 2010, 05:43:57 pm »

Hi Marcus,
I did a mkfs.ext2 on /dev/mmcblk0 and then repeated fdisk and the cylinder size was correct (32768).
I've now created a backup SD card.
Can I just replace the uImage in the boot partition with the 2.6.32.9 to try the latest kernel ?

Thanks ,
Mike

Original partioning is partition #1 size is 4M ext2, for kernel (as uImage). Partition #2 as ext3 for rootfs:

Code: [Select]
fdisk /dev/mmcblk0
Enter:

Code: [Select]
n (new partition)
p (primary)
1 (partition number 1)
<ENTER> (First cylinder = default: cylinder #1)
+4M (Last cylinder ends at +4Megabytes)
n (new partition)
p (primary)
2 (partition number 2)
<ENTER> (First cylinder = default: next cylinder)
<ENTER> (Last cylinder = default: last cylinder)
w (write partition data to SD card and exit)

And yes, to upgrade the kernel you should replace your existing uImage with the new version, but also extract modules to /lib/modules/2.6.32.9/
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #7 on: 11 March 2010, 04:17:11 pm »

Hi Marcus,
Thanks for the info.
I've created another SD card
Partitioned as follows:

*********************************************
[email protected]:/home/nfs_files# fdisk -l

Disk /dev/mmcblk0: 4093 MB, 4093640704 bytes
4 heads, 16 sectors/track, 124928 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0xb7dc7165

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1         123        3928   83  Linux
/dev/mmcblk0p2             124      124928     3993760   83  Linux
[email protected]:/home/nfs_files# mkfs.ext2 /dev/mmcblk0p1
mke2fs 1.41.4 (27-Jan-2009)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
984 inodes, 3928 blocks
196 blocks (4.99%) reserved for the super user
First data block=1
Maximum filesystem blocks=4194304
1 block group
8192 blocks per group, 8192 fragments per group
984 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[email protected]:/home/nfs_files# mkfs.ext3 /dev/mmcblk0p2
mke2fs 1.41.4 (27-Jan-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
249984 inodes, 998440 blocks
49922 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1023410176
31 block groups
32768 blocks per group, 32768 fragments per group
8064 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736
***********************************************

I've
cp sheeva-2.6.32.9-uImage to the boot partition and renamed uImage.
tar -xvf rootfs.tar.gz the file system from the original SD card to the rootfs partition
tar -xvf sheeva-2.6.32.9-Modules.tar.gz  to the rootfs partition

When I reboot it doesn't boot to the SD card.
Do I need to make any changes to the environment variables ?
The readme talks about jffs2 file system, but usn't this just for the NAND flash ?
Do I need to load a clean file system ? (eg ubuntu-9.05.release.jffs2)

Regards,
Mike

Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: backup ubuntu SD card to pc using card reader
« Reply #8 on: 11 March 2010, 06:29:25 pm »

When I reboot it doesn't boot to the SD card.
Do I need to make any changes to the environment variables ?

What messages does U-Boot give, if it doesn't boot?

If your plug was originally purchased either as UBIFS or as multi-boot (which is the same as UBIFS, but with an SD card included), then no, you don't change the environment variables.
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #9 on: 12 March 2010, 11:53:18 am »

Hi Marcus,
This is the output I get:


** Unable to read "/uImage" from mmc 0:1 **
## Booting image at 00800000 ...
Bad Magic Number

NAND read: device 0 offset 0x100000, size 0x400000

Reading data from 0x4ff800 -- 100% complete.
 4194304 bytes read: OK
## Booting image at 00800000 ...
   Image Name:   Linux-2.6.30.2

Thanks,
Mike
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #10 on: 12 March 2010, 04:13:47 pm »

Hi Marcus,
Managed to get new uImage to boot by starting again and using
mksf.ext2 -I 128 /dev/mmcblk0p1

Thanks,
Mike
Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: backup ubuntu SD card to pc using card reader
« Reply #11 on: 12 March 2010, 05:35:29 pm »

These are the commands used by the installer (or manually, if one chooses) to prepare the partitions:

Code: [Select]
mkfs.ext2 -L shvplug-uImage /dev/mmcblk0p1
mkfs.ext3 -L shvplug-rootfs /dev/mmcblk0p2
Logged

steveh

  • Newbie
  • *
  • Posts: 1
Re: backup ubuntu SD card to pc using card reader
« Reply #12 on: 15 March 2010, 08:08:59 am »

I've had no issues so far of cloning multiboot SD cards using http://www.kingston.com/ukroot/flash/mediareader.asp and http://www.alexpage.de/usb-image-tool/download/ even on a rather contorted setup of  Virtualbox Win 7 and XP guests via Mac host.
Logged

KenMG

  • Newbie
  • *
  • Posts: 12
Re: backup ubuntu SD card to pc using card reader
« Reply #13 on: 18 March 2010, 01:46:51 pm »

Hi Marcus,
I have gunziped the .gz file,  reformated partition 2  mkfs.ext3 /dev/mmcblk0p2 then:

dd if=/home/nfs_files/ultima-4G-NewIT-v1.1-ubuntu.img of=/dev/mmcblk0p2

When I try to mount /dev/mmcblk0p2 i get:

[email protected]:/# mount /dev/mmcblk0p2 /media/sdcard-rootfs-partition/
VFS: Can't find ext4 filesystem on dev mmcblk0p2.
FAT: bogus number of reserved sectors
mount: you must specify the filesystem type
[email protected]:/#

I have also tried:

[email protected]:/home/nfs_files# zcat ultima-4G-NewIT-v1.1-ubuntu.img.gz > /dev/mmcb
lk0p2
[email protected]:/home/nfs_files# cd /media/sdcard-rootfs-partition/

I get a different error with this:

[email protected]:/media/sdcard-rootfs-partition# ls
EXT3-fs error (device mmcblk0p2): ext3_readdir: bad entry in directory #2: rec_l
en is smaller than minimal - offset=0, inode=0, rec_len=0, name_len=0
EXT3-fs error (device mmcblk0p2) in ext3_reserve_inode_write: IO failure
[email protected]:/media/sdcard-rootfs-partition#

Is there another way of getting the image onto the sd card ?

Thanks,
Mike
Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: backup ubuntu SD card to pc using card reader
« Reply #14 on: 18 March 2010, 05:38:31 pm »

The img file is an image of both partitions:

Code: [Select]
dd if=/path/to/image/file.img of=/dev/mmcblk0
Logged
Pages: [1] 2
 
 

Powered by MySQL Powered by PHP SMF 2.0.10 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!