Homepage Wiki Forum Buy

Change sd card

From GNUBLIN

Contents


This article describes how to replace the 2GB SD card with a larger one. It's only a host computer is required with Linux.

preparation

install Software

First install gparted on the host computer with the following command:

sudo apt-get install gparted

This program is a graphical partition editor with which we prepare the new SD card.

prepare the new SD card

First, the new SD card is plugged into the PC / laptop and start gparted with the following command (Make sure that the SD card is not mounted.)

sudo gparted

Then you select your SD card in the upper right device selection

Gparted 001.jpg

Now klick on Device then Create Partition Table acknowledge the query, if you are sure that it is the correct device and the data can be deleted on the device.

Now it looks like this

Gparted 002.jpg

After that, klick on unallocated then new in the upper menue.

Now the following window appears:

Gparted 003.jpg

Here, the following must be set:

  1. 16 MiB leave space before the first partition (the first option)
  2. In "Create as" primary partition must be selected
  3. In file system ext3 should be chosen

Now klick on add and the first partition should be set.

After that, again klick on unallocated then new in the upper menue.

Now the following window appears:

Gparted 004.jpg

Important here is that the file system is on unformatted, the rest should be set correctly from home made​​. Clicking on Add also that partition is set.

Finally, we must in the menu bar or click on the green tick, so that our settings are stored on the SD card. The query whether we are sure we will confirm with yes or ok.

When everything is ready, the SD card should look like this. (The size of the first partition of course, vary depending on the size of the memory card)

Gparted 005.jpg

Now we just need to make the bootloader partition bootable. This can be easily done by a right click on the boot loader partition and then click Manage Flags. This will open the following window in which to boot a tick must be set.

Gparted 007.jpg

That's it with the preparation of the new SD card. Continuing with the backup of the old SD card.

Backup the old SD card

backup Bootloader

Next we put the old SD card to the host computer and save the boot loader. For this you need to find which partition is the boot loader. This can either make with gparted (beginner) or using (advanced) of dmesg.

We start gparted again and select the SD card from the top right, then we can read off the partition of the boot loader.

Gparted 006.jpg

Here we see that the bootloader partition is on / dev/sdd2. (The bootloader partition is always the one with "unknown" file system)

Now in a terminal we can save the bootloader partition:

sudo dd if=/dev/sdd2 of=/tmp/bootpartition.img

The parameter if = ... states that the boot loader partition and the parameter of = ... where the image is stored. The paths must also be adjusted, as for example the file bootpartition.img in this example in the / tmp directory will be created and will be deleted upon reboot


backup Root-Filesystem

Next we put the old SD card to the host computer and save the boot loader. For this you need to find out which partition is the boot loader. This can be made with gparted.

Is the SD card mounted we can proceed to the next step and save the filesystem using tar.

cd /media/f24f3248-0455-4557-b1bc-377a297242a9

In this command, of course, the directory needs to be adjusted. You can find the correct directory, when you type the beginning of the instruction "cd /media/" and then press TAB two times. Then you get the directories which are in "/media/".

With the following command the rootfs is packed to the file rootfs.tar.gz into the /tmp directory.

sudo tar -zvc -f /tmp/rootfs.tar.gz *

finnish the new SD card

copy Bootloader

Now we put back the new SD card and make sure, that it is not mounted. Then the bootloader can be copied with the following instruction

sudo dd if=/tmp/bootpartition.img of=/dev/sdd2

In this command, must of course be noted that the parameter if = ... shows to the previously created backup of the bootloader, and the parameters of = ... shows on the right device (SDD2, SDE2, sdf2, etc.).

copy Root-Filesystem

Now we want to bring back the rootfs on the SD card, we have to mount the SD card again and then enter the following command:

sudo tar xvzf /tmp/rootfs.tar.gz -C /media/f24f3248-0455-4557-b1bc-377a297242a9

Here must of course again be noted that the path /media/f24f3248-0455-4557-b1bc-377a297242a9 and /tmp/rootfs.tar.gz is adapted.

Use the following command, to make sure that all the data has been correctly written to the SD card.

sync

Then we just need to unmount the SD card (the file manager, or by hand) and the card is ready.

In other languages