1

I run out of memory (8GB) in one system, and I need to move the existing system to bigger memory (16GB). Details

  • /dev/disk4s1 is the input i.e. from where I want to get the data
  • /dev/disk2s1 is the sd-card where I want write

I unmount disk2s1, and run

sudo dd bs=1m if=/dev/disk4s1 of=/dev/disk2s1

but I get

dd: /dev/disk4s1: Resource busy

I unmount also /dev/disk2s1 but I get dd: /dev/disk4s1: No such file or directory. So I should not unmount the input.

Keeping both SD-cards unmounted, I run XtrmJosh's proposal sudo dd if=/dev/disk4s1 of=/dev/disk2s1 but get dd: /dev/disk4s1: No such file or directory.

System report of OSX (Sorry, my Ubuntu is upgrading slowly itself now) where I am uncertain if I dding right things. Command sudo dd if=/dev/disk4s2 of=/dev/disk2s1 is not correct also.

USB 3.0 Bus:

  Capacity: 8,02 GB (8 017 412 096 bytes)
  Removable Media:  Yes
  BSD Name: disk4
  Partition Map Type:   MBR (Master Boot Record)
  PCI Device ID:    0x9c31 
  PCI Revision ID:  0x0004 
  PCI Vendor ID:    0x8086 
  Volumes:
boot:
  Capacity: 62,9 MB (62 914 560 bytes)
  Available:    42 MB (41 951 232 bytes)
  Writable: Yes
  File System:  MS-DOS FAT16
  BSD Name: disk4s1
  Mount Point:  /Volumes/boot
  Content:  Windows_FAT_32
  Volume UUID:  B39523D8-BEFC-3910-95CD-08A0C8F472AF
disk4s2:
  Capacity: 3,96 GB (3 962 568 704 bytes)
  BSD Name: disk4s2
  Content:  Linux

Card Reader:

  ...
  Current Available (mA):   1800
  Current Required (mA):    224
  Extra Operating Current (mA): 0
  Capacity: 15,93 GB (15 931 539 456 bytes)
  Removable Media:  Yes
  Detachable Drive: Yes
  BSD Name: disk2
  Built-In: Yes
  Partition Map Type:   MBR (Master Boot Record)
  Volumes:
NO NAME:
  Capacity: 1,98 GB (1 975 546 368 bytes)
  Available:    1,97 GB (1 972 600 832 bytes)
  Writable: Yes
  File System:  MS-DOS FAT16
  BSD Name: disk2s1
  Mount Point:  /Volumes/NO NAME
  Content:  DOS_FAT_16
  Volume UUID:  2AE73D94-DEE9-3B80-A4DA-0AF2B6449863

Mass Storage Device:

  Product ID:   0x125c
  Vendor ID:    0x14cd  (MOAI ELECTRONICS CORPORATION)
  Version:  3.00
  Serial Number:    125C20100726
  Speed:    Up to 480 Mb/sec
  Manufacturer: Generic
  Location ID:  0x14200000 / 11
  Current Available (mA):   1000
  Current Required (mA):    248
  Extra Operating Current (mA): 0
  Capacity: 8,02 GB (8 017 412 096 bytes)
  Removable Media:  Yes
  Detachable Drive: Yes
  BSD Name: disk4
  Partition Map Type:   MBR (Master Boot Record)
  Volumes:
boot:
  Capacity: 62,9 MB (62 914 560 bytes)
  Available:    42 MB (41 951 232 bytes)
  Writable: Yes
  File System:  MS-DOS FAT16
  BSD Name: disk4s1
  Mount Point:  /Volumes/boot
  Content:  Windows_FAT_32
  Volume UUID:  B39523D8-BEFC-3910-95CD-08A0C8F472AF
disk4s2:
  Capacity: 3,96 GB (3 962 568 704 bytes)
  BSD Name: disk4s2
  Content:  Linux

