To unmount, run: for i in /dev /dev/pts /proc /sys /run do sudo umount /media/root$i doneĬreating Ubuntu Persistent Live USB Imageįollow these steps to flash a USB drive with a persistent live installation of Ubuntu: Then cd into root folder of img and chroot: cd /media/root 512*1050624 = 537,919,488Īlso mount other system folders: for i in /dev /dev/pts /proc /sys /run do sudo mount -B $i /media/root$i done Then, multiply block-size of 512 bytes by the start-block of the Linux partition, 1050624. To determine the offset for your image or drive, run: fdisk -l /media/user/usbdata/ubuntu.img Sudo mount -t ext4 -o loop,offset=537919488 /media/user/usbdata/ubuntu.img /media/root To modify an existing Linux image or drive from within Linux, plug in drive or mount the image: sudo mkdir /media/root When completed, shutdown and disconnect USB.īoot to internal eMMC drive Creating the Image:Ĭreate uncompressed sparse image file from internal eMMC and save to flash drive sudo dd if=/dev/mmcblk0 bs=1M status=progress | cp -sparse=always /dev/stdin /media/ubuntu/usbdata/ubuntu.imgĮxtract uncompressed image file to internal eMMC sudo dd if=/media/ubuntu/usbdata/ubuntu.img of=/dev/mmcblk0 bs=1M status=progressĬreate compressed image file from internal eMMC and save to Desktop sudo dd if=/dev/mmcblk0 bs=1M status=progress | gzip > /home/user/Desktop/Įxtract compressed image file to internal eMMC sudo gzip -cd /home/user/Desktop/ | dd of=/dev/mmcblk0 bs=1M status=progress Launch Terminal and type in the following command (single line): sudo dd if=/media/ubuntu/usbdata/ubuntu.img of=/dev/mmcblk0 bs=1M status=progress Boot to USB (default persistent live option). Plug in bootable Ubuntu persistent live USB with image file in usbdata partition into Single-Board Computer such as UP² Board. Sparse (Shrunken) Image Cloning Instructions: I have seen advice in many places that dd should not be performed on a mounted partition and I followed that because it seems intuitively correct it does seem rather like trying to sketch yourself making a sketch in a mirror with the sketch you're making also visible in the sketch. This cuts out the other 6 GB (or 30 GB or whatever the device has spare) of unused space that would otherwise be in the image. The resulting image will also include the random noise beyond the greatest extent of the last partition.ĭon't forget to sudo the above commands if your account doesn't already have sufficient privileges.įor my purposes, I don't need an image that is perfectly trimmed down to the last bit of data so when the real size is 1.75 GB then a 2 GB image is near enough for me. If you decide, for example, that your image should be exactly 2 GB, the following command will do that: dd if=/dev/mmcblk0 of=/path/to/pi_updated.img bs=1M count=2048 Total used space in GB = total used space in bytes / 1024 3 (here that's 1.749023 GB). Total used space in bytes = end sector of last partition X sector size (here that's 3667967 x 512). I/O size (minimum/optimal): 512 bytes / 512 bytesĭevice Boot Start End Sectors Size Id Type Sector size (logical/physical): 512 bytes / 512 bytes Substitute / with a space-separated list of all the mount points relating to the disk partitions.Ī more accurate way might be to use fdisk or your preferred partition editor and get busy with a calculator. If not, you can get a good idea from df: df -H -total / You may already know what size image you want to create. Using the bs and count parameters of dd, you can limit the size of the image, as seen in step 2 of answer 1665017.
Sudo dd if=myimage/mbr.img of=/dev/sdX bs=446 count=1 Sudo cp -rf -preserve=all myimage/partition2/* /media/mount_point_partition2/ Sudo cp -rf -preserve=all myimage/partition1/* /media/mount_point_partition1/ On most computers, you just need to connect the disk and you can find the mounted partitions in /media folder.Ĭopy the previously copied data to destination partitions using following commands Mount the freshly formatted and partitioned disk.
Partition the destination disk into partitions with sizes greater than copied data and should be of the same format and same flags using gparted. Replace /dev/sdX with the corresponding device. Sudo dd if=/dev/sdX of=myimage/mbr.img bs=446 count=1 Sudo cp -rf -preserve=all /media/mount_point_partition2/* myimage/partition2/ Sudo cp -rf -preserve=all /media/mount_point_partition1/* myimage/partition1/
Copy all the files from all the partitions preserving meta data