Changes between Version 4 and Version 5 of linux/blockdev
- Timestamp:
- 05/03/2018 05:44:00 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
linux/blockdev
v4 v5 3 3 = Linux Block Storage Devices = 4 4 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 7 These are the instructions to flash something like Ubuntu on a microSD. 8 9 The 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: 7 10 1. Partition the device 8 11 2. Format the partition(s) … … 14 17 * Can be re-sized even if mounted (via {{{resize2fs}}}) 15 18 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: 19 The 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 22 1. Insert the device (microSD) into the Linux PC (a USB to microSD adapter may be needed). 23 24 Use the ls command to verify that your microSD was detected by your Linux PC. Example below: 25 {{{ 26 gw@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 33 2. Set the DEVICE variable to the proper device, example given is /dev/sdc: 19 34 {{{#!bash 20 35 DEVICE=/dev/sdc 21 36 }}} 22 37 23 2. Partition device:38 3. Partition device: 24 39 {{{#!bash 25 40 printf "2048,,L,,\n" | sudo sfdisk -uS ${DEVICE} 26 41 }}} 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 needs28 29 3. Format the partition as ext442 * 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 44 4. Format the partition as ext4 30 45 {{{#!bash 31 46 sudo mkfs.ext4 ${DEVICE}1 32 47 }}} 33 * Note that if you put this into a script I'vefound 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 exists34 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 50 5. Mount the partition: 36 51 {{{#!bash 37 52 sudo mount ${DEVICE}1 /mnt/disk 38 53 }}} 39 * make sure /mnt/disk exists - this is simply a mount-point40 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 56 6. Un-archive the rootfs tarball to the /mnt/disk location: 42 57 {{{#!bash 43 58 sudo tar -C /mnt/disk -xvf rootfs.tar.bz2 … … 45 60 * If instead you have a rootfs directory created with {{{fakeroot}}} or {{{deboostrap}}} you can copy it with a {{{sudo cp -rupv rootfs/* /mnt/disk}}} 46 61 47 5. Unmount the partition:62 7. Unmount the partition: 48 63 {{{#!bash 49 64 sudo umount /mnt/disk 50 65 }}} 66 67 8. Remove the device from the PC and insert/connect to Gateworks SBC 51 68 52 69 === mmcblk0 Imaging ===