How to make a 2 GB .img backup file, from EasyOS on an 8 GB stick?

Moderator: BarryK

Post Reply
Thanos
Posts: 76
Joined: Wed Mar 29, 2023 6:02 am
Has thanked: 2 times
Been thanked: 14 times

How to make a 2 GB .img backup file, from EasyOS on an 8 GB stick?

Post by Thanos »

I have a 8GB usb stick with easyos on it, but I used the space only 2GB .

Now, I want to backup the usb stick into a img file.

When I use the command line "dd if=/dev/sda of=myeasy.img", I get a 8GB file, it is too big for me.

So, how to make a small image only 2GB?

User avatar
BarryK
Posts: 2273
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 564 times

Re: How to make a 2 GB .img backup file from EasyOS on an 8 GB stick?

Post by BarryK »

8GB is the minimum size that is usable.

If you really want to make it smaller, you would have to reduce the size of the working-partition, using gparted.

Then, knowing how much space is required, which is, on the usb-stick:
1MiB gap + 7MiB esp boot partition + size of ext4 working-partition + 1MiB safety gap on end

Well, say that is 2GiB, 2048MiB, then you would do this:

Code: Select all

# dd if=/dev/sda of=easy.img bs=1M count=2048
# sync
Thanos
Posts: 76
Joined: Wed Mar 29, 2023 6:02 am
Has thanked: 2 times
Been thanked: 14 times

Re: How to make a 2 GB .img backup file from EasyOS on an 8 GB stick?

Post by Thanos »

After I got the 2GB image file, can I extend the image file to 3GB with some commands? I want to add some files to the easy2 partition.

User avatar
BarryK
Posts: 2273
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 564 times

Re: How to make a 2 GB .img backup file from EasyOS on an 8 GB stick?

Post by BarryK »

Thanos wrote: Wed Jan 31, 2024 10:37 pm

After I got the 2GB image file, can I extend the image file to 3GB with some commands? I want to add some files to the easy2 partition.

The easiest way would be to create a 3GB img file in the first place.

Thanos
Posts: 76
Joined: Wed Mar 29, 2023 6:02 am
Has thanked: 2 times
Been thanked: 14 times

Re: How to make a 2 GB .img backup file, from EasyOS on an 8 GB stick?

Post by Thanos »

No way to edit the img file?

I want to mount the img file and edit it.

User avatar
BarryK
Posts: 2273
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 564 times

Re: How to make a 2 GB .img backup file, from EasyOS on an 8 GB stick?

Post by BarryK »

It is possible to edit the .img file and increase its size. A few steps involved, cannot give them off the top of my head.

The easiest way would be to write the .img file to a usb stick, run gparted to increase the size of the ext4 partition, then use dd to copy it back to an .img file.

If you want to study how to operate directly on a .img file, see this:

https://github.com/bkauler/woofq/blob/m ... el-drv-img

Post Reply

Return to “EasyOS”