Changes between Version 4 and Version 5 of linux/blockdev


Ignore:
Timestamp:
05/03/2018 05:44:00 PM (6 years ago)
Author:
Ryan Erbstoesser
Comment:

clarify first imaging section, clean up

Legend:

Unmodified
Added
Removed
Modified
  • linux/blockdev

    v4 v5  
    33= Linux Block Storage Devices =
    44
    5 == Imaging a Block device ==
    6 To place a root filesystem on a removable block storage device (mSATA disk, microSD card, USB Mass Storage device) you need to to the following:
     5== Imaging a Block Device (microSD) on a Linux PC ==
     6
     7These are the instructions to flash something like Ubuntu on a microSD.
     8
     9The overall theory is that to place a root filesystem on a removable block storage device (mSATA disk, microSD card, USB Mass Storage device) you need to to the following:
    710 1. Partition the device
    811 2. Format the partition(s)
     
    1417 * Can be re-sized even if mounted (via {{{resize2fs}}})
    1518
    16 The following commands will perform the above steps on a Linux development host. For convenience we set an env variable to represent the block device - take care to set this properly so as not to format a partition vital to your host (such as its rootfs)
    17 
    18 1. Determine device:
     19The following commands will perform the above steps on a Linux development host PC/Laptop. For convenience we set an env variable to represent the block device - take care to set this properly so as not to format a partition vital to your host (such as its rootfs)
     20
     21
     221. Insert the device (microSD) into the Linux PC (a USB to microSD adapter may be needed).
     23
     24Use the ls command to verify that your microSD was detected by your Linux PC. Example below:
     25{{{
     26gw@cpu-660:~$ ls /dev/sd*
     27/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb  /dev/sdb1  /dev/sdb2
     28}}}
     29 * '''Note''' - /dev/sda is usually the main hard disk of the system. DO NOT write to this.
     30 * In this case, no other media is connected to the PC, and thus the microSD is /dev/sdb
     31 * '''Note''' - If nothing besides /dev/sda comes up, please refer to the [#mmcblk0Imaging mmcblk0 section]
     32
     332. Set the DEVICE variable to the proper device, example given is /dev/sdc:
    1934{{{#!bash
    2035DEVICE=/dev/sdc
    2136}}}
    2237
    23 2. Partition device:
     383. Partition device:
    2439{{{#!bash
    2540printf "2048,,L,,\n" | sudo sfdisk -uS ${DEVICE}
    2641}}}
    27  * here we create a single Linux (type 83) partition offset at 1MiB - you can adjust the parameters to create multiple partitions depending on your needs
    28 
    29 3. Format the partition as ext4
     42 * Here we create a single Linux (type 83) partition offset at 1MiB - you can adjust the parameters to create multiple partitions depending on your needs
     43
     444. Format the partition as ext4
    3045{{{#!bash
    3146sudo mkfs.ext4 ${DEVICE}1
    3247}}}
    33  * Note that if you put this into a script I've found you need to have a second or so of a sleep following the {{{sfdisk}}} to allow the OS to re-scan the partition table before it will realize that the partition exists
    34 
    35 3. Mount the partition:
     48 * Note that if you put this into a script it has been found you need to have a second or so of a sleep following the {{{sfdisk}}} to allow the OS to re-scan the partition table before it will realize that the partition exists
     49
     505. Mount the partition:
    3651{{{#!bash
    3752sudo mount ${DEVICE}1 /mnt/disk
    3853}}}
    39  * make sure /mnt/disk exists - this is simply a mount-point
    40 
    41 4. Un-archive the rootfs tarball:
     54 * Make sure /mnt/disk exists - this is simply a mount-point. If it does not exist, use the mkdir command to create it.
     55
     566. Un-archive the rootfs tarball to the /mnt/disk location:
    4257{{{#!bash
    4358sudo tar -C /mnt/disk -xvf rootfs.tar.bz2
     
    4560 * If instead you have a rootfs directory created with {{{fakeroot}}} or {{{deboostrap}}} you can copy it with a {{{sudo cp -rupv rootfs/*  /mnt/disk}}}
    4661
    47 5. Unmount the partition:
     627. Unmount the partition:
    4863{{{#!bash
    4964sudo umount /mnt/disk
    5065}}}
     66
     678. Remove the device from the PC and insert/connect to Gateworks SBC
    5168
    5269=== mmcblk0 Imaging ===