Installing on a 1GB SD Card

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

Installing on a 1GB SD Card

Postby hyke » Sun Nov 10, 2013 3:12 am

I wanted to install the Raspberry Pi image on 1GB SD Card. The only problem is that the image is 2GB. Upon inspection you'll notice there is 1GB of free space in the install image, so it's technically possible to install on a 1GB card. This is not recommended since you'll only have 200 MB free left on the main partition, but it'll work.

Quick Summary:
$this->bbcode_list('1')
  • Copy the boot sector to the SD card
  • Create a partition table
  • Copy the boot partition
  • Manually copy the files from the data partition

  • Detailed Instructions:
    This will use examples for installing /tmp/archlinux-hf-2013-07-22.img. The SD card shows up as /dev/sdj. This will overwrite the SD card, so all information will be wiped from the card. All these steps are run as root.
    $this->bbcode_list('1')
  • Setup the image on a loopback device to make it easier to inspect the image. Inspect the partition the table (using bytes as the unit).
    $this->bbcode_second_pass_code('', '
    # losetup /dev/loop3 /tmp/archlinux-hf-2013-07-22.img
    # parted /dev/loop3 unit b print free
    ')
    For the archlinux-hf-2013-07-22.img, you should see
    $this->bbcode_second_pass_code('', '
    Model: Loopback device (loopback)
    Disk /dev/loop3: 1960837120B
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    16384B 1048575B 1032192B Free Space
    1 1048576B 95420415B 94371840B primary fat16 lba
    2 95420416B 1877999615B 1782579200B extended
    5 96468992B 1877999615B 1781530624B logical ext4
    1877999616B 1960837119B 82837504B Free Space
    ')
    You'll use the start offset of partition 1 and partition 5 to setup lookback devices for those partitions.
  • Copy the boot sector from the image onto the SD card. Note: This is copying way too much and will destroy the partition table on the SD card. We will fix the partition table in the next step.
    $this->bbcode_second_pass_code('', '
    # dd if=/dev/loop3 of=/dev/sdj bs=1M count=2
    ')
  • Create a proper partition table on the card. (I will try to mimic the image's partition table). Note: 1030225919 is the end of my 1GB SD card. Your SD card may be slightly different. You can check your SD card by "parted /dev/sdj unit b print free"
    $this->bbcode_second_pass_code('', '
    # parted /dev/sdj
    mklabel msdos
    unit b
    mkpart p fat16 1048576 95420415
    mkpart e 95420416 1030225919
    mkpart l ext4 96468992 1030225919
    quit
    ')
    You'll now notice the /dev/sdj1 and /dev/sdj5 device nodes.
  • Setup the first partition as a loopback device and dump the first partition onto the first partition of the card.
    $this->bbcode_second_pass_code('', '
    # losetup /dev/loop4 /tmp/archlinux-hf-2013-07-22.img -o 1048576
    # dd if=/dev/loop4 /dev/sdj1 bs=512 count=184320
    ')
    Note: 512 * 184320 = 94371840 (the size of the first partition).
  • Prepare the filesystem on the fourth partition and copy the data over. We can not just copy the partition from the image onto SD card like the previous step, so we'll copy the data ourselves. First we will initialize the filesystem on the SD card. We will mount the data partition from the image and mount the data partition on the SD card. Then manually copy the files from the image's partition to the SD card's partition.
    $this->bbcode_second_pass_code('', '
    # mkfs.ext4 /dev/sdj5
    # losetup /dev/loop5 /tmp/archlinux-hf-2013-07-22.img -o 96468992
    # mkdir /tmp/src /tmp/dest
    # mount -r /dev/loop5 /tmp/src
    # mount /dev/sdj5 /tmp/dest
    # cp -a /tmp/src/. /tmp/dest/.
    # umount /tmp/dest
    # umount /tmp/src
    ')
  • Cleanup the loopback devices
    $this->bbcode_second_pass_code('', '
    # losetup -d /dev/loop3 /dev/loop4 /dev/loop5
    ')

  • Anyone know how much of the boot sector needs to be copied without blowing away the whole partition table? I don't know the requirements for u-boot.
    Raspberry Pi 3 Model B Rev 1.2|Raspberry Pi Zero 2 W Rev 1.0|Hardkernel ODROID-HC4|Orange Pi 5|Orange Pi 5 Max
    linux-rpi|linux-rpi|linux-aarch64|linux-opi5|linux-collabora:aarch64
    hyke
     
    Posts: 21
    Joined: Sun Nov 10, 2013 2:26 am

    Re: Installing on a 1GB SD Card

    Postby pepedog » Sun Nov 10, 2013 9:06 am

    Rpi doesn't have uboot, just make card with a vfat and other filesystem
    Boot tarball: http://archlinuxarm.org/builder/rpi/boot.tar.gz
    Root tarball: http://archlinuxarm.org/builder/rpi/root.tar.gz
    Adjust 2 files, fat cmdline.txt and other partition /etc/fstab for the obvious
    pepedog
    Developer
     
    Posts: 2431
    Joined: Mon Jun 07, 2010 3:30 pm
    Location: London UK


    Return to Raspberry Pi

    Who is online

    Users browsing this forum: No registered users and 4 guests