from: http://www.koltorah.org/ravj/Do_Walk_In_Closets_and_Porches_Require_a_Mezuzah_2.html
The Gemara (Sukkah 3a) teaches that we are not required to attach a
Mezuzah to a house which is smaller than four Amot (cubits) by four
Amot. The Rishonim debate whether the Gemara requires a minimum length
and width of four Amot (Rosh Hilchot Mezuza number 16) or just an area
of sixteen square Amot regardless of length and width (Rambam Hilchot
Mezuzah 6:2). For example, if an area is eight Amot long and two Amot
wide, it is sixteen Amot square, but is not four Amot wide. In such a
case, a Mezuzah is required according to the Rambam but not according
to the Rosh. This issue is quite relevant, as many walk-in closets
have narrow corridors but are quite long.
Many individuals do not have Mezuzot attached to their walk-in
closets, and they certainly have many opinions upon which to rely. One
who adopts the strict view and attaches a Mezuzah to a walk-in closet
(either to the right or left side) should most likely omit the
Berachah in deference to the many opinions who rule that walk-in
closets do not require a Mezuzah.
In practice, one should inquire of his Rav as to whether walk-in
closets and porches require a Mezuzah and to which side it should be
affixed. Moreover, it is highly recommended for one to invite his Rav
to visit his home for an inspection to insure that Mezuzot are affixed
in all of the required areas and that they are attached to the proper
side of the doorway.
In response to the question's edit I'll add a quote from the same site:
Rav Akiva Eiger (commentary to Shulchan Aruch Y.D. 286:13) places a further limitation on the four by four Amot exemption. He believes that it does not apply if the area that is less than sixteen square Amot leads into an area that requires a Mezuzah. He rules that one is required to affix a Mezuzah to the right side as one leaves the small area into the larger area. Even though the small area is in and of itself exempted from a Mezuzah, one is required to affix a Mezuzah just as one places a Mezuzah on the doorway to his home. In that case, one places a Mezuzah on the right side entering the house, since one enters from an area that does not require a Mezuzah (the outside) to an area that requires a Mezuzah (one's home)...Although the Aruch HaShulchan (Y.D. 286:23) rules in accordance with Rav Akiva Eiger, some Acharonim dispute or limit his view... Rav Moshe Feinstein (Teshuvot Igrot Moshe Y.D. 1:181) writes that Rav Akiva Eiger's assertion is "bewildering" and that "in practice one is not required to accommodate his view." Rav Ovadia Yosef (ad. loc.) does not even consider the opinion of Rav Akiva Eiger in his ruling (he cites Rav Moshe as one of his many precedents for this approach). >
A similar issue applies to affixing a Mezuzah to a porch (or a deck). A porch would seem not to require a Mezuzah, since it does not
have a roof (Shulchan Aruch Y.D. 286:14). However, one could claim
that it does require a Mezuzah either because it is normal for a porch
not to have a roof (similar to the approach of the Chamudei Daniel) or
that one should affix the Mezuzah on the right side as one enters the
house from the porch based on Rav Akiva Eiger. The Aruch HaShulchan
(ad. loc.) explicitly applies Rav Akiva Eiger's ruling to an area that
does not have a roof. A consensus view has not emerged among contemporary Poskim regarding this issue. The Chazon Ish (Y.D. 168:5) rules that one should affix a Mezuzah on the right side as one enters a house from a porch, while Rav Ovadia Yosef (ad. loc.) cites many Poskim, such as Rav Yaakov Emden and Rav Shlomo Kluger, who rule that it should be placed on the right side as one leaves one's home to enter the porch. Rav Yosef concludes that essentially a porch does not require a Mezuzah, but one who affixes a Mezuzah at the entrance to his porch "will have a Berachah bestowed upon him." Rav Yosef rules that those who affix a Mezuzah to their porch entrance should do so on the right side as one leaves the house to enter the porch.