官术网_书友最值得收藏!

Setting up the SD card on Linux

This recipe will explain how to set up the SD card using a Linux-based operating system. On Linux computers, you usually will not need any special software to uncompress archives or write the image to an SD card. To do these tasks, you usually need the command-line tools tar and dd that are preinstalled on almost any Linux distribution by default.

Getting ready

To prepare your image and the SD card on Linux, you will only need the following software ingredients:

  • A downloaded image from the Downloading an operating system for the Banana Pi recipe
  • The dd program
  • The tar program including gzip support
  • Optionally, the fdisk program

How to do it…

The following steps are required to unpack the image archive and write the image to the SD card:

Note

Use the following dd command very carefully. The dd command will overwrite anything on the output (the of parameter). In fact, you can damage your computer, if you choose the wrong output. So, make sure that the value of the parameter of is definitely the SD card.

  1. Unpack the downloaded .tar.gz or .tgz archive using the following command:
    $ tar -xzvf Raspbian_For_BananaPi_v1412.tgz
    
  2. If you have downloaded a .zip file, you use the following command:
    $ unzip Raspbian_For_BananaPi_v1412.zip
    
  3. Determine how your SD card is recognized by the system. You can check the correct path of your SD card by using the following command:
    $ sudo fdisk -l
    
    Tip

    To determine the correct device, you can compare the results before and after you plug in the SD card.

    The commands used in the next steps assume that your SD card is recognized as /dev/mmcblk0.

  4. Make a backup of the contents on your SD card.
  5. Unmount all partitions of the SD card, if any partition is mounted:
    $ sudo umount /dev/mmcblk0*
    
  6. Write the image to the SD card:
    $ sudo dd if=Raspbian_For_BananaPi_v1412.img of=/dev/mmcblk0 bs=1M
    

    The writing process takes a few minutes.

  7. On some systems, the SD card is automatically mounted after the writing process. Unmount the partitions of the SD card again:
    $ sudo umount /dev/mmcblk0*
    

When the writing process is finished, you can eject your SD card and put it into the SD slot of your Banana Pi.

How it works…

On Linux, you also need to unpack an image file and write the image to the SD card. Luckily, these tasks are much quicker and more easily done on the command line and you usually do not need to install additional software.

In fact, to unpack the image, you need the tar command and to write an image to the SD card you need the dd (disk dump) command. The tool tar is a program to pack or unpack archive files. The tool dd is a utility to convert and copy files from a source (the input file—the if parameter) to a destination (the output file—the of parameter). In contrast to a normal file copy, the actual order of the bytes is preserved.

The dd command is executed with root privileges (by using the prefix command sudo) to use the image file as input, the SD card as output, and to read/write with a block size (the bs parameter) of one megabyte. That block size value is a safe choice when writing images to or reading from SD cards. You can also try a block size value of 4M, which results in a faster but possibly unsuccessful writing process.

You do not need to format the SD card before issuing the dd command as dd also writes the whole partition information directly to the SD card.

Note

The output parameter has to be the whole SD card (/dev/mmcblk0 in our previous example). Make sure not to accidentally write to a partition of the SD card. This means do not use /dev/mmcblk0p1 or the like).

Moreover, depending on your computer, the SD card may be recognized as /dev/sdX and not /dev/mmcblk0. Use the fdisk -l command to determine the correct device file as mentioned in this recipe.

The dd command will take some time. If you want to check the progress, you can issue the following command in another shell:

$ sudo pkill -USR1 -n -x dd

This will output the current status on the running dd job.

See also

  • Type in the man dd command into a shell to show the manual page of dd:
    $ man dd
    
  • Type in the man tar command into a shell to show the manual page of tar:
    $ man tar
    
  • Type in the man fdisk command into a shell to show the manual page of fdisk:
    $ man fdisk
    
主站蜘蛛池模板: 巨野县| 赤壁市| 荣昌县| 达日县| 西平县| 郯城县| 张家港市| 修武县| 金湖县| 芒康县| 武胜县| 阿城市| 玛多县| 白城市| 黄大仙区| 五指山市| 溧阳市| 北海市| 沂水县| 稻城县| 乌拉特中旗| 元氏县| 乡城县| 广州市| 乌拉特后旗| 永修县| 龙川县| 东丽区| 宜黄县| 册亨县| 于田县| 阿克苏市| 沂源县| 济南市| 舒城县| 灌阳县| 遂平县| 阜宁县| 连州市| 聊城市| 大同市|