Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:installation:installation_methods:sd_card [2022/12/19 16:49] – [Which image to chose?] cleanup typos palebloodskydocs:guide-user:installation:installation_methods:sd_card [2024/02/12 12:06] – external edit
Line 29: Line 29:
  
 ==== Which image to chose? ==== ==== Which image to chose? ====
-Often multiple images are available for a device which differ in the [[:docs:guide-user:storage:filesystems-and-partitions|filesystem ]] used.+Often a device has multiple images available which differ in the [[:docs:guide-user:storage:filesystems-and-partitions|filesystem ]] used.
  
 === ext4-sdcard.img.gz === === ext4-sdcard.img.gz ===
   * not optimized for flash memory (journaling increases flash wear)   * not optimized for flash memory (journaling increases flash wear)
   * sd card can be easily mounted externally for modification   * sd card can be easily mounted externally for modification
-  * any updates and changes can be made directly to file system +  * updates and changes can be made directly to the partition 
-  * desktop Linux standard+  * Linux desktop standard
  
 === squashfs-sdcard.img.gz === === squashfs-sdcard.img.gz ===
-  * newer images include a hidden f2fs filesystem, which is optimized for flash memory 
   * compressed   * compressed
 +  * newer images include a hidden f2fs filesystem, which is optimized for flash memory
   * needs special mount procedure to externally modify   * needs special mount procedure to externally modify
   * all changes are done in an overlay partition   * all changes are done in an overlay partition
-  * due to overlay partion very simple to reset system to defaults+  * due to overlay partition it is simple to reset system to defaults
  
 == other images == == other images ==
   * ubifs-sdcard.img.gz   * ubifs-sdcard.img.gz
-  * ... 
  
 +==== Mounting a squashfs filesystem locally ====
  
 +If you insert your newly flashed SD card into a Linux machine, it will be easy to mount the read only squashfs partition but it won't know about the overlay, which is not even in the partition table but instead located immediately after the squashfs filesystem in the same partition. You therefore need to mount the overlay as a loopback device. You can discover the offset by running losetup on the device, or calculate the offset yourself by inspecting the filesystem.
 +
 +<code>
 +# Setup the loop back device.
 +# See libfstools/rootdisk.c for source of partition offset logic.
 +DEVICE= ### Set this appropriately - e.g. /dev/sda
 +PARTITION="$DEVICE"2
 +FS_SIZE="$(sudo unsquashfs -s "$PARTITION" | grep -o 'Filesystem size [0-9]* bytes' | grep -o '[0-9][0-9]*')"
 +FS_OFFSET="$(expr '(' "$FS_SIZE" + 65535 ')' / 65536 '*' 65536)" 
 +LOOP_DEVICE="$(sudo losetup -f --show -o "$FS_OFFSET" "$PARTITION")"
 +
 +# Now mount both partitions (remember, you may need to unmount any automatic mounts)
 +mkdir -p /mnt/base /mnt/overlay /mnt/combined
 +sudo mount "$PARTITION" /mnt/base            
 +sudo mount "$LOOP_DEVICE" /mnt/overlay
 +sudo mount -o noatime,lowerdir=/mnt/base,upperdir=/mnt/overlay/upper,workdir=/mnt/overlay/work -t overlay overlayfs /mnt/combined
 +</code>
 +
 +This should leave you with a writable filesystem in /mnt/combined which will work as it does on OpenWRT.
  
 ==== Expanding the filesystem ==== ==== Expanding the filesystem ====
 +
 To use the whole available space of your sdcard, you probably have to resize your partition.  To use the whole available space of your sdcard, you probably have to resize your partition. 
  
 === squashfs image === === squashfs image ===
