Back in 2012 I’ve bought myself Raspberry Pi model B. I’m not really keen on playing with electronics and all those GPIO pins could be non-existent as far as I’m concerned. The only thing I wanted was a low-power linux server to manage my network and provide some additional services. My router has been pretty much useless as it forced me to choose between static IP configuration and DHCP. With RPi I’ve got both and more.
Just about a week ago I’ve read about Raspberry Pi v2. has been released. Quad-core and 1 GB of RAM should make my GitLab installation usable at the very least. Without much thinking I’ve bought it and today I’ve decided to replace the hardware.
At the very beginning I’d been surprised – micro SD. Well – maybe someday I learn to read the specification accurately. Luckily I’ve found a spare class 10 16 GB micro SDHC and I’m back in business.
Blah, I tend to write too much. So let’s get down to the migration process itself. First log on to your (old) device and update your system:
sudo aptitude update sudo aptitude upgrade
If you normally use
apt-get for managing packages just use it instead of
aptitude the syntax is the same. The update is not strictly required, but I wanted to avoid any surprises.
Once it’s done shut your Pi down. Take the SD card out the device. For my own sake I’ve moved the “lock” switch to write-protect the card – you know – a second of distraction and one can wipe out entire card and my backup is not as fresh as it should be…
Put the card into your PC. If it gets mounted automatically, unmount. We need to identify the device name associated with the card. I’ve used
dmesg command for this.
$ dmesg | tail [288865.163824] wlp3s0: send auth to 24:ec:99:e5:c4:85 (try 1/3) [288865.165568] wlp3s0: authenticated [288865.166032] wlp3s0: associate with 24:ec:99:e5:c4:85 (try 1/3) [288865.168653] wlp3s0: RX AssocResp from 24:ec:99:e5:c4:85 (capab=0x411 status=0 aid=2) [288865.168741] wlp3s0: associated [288865.168749] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready [288869.753147] traps: notification-da trap int3 ip:7f6aa5e087b3 sp:7fff0ec10fd0 error:0 [298845.069339] mmc0: new SDHC card at address aaaa [298845.069527] mmcblk0: mmc0:aaaa SU08G 7.40 GiB (ro) [298845.079452] mmcblk0: p1 p2
It’s now clear, that my card is
mmcblk0. Let’s copy it to a local file:
$ sudo dd if=/dev/mmcblk0 of=/data/rpi/rpi-20150321.img bs=4M
If you’re not familiar with `dd`:
ifmeans “from” (Input File)
ofmeans “to” (Output File)
bsis Block Size – block reading / writing is much faster than byte-for-byte as long as the value is reasonable.
dd reads till the end of file which is exactly what we want. BTW: If you haven’t done any backups before, this is exactly how you can do it. It’s easy, it’s brutal, but it’s quite robust and effective.
You may want to grab a cup of coffee now. When you see confirmation, you’re done with the first part:
1895+0 przeczytanych recordów 1895+0 zapisanych recordów skopiowane 7948206080 bajtów (7,9 GB), 722,843 s, 11,0 MB/s
(My system is partially localized. I’m still wondering, what have I been thinking …)
Now swap the cards (you have an adapter for your micro SD, right?). Again, if something gets mounted, unmount it. I assume your target card to be empty. Remember that you’re going to wipe all the existing data from it!
Check your card device name again! And make sure you’re writing to the right device.
dd is very useful but a typo can wipe your entire hard drive. In my case nothing has changed:
$ dmesg | tail [288865.168741] wlp3s0: associated [288865.168749] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready [288869.753147] traps: notification-da trap int3 ip:7f6aa5e087b3 sp:7fff0ec10fd0 error:0 [298845.069339] mmc0: new SDHC card at address aaaa [298845.069527] mmcblk0: mmc0:aaaa SU08G 7.40 GiB (ro) [298845.079452] mmcblk0: p1 p2 [299926.642204] mmc0: card aaaa removed [300216.254405] mmc0: new SDHC card at address 0007 [300216.254693] mmcblk0: mmc0:0007 SD16G 14.4 GiB [300216.256324] mmcblk0: p1
Look closely – I’ve swapped
of in this command.
$ sudo dd of=/dev/mmcblk0 if=/data/rpi/rpi-20150321.img bs=4M 1895+0 przeczytanych recordów 1895+0 zapisanych recordów skopiowane 7948206080 bajtów (7,9 GB), 921,305 s, 8,6 MB/s
It took a little bit more time, but that’s normal. The partitions could have been detected and mounted, so make sure to unmount them before taking the card out. At this point you can start your new Raspberry Pi and enjoy the new quality ;).
If you were reading carefully enough, you might have noticed, that my old card was 8 GB and the new one is 16 GB. It would be a pity to waste this space. You can do two things – create an additional partition if you’d like or use the
raspi-config to automatically expand the root partition.
My GitLab can already show me the diffs it chocked on before, so there’s an improvement. Now I have to see if I can tweak some settings to make it generate faster. There’s also almost no latency when displaying most of the pages, so I’m pretty content with my new toy :).