clearlinux / micro-config-drive

An alternative and small cloud-init implementation in C
Other
46 stars 17 forks source link

ucd.service spend too long time to adjust disk partition #37

Closed shaoyuta closed 4 years ago

shaoyuta commented 5 years ago

I found an issue report in https://github.com/clearlinux/distribution/issues/1065 After analysis, I think this issue due to /lib/systemd/system/ucd.service [Service] Type=oneshot ExecStart=/usr/bin/ucd --fix-disk --first-boot-setup --metadata --user-data-once It looks like the execution time of command "/usr/bin/ucd --fix-disk --first-boot-setup --metadata --user-data-once" will more than 1 minutes, could this procedure be optimized ?

donnydavis commented 5 years ago

how big is the disk to be resized? What type of disk is underneath? Here is what I get on my system with a 80G disk. Could you share some details from your system?

ucd start

Aug 29 23:02:10 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [1.422253] micro-config-drive version: 36

disk resize

Aug 29 23:02:13 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [4.518814] disk: Resizing filesystem disk '/dev/vda'
Aug 29 23:02:13 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [4.534057] async_task: Executing [521]: /bin/sh -c "/usr/bin/resize2fs /dev/vda2"
Aug 29 23:02:13 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [4.534115] disk: Resizing filesystem done
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [4.534226] async_task: Running main loop
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: resize2fs 1.45.3 (14-Jul-2019)
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 kernel: EXT4-fs (vda2): resizing filesystem from 204544 to 20954892 blocks
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 kernel: EXT4-fs (vda2): resized filesystem to 20954892
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: Filesystem at /dev/vda2 is mounted on /; on-line resizing required
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: old_desc_blocks = 1, new_desc_blocks = 10
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: The filesystem on /dev/vda2 is now 20954892 (4k) blocks long.
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [4.755872] PID 521 ends, exit status 0
Aug 29 23:02:14 clr-6a739d64c0f8425983ccbb378603d889 ucd[247]: [4.755905] async_task: Quit main loop

By my measurements its only 2 seconds from start to finish for disk resize.

ahkok commented 4 years ago

ext4 resize can be slow on spinning HDD's, or even on large SSD's. However, I don't see any log evidence of how long it actually took.