Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
fuss:linux [2020/07/08 04:19] – [Scraping a Site Automatically using SystemD] officefuss:linux [2021/04/16 19:21] – [Self-Delete Shell Script] office
Line 1196: Line 1196:
  
 Finally access the original underlying content via the path ''/mnt/root/mnt/usb2''. Finally access the original underlying content via the path ''/mnt/root/mnt/usb2''.
 +
 +====== Self-Delete Shell Script ======
 +
 +<code>
 +rm -rf -- "$@"
 +</code>
 +
 +====== Resize Last Partition and Filesystem in Image File ======
 +
 +Assuming that an image file is available and named, for example, ''raspios.img'' then the following procedure will extend the last partition and the filesystem by a given size.
 +
 +First, extend the image file ''raspios.img'' itself with zeroes:
 +<code bash>
 +dd if=/dev/zero bs=1M count=500 >> raspios.img
 +</code>
 +where:
 +  * ''1M'' is the block size,
 +  * ''500'' is the amount of blocks to copy over
 +
 +In this case, the image file ''raspios.img'' is extended by $500MiB$. Alternatively, ''qemu-img'' can be used to extend the image file:
 +<code bash>
 +qemu-img resize raspios.img +500M
 +</code>
 +
 +The next step is to run ''parted'' and extend the last partition inside the image file. Open the image file with ''parted'':
 +<code bash>
 +parted raspios.img
 +</code>
 +
 +and then resize the partition, for example:
 +<code bash>
 +(parted) resizepart 2 100%
 +</code>
 +where:
 +  * ''2'' is the partition number
 +
 +The ''parted'' command will resize the second partition to fill 100% of the available space (in this example, it will extend the second partition by $500MiB$).
 +
 +The final step is to enlarge the filesystem within the second partition that has just been extended by $500MiB$. ''kpartx'' will create mapped devices for each of the partitions contained within the ''raspios.img'' image file:
 +<code bash>
 +kpartx -avs raspios.img
 +</code>
 +
 +First, the existing filesystem has to be checked:
 +<code bash>
 +e2fsck -f /dev/mapper/loop0p2
 +</code>
 +where:
 +  * ''/dev/mapper/loop0p2'' is the last partition reported by ''kpartx''
 +
 +and then finally the filesystem is extended to its maximum size:
 +<code bash>
 +resize2fs /dev/mapper/loop0p2
 +</code>
 +
 +
 +
 +
 +
 +
  
  

fuss/linux.txt · Last modified: 2024/02/21 06:47 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.