• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Use larger SD-Card with original Hilscher-Image
#1
Hello everyone,

since Revision #2 it is possible to change the micro-sd-card of the netPi. Therefore it is possible to use larger micro-sd-cards as the original 8GB-one. Since I like the original Hilscher-Image with its security features quite a lot, I would not want to miss it on a larger sd-card.

Therefore I have backuped the original Image with win32-Disk-Imager, which worked well. I was also able to flash this image to the new card using balenaEtcher. When I inserted the new card into the netPi, everything worked well. The only problem is that I forgot to extend the filesystem/logical Volume on the new card to be able to use the additional space. So my 16 GB-card still worked like a 8 GB-one. After googeling, try and error, I actually managed to extend the Logical Volume which is used by the netPi for storing our data, with the underlying volume group and physical volume. After that I was able to use the complete 16-GBs of the new card on this netPi.

I thought "hey, now I know what to do" and wrote a quick manual of how to do the extension. Trying this at the second netPi, I wasn't able to do it again. After hours of trying, I surrendered and found a kind of a "hack" which helped me out. I flashed the Image of netPi(1), which I was able to sucessfully extend to 16GBs, to the netPI(2). After that of course the netPI(2) did not boot, since the Hardware-ID of the netPi did not match the hardware-ID written to the image by Hilscher. But I managed to change the hardware-ID wirtten to the Image by coping one Partition of the original netPi(2)'s Image to the 16-GB Image of netPI(1). Now I am able to reproduce 16GB netPi Images, but as you might guess, I can't handle e.g. 32GB cards now  Blush

To cut a long story short.....Would anyone who is trying to do the same/has done the same and is more into filesystems and logical volumes than me be willing to share his way of doing it with me (and everyone else) in form of a quick manual? Or would one of the Support-Team be that kind? Rolleyes 


Thanks in advance,
Andi
  Reply
#2
Well Andi,

the following procedure described needs a separate Linux machine (like ubuntu) along with an external SD card reader. This procedure does not work on netPI booted with the original SD card since this image is secure and does not allow you to make any partition modifications.

In general the SD card image of netPI consists of 3 partitions:

Partition 1 : Filesystem FAT32 , name RESC
Partition 2 : Filesystem FAT32, name BOOT
Partition 3 : Filesystem LVM2, noname, containing two logical volumes named SYSTEM and BACKUP, both ext4 formatted.

What can be quite easily handled is to extend the size of the Partition 3 from 6GB to 32GB and is what you might have successfully done already. For this you probably used for the Linux partition tool named "gparted" and is a thing of a minute. But this is not enough because the logical volume SYSTEM - responsible for netPI's usable flash memory - within Partition 3 was not changed in its size during this procedure.
 
In order to change the size of the SYSTEM volume additionally you need help of a Linux system supporting the LVM(2) file system. You install it using the command

Code:
apt-get install lvm2

After that call the command


Code:
vgdisplay -v
 

just to display all the found LVM volumes. One of the listed volumes will be:

Code:
--- Logical volume ---
 LV Path                /dev/rootfs/SYSTEM
 LV Name                SYSTEM
 VG Name                rootfs
 LV UUID                HmnD5O-wBzR-PME6-LxZV-gbMM-ucQW-MaCWuA
 LV Write Access        read/write
 LV Creation host, time (none), 2019-03-27 15:54:47 +0100
 LV Status              available
 # open                 0
 LV Size                <6,19 GiB
 Current LE             2096
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           253:0


After that you know the name of the SYSTEM volume. Then continue with a command like the following to add +1Gbyte (or more) memory to this volume

Code:
lvresize -L +1G -n -f --resizefs rootfs/SYSTEM


Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#3
Hello Andi,

I had the opinion that my described way works ... but I have to admit it didn't.

I need to investigate further.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#4
Meanwhile I found out why the command

Code:
lvresize -L +1G -n -f --resizefs rootfs/SYSTEM

