apogee@g33kbox:~$ dd if=/dev/sdd of=raspi4-noob-32g.img 62333952+0 records in 62333952+0 records out 31914983424 bytes (32 GB, 30 GiB) copied, 406.123 s, 78.6 MB/s
Buat device menggunakan losetup
$ sudo losetup --show -f -P raspi4-noob-32g.img /dev/loop15
Fdisk untuk tengok partition dalam image
$ fdisk -l /dev/loop15 Disk /dev/loop15: 29.7 GiB, 31914983424 bytes, 62333952 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xdaa0952c Device Boot Start End Sectors Size Id Type /dev/loop15p1 8192 62333951 62325760 29.7G c W95 FAT32 (LBA)
Lepas tu kita mount image yang kita buat tadi
$ mkdir sdimg $ sudo mount -o loop /dev/loop15p1 sdimg $ cd sdimg $ ll total 39M -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-b.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-b-plus.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-cm.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-zero.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-zero-w.dtb -rwxr-xr-x 1 root root 25K Mei 28 18:57 bcm2709-rpi-2-b.dtb -rwxr-xr-x 1 root root 25K Mei 28 18:57 bcm2710-rpi-2-b.dtb -rwxr-xr-x 1 root root 26K Mei 28 18:57 bcm2710-rpi-3-b.dtb -rwxr-xr-x 1 root root 27K Mei 28 18:57 bcm2710-rpi-3-b-plus.dtb -rwxr-xr-x 1 root root 25K Mei 28 18:57 bcm2710-rpi-cm3.dtb -rwxr-xr-x 1 root root 41K Mei 28 18:57 bcm2711-rpi-4-b.dtb -rwxr-xr-x 1 root root 52K Mei 28 18:57 bootcode.bin -rwxr-xr-x 1 root root 303 Mei 28 18:57 BUILD-DATA drwxr-xr-x 3 root root 32K Jul 30 01:56 defaults -rwxr-xr-x 1 root root 2.4K Mei 28 18:57 INSTRUCTIONS-README.txt drwxr-xr-x 6 root root 32K Jul 30 01:56 os drwxr-xr-x 2 root root 32K Jul 30 01:58 overlays -rwxr-xr-x 1 root root 766K Mei 28 18:57 recover4.elf -rwxr-xr-x 1 root root 3.1M Mei 28 18:57 recovery7.img -rwxr-xr-x 1 root root 3.3M Mei 28 18:57 recovery7l.img -rwxr-xr-x 1 root root 121 Mei 28 18:57 recovery.cmdline -rwxr-xr-x 1 root root 675K Mei 28 18:57 recovery.elf -rwxr-xr-x 1 root root 0 Mei 28 18:57 RECOVERY_FILES_DO_NOT_EDIT -rwxr-xr-x 1 root root 3.0M Mei 28 18:57 recovery.img -rwxr-xr-x 1 root root 28M Mei 28 18:57 recovery.rfs -rwxr-xr-x 1 root root 9.5K Mei 28 18:57 riscos-boot.bin drwxr-xr-x 2 root root 32K Ogos 7 01:18 'System Volume Information'
Umount partition
$ sudo umount sdimg
Tengok dalam gparted
$ gparted /dev/loop15
Setelah resize
Untuk membuang space yang kita taknak:
$ truncate -s -${SIZE}G $image_file
Kita kena kira size tu berdasarkan value dari fdisk darab sector size.
$ fdisk -l /dev/loop15 Disk /dev/loop15: 29.7 GiB, 31914983424 bytes, 62333952 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xaf16378a Device Boot Start End Sectors Size Id Type /dev/loop15p1 8192 10493951 10485760 5G c W95 FAT32 (LBA)
Gunakan nombor End (10493951) sebagai rujukan, tambah 1 dan * 512 seperti berikut:
$ sudo umount sdimg $ losetup -d /dev/loop15 $ ll total 30G -rw-r--r-- 1 apogee apogee 30G Nov 21 13:45 raspi4-noob-32g.img drwxr-xr-x 2 apogee apogee 4.0K Nov 21 12:42 sdimg $ truncate --size=$[(10493951+1)*512] 'raspi4-noob-32g.img' $ ll total 5.1G -rw-r--r-- 1 apogee apogee 5.1G Nov 21 14:03 raspi4-noob-32g.img drwxr-xr-x 2 apogee apogee 4.0K Nov 21 12:42 sdimg
Test balik
$ sudo losetup --show -f -P raspi4-noob-32g.img /dev/loop15 $ gparted /dev/loop15
$ sudo mount /dev/loop15p1 sdimg $ ll sdimg total 39M -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-b.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-b-plus.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-cm.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-zero.dtb -rwxr-xr-x 1 root root 24K Mei 28 18:57 bcm2708-rpi-zero-w.dtb -rwxr-xr-x 1 root root 25K Mei 28 18:57 bcm2709-rpi-2-b.dtb -rwxr-xr-x 1 root root 25K Mei 28 18:57 bcm2710-rpi-2-b.dtb -rwxr-xr-x 1 root root 26K Mei 28 18:57 bcm2710-rpi-3-b.dtb -rwxr-xr-x 1 root root 27K Mei 28 18:57 bcm2710-rpi-3-b-plus.dtb -rwxr-xr-x 1 root root 25K Mei 28 18:57 bcm2710-rpi-cm3.dtb -rwxr-xr-x 1 root root 41K Mei 28 18:57 bcm2711-rpi-4-b.dtb -rwxr-xr-x 1 root root 52K Mei 28 18:57 bootcode.bin -rwxr-xr-x 1 root root 303 Mei 28 18:57 BUILD-DATA drwxr-xr-x 3 root root 32K Jul 30 01:56 defaults -rwxr-xr-x 1 root root 2.4K Mei 28 18:57 INSTRUCTIONS-README.txt drwxr-xr-x 6 root root 32K Jul 30 01:56 os drwxr-xr-x 2 root root 32K Jul 30 01:58 overlays -rwxr-xr-x 1 root root 766K Mei 28 18:57 recover4.elf -rwxr-xr-x 1 root root 3.1M Mei 28 18:57 recovery7.img -rwxr-xr-x 1 root root 3.3M Mei 28 18:57 recovery7l.img -rwxr-xr-x 1 root root 121 Mei 28 18:57 recovery.cmdline -rwxr-xr-x 1 root root 675K Mei 28 18:57 recovery.elf -rwxr-xr-x 1 root root 0 Mei 28 18:57 RECOVERY_FILES_DO_NOT_EDIT -rwxr-xr-x 1 root root 3.0M Mei 28 18:57 recovery.img -rwxr-xr-x 1 root root 28M Mei 28 18:57 recovery.rfs -rwxr-xr-x 1 root root 9.5K Mei 28 18:57 riscos-boot.bin drwxr-xr-x 2 root root 32K Ogos 7 01:18 'System Volume Information' $ sudo umount sdimg $ sudo losetup -d /dev/loop15
Selesai... tu je nak kongsi.