Sahih al-Bukhari Book 33, Hadith 18
that `Umar had vowed in the Pre-Islamic period to perform I`tikaf in Al-Masjid-al-Haram. (A subnarrator
thinks that `Umar vowed to perform I`tikaf for one night.) Allah's Messenger (ﷺ) said to `Umar,
"Fulfill your vow."
`Umar bin Al-Khattab said, "O Allah's Messenger (ﷺ)! I vowed in the Pre-Islamic period to perform I`tikaf in Al-Masjid-al-Haram for one night." The Prophet (ﷺ) said, "Fulfill your vow." So, he performed I`tikaf for one night.
The Prophet (ﷺ) used to perform I`tikaf every year in the month of Ramadan for ten days, and when it was the year of his death, he stayed in I`tikaf for twenty days.