did not work as expected.

Physically the LVM volume BACKUP is directly following the SYSTEM volume. If you now resize the SYSTEM volume with the command above then the original SYSTEM volume remains as it is and at its place - cause there is no immediate space left due to followin BACKUP - and a second socalled "segment" for SYSTEM is created behind the BACKUP volume. So SYSTEM is split in two segments and this cannot be resolved by netPI.

The trick is now to delete the BACKUP volume first and then resize the SYSTEM volume. Volume BACKUP is of no relevance for netPI so you can delete it without remorse. So call first

Code:
lvremove /dev/rootfs/BACKUP

Make sure you have not called a resizing command before. So take a fresh 1:1 copy of your orignal SD card image. If a second segment was created during resizing the procedure will not work at all.

Now call

Code:
lvresize -L +1G -n -f --resizefs rootfs/SYSTEM

with any size (1G = example) you want.

If you want to create the BACKUP volume afterwards too again then call

Code:
lvcreate -L 372M -n BACKUP rootfs

at the end and you have a 100% partition structure as before but with a larger memory that can be used by netPI.

Insert the card afterwards back into your netPI and boot it and feel happy.


Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#5
A simple trick reported by a colleague of mine skips the complex SD card reformatting procedure:


  1. Create an image of the SD card your netPI was delivered with using the tool win32diskimager https://sourceforge.net/projects/win32diskimager/
  2. Write back this image to your own SD card which is usually a larger one
  3. Insert the new card in your netPI while using a prepared USB update stick to trigger a device update procedure as described in the FAQ https://www.netiot.com/?id=2427
  4. The update procedure reformats the new SD card and does a repartitioning to the maximum possible size

UPDATE: THE SIMPLE "TRICK" DOES NOT WOR ITH NETPIK!!! USE THE DESCRIPTION POSTED BEFORE INSTEAD
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#6
(December-3rd-2020, 11:32 AM)Armin@netPI Wrote: A simple trick reported by a colleague of mine skips the complex SD card reformatting procedure:


  1. Create an image of the SD card your netPI was delivered with using the tool win32diskimager https://sourceforge.net/projects/win32diskimager/
  2. Write back this image to your own SD card which is usually a larger one
  3. Insert the new card in your netPI while using a prepared USB update stick to trigger a device update procedure as described in the FAQ https://www.netiot.com/?id=2427
  4. The update procedure reformats the new SD card and does a repartitioning to the maximum possible size

Hi Armin, with a brand new netPI v1.2.0 upgraded to 1.2.2 it were not resized to the full possible 30GB as described here. All was done with the new and cloned SD-Card, the upgrade to 1.2.2 was done, but the Volume has just 8GB again. The cloned new 32GB SD-Card worked well as 1.2.0 like the original SD before I did the upgrade to 1.2.2.
  Reply
#7
Ok understood. To be honest the tip I gave in this post was not verfied by myself. I just trusted in what a colleague of mine told me. I need to try it myself I think.

So just to repeat what you have done. You had the original 8GByte SD card in the version V1.2.0.0 This one you cloned to a 32Gbyte SD card and put it back into your netPI. During this first boot sequence the new 32Gbyte SD card should still indicate 8Gbyte in size. Then you initated the update to 1.2.2.0 with this large SD card. After the next boot it still shows 8Gbyte but should show 30Gbyte+ as my colleague told us. But it does not. Is my understanding correct so far how you proceed?

If yes then could you again apply the update from 1.2.2.0 to 1.2.2.0 again with the 32GByte SD card. What does netPI indicate then?

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#8
(December-29th-2020, 08:23 PM)Armin@netPI Wrote: Ok understood. To be honest the tip I gave in this post was not verfied by myself. I just trusted in what a colleague of mine told me. I need to try it myself I think.