How can you dd from smaller SD-card to Bigger?

  • 2
    You're trying to copy a specific partition, not the whole disk so I think it does need to be mounted. As per the other answer, you want to format the new SD card and copy all the files over. Alternatively, you could use dd and just run dd if=/dev/disk4 of=/dev/disk2 which would copy the entire disk. After that, open the disk in gparted and see if you can expand the partition. – XtrmJosh May 20 '16 at 12:52
  • 1
    I prefer a new clean install. And then use rsync or cp with parameters to preserve ownership & permissions to copy /home over. That is almost all your settings. If you manually edited some hardware settings, those would be in /etc. Only if a server with apache or databases may you have other system folders to copy. – oldfred May 20 '16 at 13:28
  • Good example here. But you only need the copy commands. To move /home uses rsync- Be sure to use parameters to preserve ownership & permissions https://help.ubuntu.com/community/Partitioning/Home/Moving But if a regular backup of /home you should create an excludes file and exclude a lot of temporary files. http://askubuntu.com/questions/545655/backup-your-home-directory-with-rsync-and-skip-useless-folders – oldfred May 20 '16 at 13:35
  • 1
    Forgot to mention, for my command above you should run with both disks unmounted. If it still claims one of them is busy, I'm not sure what's going on. Do you have gparted open? Are you trying to do this on a virtual machine? Nothing should be using the device if its not mounted or open in something like gparted. – XtrmJosh May 20 '16 at 13:36
  • 1
    Again, you are including s1 on the end, which suggests a subdevice (mac term, I don't entirely understand this one), if you run lsblk, do you get a tree where disk2 and disk4 are the "roots"? or do you get one where disk2s1 and disk4s1 are the roots? If the former, you should be able to run the command as I posted it above. – XtrmJosh May 20 '16 at 14:50

2 Answers2

1

You can "dd from smaller SD-card to Bigger" but you will end up with the same partitions, e.g. disk space, as on the smaller SD card. Eventually you can create a new partition on the bigger SD card ending up with two partitions.

What you should do is to format the bigger SD card with full capacity and copy over the files form the smaller SD card.

NuMessiah
  • 111
  • 1
    Which will lead to an unbootable system, if I understood the OP correctly and these are system partitions. – Bruni May 20 '16 at 12:53
  • 1
    @Masi Did you try dd if=/dev/disk4 of=/dev/disk2 as XtrmJosh wrote? Than you could try resizing the partitions. If the target system is raspbian there is a script to do that. Otherwise maybe gparted? But first you need to make the copy..... – Bruni May 20 '16 at 13:43
  • 1
    @Masi the option provided here is maybe the best option, still you would have to change the 'boot' flag on the drives accordingly and run sudo update-grub and make sure you're chrooted into the drive you want to update grub and install grub onto the MBR – Videonauth May 20 '16 at 14:34
  • @Bruni Write done now successfully with dd. Some mistakes as described in comments of spyderdyne's answer. Yes, the target system is Raspian. What is the script called for the disk enlargement? I can do it also by gparted if in live system if it does not exists there easily. – Léo Léopold Hertz 준영 May 20 '16 at 17:38
  • 1
    @Masi sudo raspi-config, then it is the first menu point. – Bruni May 23 '16 at 07:57
1

This appears to be an OS X question due to the disk names, but here is what you need to do:

diskutil unmountDisk /dev/disk4
diskutil unmountDisk /dev/disk2
sudo dd if=/dev/disk4 of=/dev/disk2 bs=1m

The last line should work on Ubuntu and probably works on OS X as well. I just did something similar a couple weeks ago on a Raspberry Pi running Ubuntu Mate to rescue a buddy's Windows HDD data to a new drive. I don't recall having to unmount on Ubuntu, but it took forever to transfer about 150GB.

You can then follow the instructions here to resize your new partition to take advantage of the extra space.

Let me know if this works for you.

spyderdyne
  • 685
  • 9
  • 23
  • My previous command assumed this was just data on a specific partition and not a bootable OS install. Just copy the entire disk and it should work. Drop the (s1) partition names. – spyderdyne May 20 '16 at 14:46
  • Your commands work. My mistakes were that 1) I confused unmount with eject, and 2) heterogenous SDs (some SDs were FAT16, extFat and with different allocation sizes). So simply do sudo dd bs=1m if=/dev/disk4 of=/dev/disk2. – Léo Léopold Hertz 준영 May 20 '16 at 17:36
  • Im glad I could help. :) – spyderdyne May 20 '16 at 18:14