-To resize the squashfs-image one has to know the offset of the hidden f2fs filesystem.  + 
-In this example, the squashfs partiton is ''/dev/sde2''. +As with mounting the overlay above, to resize it you'll need the offset of the hidden f2fs or ext4 filesystem (depending on the size of your image, one or the other will be used)
-  - You can find the offsetby running ''losetup'' on your openwrt device. + 
-  On your computer, resize the squashfs partition, for example with ''cfdisk''. +Firstmake sure the partition is not mounted, then do something like: 
-  - Loop mount the underlying f2fs partition (( If you are already using a loop device, you may have to use another number that loop0 )) <code>losetup --o <offset> /dev/loop0 /dev/sde2</code> + 
-  - Run filesystem checks <code>fsck.f2fs /dev/loop0</code> +<code> 
-  - Resize f2fs filesystem <code>resize.f2fs /dev/loop0</code> +DEVICE= ### Set this appropriately - e.g. /dev/sda 
-Now your filesystem should be recognized with the correct size.+PARTITION="$DEVICE"2 
 +sudo cfdisk "$DEVICE"  # select resizethen write 
 + 
 +# Create a loop device pointing to the FS 
 +# See libfstools/rootdisk.c for source of partition offset logic
 +FS_SIZE="$(sudo unsquashfs -s "$PARTITION" | grep -o 'Filesystem size [0-9]* bytes| grep -o '[0-9][0-9]*')" 
 +FS_OFFSET="$(expr '(' "$FS_SIZE" + 65535 ')' / 65536 '*' 65536)"  
 +LOOP_DEVICE="$(sudo losetup -f --show -o "$FS_OFFSET" "$PARTITION")" 
 + 
 +# Now, resize... you may need to fsck first, though
 +sudo fsck "$LOOP_DEVICE" 
 +sudo resize2fs "$LOOP_DEVICE" 
 +</code>
  
 === ext4 image === === ext4 image ===
-You can us gparted to resize and extend the partitions.+ 
 +You can use gparted to resize and extend the partitions.
 To do it online, follow the procedure in [[http://bugs.openwrt.org/index.php?do=details&task_id=2951|link]] or [[docs:guide-user:installation:openwrt_x86#resizing_filesystem|link]]. To do it online, follow the procedure in [[http://bugs.openwrt.org/index.php?do=details&task_id=2951|link]] or [[docs:guide-user:installation:openwrt_x86#resizing_filesystem|link]].
  
 +Example, to resize ''/dev/mmcblk0p2'' mounted on ''/'', install ''parted'', ''tune2fs'' and ''resize2fs'' then:
 +<code>
 +parted
 +p
 +resizepart 2 32GB
 +q
 +</code>
 +Next, you may need to repair your device (perhaps say yes to all interactive queries):
 <code> <code>
 mount -o remount,ro /                  #Remount root as Read Only mount -o remount,ro /                  #Remount root as Read Only
-tune2fs -O^resize_inode /dev/device    #Remove reserved GDT blocks +tune2fs -O^resize_inode /dev/mmcblk0p2    #Remove reserved GDT blocks 
-fsck.ext4 /dev/device                  #Fix part, answer yes to remove GDT blocks remnants +fsck.ext4 /dev/mmcblk0p2                  #Fix part, answer yes to remove GDT blocks remnants 
- +</code> 
-#reboot +Now, ''reboot'' and then resize the partition: 
-resize2fs /dev/device+<code> 
 +resize2fs /dev/mmcblk0p2
 </code> </code>
  
Line 88: Line 130:
  
 ===== Devices with this installation method ===== ===== Devices with this installation method =====
----- datatable ---- +<!-- ToH: { 
-cols       BrandModelVersionsSupported Current Rel_releasecurrentInstallation method(s)_method-installationsComment installationDevice Page_pageDevice Techdata_pageid +  "source""json", 
-dynfilters +  "dom": "t", 
-filter     Model!=@@Model@@ +  "paging": true, 
-filter     : installation method(s)=SD card +  "pageLength": 25, 
-sort       : Brand +  "shownColumns": ["brand""model""version", "supportedcurrentrel", "installationmethods", "commentinstallation", "devicepage", "deviceid"]
-limit      : 25 +  "filterColumns"{"installationmethods""^SD card$", "model": "!^@@Model@@$"} 
-----+--
  • Last modified: 2024/12/13 16:42
  • by palebloodsky