So just to repeat what you have done. You had the original 8GByte SD card in the version V1.2.0.0 This one you cloned to a 32Gbyte SD card and put it back into your netPI. During this first boot sequence the new 32Gbyte SD card should still indicate 8Gbyte in size. Then you initated the update to 1.2.2.0 with this large SD card. After the next boot it still shows 8Gbyte but should show 30Gbyte+ as my colleague told us. But it does not. Is my understanding correct so far how you proceed?

If yes then could you again apply the update from 1.2.2.0 to 1.2.2.0 again with the 32GByte SD card. What does netPI indicate then?

Thx
Armin

Hi Armin, here the way I tried:

1.) clone SD-Card 8GB to image v1.2.0
2.) restore image to 32GB SD-Card from that image v1.2.0
3.) put the 32GB into netPI and started to see that it works well - all worked as with the original 8GB card - 6.9GB was the size
4.) switched off and plugged in the USB RECOVERY stick v1.2.2 and power on
5.) after that Act was off from finished Upgrade power off and power on - we are on v1.2.2 now
6.) 6.9GB (PV) were allocated from SD and nearly 24GB were free without any Partition
7.) tried to do it again from points 4 to 6 again - same result it stays on 6.9GB and did no resize, but RECOVERY worked well (pw, user, all reset)
8.) made a primary partition (Partition 4) via other Linux-PC
9.) created a new PV on the 24GB partition
10.) add of the new PV to the group "rootfs"
11.) extended LV SYSTEM with fsresize to %100Free - done and netPI showed nearly 30GB

I think it is blocked from the fact that PV (Partition 3) stays on 6.9GB. A resize of the LV would work but does nothing caused by the size of the PV of just 6.9GB.
If the PV would get resized to use 100% free space, then it could extend later the LV:SYSTEM to 100% free as well, couldn't it?
There are some ways to solve it and maybe there is also a way as you described, which would be the easiest way to enlarge the SD-Card Smile

Happy new year, Armin!
  Reply
#9
Well, it might be that you have not read my previous posts in exactly this thread here I made before I posted the "easy way of my colleague". Cause in these posts I described very well the manual way on how to enlarge the size. It needs to mount the SD card in an independent Linux machine and modify the partitions manually with command like you did.

At the moment I am on holiday and can't test the netPI repartitioning as the colleague described it.

But anyway ... Happy new year to you too!
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#10
Can confirm it does not work with netPI product.

I interviewed the colleague again and what I found out is that the collegue tested it with our Raspberry Pi gateway "netFIELD Connect" which is the Cloud managed Docker platform and not the local Docker only platform like netPI is. This "netFIELD Connect" gateway supports the software version V2 and with this software version the upgrade to a bigger SD card works with charme. With netPIs software version V1 and update USB sticks it does not work.

Sorry for this confusion.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Broken SD card dusrma24 11 9,517 February-9th-2022, 02:31 PM
Last Post: dral2009
  [SOLVED]SD card writing speed m-yoshikawa 4 3,076 February-25th-2021, 07:13 AM
Last Post: m-yoshikawa
  SD card durability Armin@netPI 2 5,054 November-4th-2020, 06:01 PM
Last Post: Armin@netPI
  how to unpack netPI to replace the microSD card tad 2 2,870 September-2nd-2020, 05:47 AM
Last Post: tad
Wink SD card on NIOT-E-NPI3-51-EN-RE Lingyue 3 4,264 March-6th-2020, 07:34 AM
Last Post: Lingyue
  Sealed microSD memory card (no more) Armin@netPI 1 3,070 August-13th-2019, 10:51 AM
Last Post: Armin@netPI
  [SOLVED] Memory storage MGharat 1 2,136 April-2nd-2019, 05:32 AM
Last Post: Armin@netPI
  [SOLVED] Pin configuration Akhil 7 4,755 December-13th-2018, 07:30 AM
Last Post: Armin@netPI
  [SOLVED] Information for pin connector Justin 9 6,683 November-12th-2018, 09:25 AM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)