cloudmesh / cloudmesh-pi-burn

Burns many SD cards so we can build a Raspberry PI cluster
Other
18 stars 12 forks source link

burn: sdcard: size of SDCard #47

Open laszewsk opened 3 years ago

laszewsk commented 3 years ago

For SDCard size we need to find out how to get the size in

gregor can help once you find it out.

we need a function thatreturns the size of an sd card given the device

def size(device=dev/disk2): return number in bytes

aporlowski commented 3 years ago

cms burn info reports the sd card size on linux

# ----------------------------------------------------------------------
# SD Cards Found
# ----------------------------------------------------------------------+----------+----------------------------------------------+-------------+------------------+--------------+------------+---------+----------+-------------+-------------+
| Path     | Info                                         | Formatted   | Size             | Plugged-in   | Readable   | Empty   | Access   | Removable   | Writeable   |
|----------+----------------------------------------------+-------------+------------------+--------------+------------+---------+----------+-------------+-------------|
| /dev/sdb | Generic- USB3.0 CRW-SD/MS 1.00 PQ: 0 ANSI: 6 | True        | 64.1 GB/59.7 GiB | True         | True       | False   | True     | True        | True        |
+----------+----------------------------------------------+-------------+------------------+--------------+------------+---------+----------+-------------+-------------+
laszewsk commented 3 years ago

do we have a diffenet command that gets only one number?

laszewsk commented 3 years ago

so we can use what we have and use or we just use info and parse the first value split by space and multiply by 1000**3

# ----------------------------------------------------------------------
# Operating System SD Card
# ----------------------------------------------------------------------

Disk /dev/mmcblk0: 59.7 GiB, 64088965120 bytes, 125173760 sectors
jpfleischer commented 2 years ago

WINDOWS

Sledgehammer@Sledgehammer MINGW64 ~
$ cms burn info

# ----------------------------------------------------------------------
# This is a Windows Computer
# ----------------------------------------------------------------------

+----------+-------+-------+---------+-------+-----------+--------+----------+--------+----------+
| Volume   |   ### | Ltr   | Label   | Fs    | Type      | Size   | Status   | Info   | dev      |
|----------+-------+-------+---------+-------+-----------+--------+----------+--------+----------|
| Volume   |     2 | E     | boot    | FAT32 | Removable | 256 MB | Healthy  |        | /dev/sdb |
+----------+-------+-------+---------+-------+-----------+--------+----------+--------+----------+
+--------+-----------------+-----------------+-----------------------------------+---------+--------------+--------+
|   Disk | InterfaceType   | MediaType       | Model                             |   Model | Partitions   | Size   |
|--------+-----------------+-----------------+-----------------------------------+---------+--------------+--------|
|      1 | USB             | Removable Media | Generic STORAGE DEVICE USB Device |       2 | 59 GB        | Online |
+--------+-----------------+-----------------+-----------------------------------+---------+--------------+--------+
WARNING: We could not find your USB reader in the list of known readers
# Timer: 1.9406s Load: 0.0070s burn info
(ENV3)
Sledgehammer@Sledgehammer MINGW64 ~
laszewsk commented 2 years ago

fix field names looks liek that the split of the info has wrong order. there may need to be other fileds. create as much info as possible, and compare to the result of info posted next from linux

+----------+------------------------+-------------+------------------+--------------+------------+---------+----------+-------------+-------------+
| Path     | Info                   | Formatted   | Size             | Plugged-in   | Readable   | Empty   | Access   | Removable   | Writeable   |
|----------+------------------------+-------------+------------------+--------------+------------+---------+----------+-------------+-------------|
| /dev/sdd | Generic STORAGE DEVICE | True        | 64.1 GB/59.7 GiB | True         | True       | False   | True     | True        | True        |
+----------+------------------------+-------------+------------------+--------------+------------+---------+----------+-------------+-------------+

compare also with macos