DOES PARTNERSHIP WITH A NOCHRI EXEMPT FROM MEZUZAH?
Gemara
(Rava): One might have thought that partners (in a house) need not affix a Mezuzah, because it says "Beisecha", but not of partners. "Lema'an Yirbu Yemeichem" teaches that partners are liable;
"Beisecha" teaches that a Mezuzah is placed on the right doorpost (We read this "Bi'asecha", the way one enters a house, with his right foot first.)
Menachos 32b (Rava): The Mezuzah should be affixed in the Tefach closest to Reshus ha'Rabim.
33b (R. Chanina of Sura): This is so the entire house (inside from the Mezuzah) will be protected;
(R. Chanina): Hash-m's ways are unlike mortal's ways. A mortal king sits inside, and his servants guard him from the outside. Hash-m's servants (Yisrael) are inside, and He guards them from the outside - "Hash-m Shomrecha Hash-m Tzilcha Al Yad Yeminecha."
Avodah Zarah 11a: Onkelus converted. The Kaiser sent troops to return him. He put his hand on a Mezuzah, and explained 'a mortal king sits inside... but Hash-m guards his servants from the outside - "Hash-m Yishmor Tzeisecha u'Vo'echa."'
Bava Metzia 101b (Rav Mesharshiya): The tenant is obligated to affix a Mezuzah. The Mitzvah is Chovas ha'Dar (incumbent on the resident).
Rishonim
Rambam (Hilchos Mezuzah 5:4): People who write inside the Mezuzah names of angels or Kodesh names or a verse or seal, have no share in the world to come. Not only do they lose the Mitzvah, they consider this great Mitzvah of Yichud Hash-m, love and service of Hash-m, as if it were a mere amulet for their benefit.
Question (Ramach): Onkelus said that Hash-m makes the Mezuzah to guard Yisrael! R. Shimshon and all my Rebbeyim say that it guards from Mazikin. The custom is to write names in Mezuzos. Perhaps Onkelos merely said what he said to show the importance of Yisrael, but it is not really true. This is a weak answer.
Answer (Kesef Mishneh): Menachos 33b proves that Mezuzah guards Yisrael. This is when it is written properly, and the Yisrael intends for the Mitzvah. Then, automatically it guards the house.
Maharil (Teshuvos Chadashos 123): A Yisrael is commanded in the Mitzvah, so it is not Minus (idolatrous) even if he does so Lo Lishmah, just for Shemirah. The Rambam agrees to this, like the case of Onkelus.
Rosh (Hilchos Ketanos (after Menachos), Siman 10) The Mezuzah is in the Tefach closest to Reshus ha'Rabim so the entire house will be protected. Hash-m's servants are inside, and He guards them from the outside.
Rashi (Pesachim 4a DH Chovas): Mezuzah is Chovas ha'Dar (a Mitzvah incumbent on the resident) because it protects him.
Tosfos (Bava Metzia 101b DH Lo): Even though Shmuel permits to remove Tzitzis from a garment in order to put them on another garment, one may not do so with a Mezuzah, for Mazikin (Shedim, i.e. damagers with similarities to humans and angels) enter a house without a Mezuzah. When he takes it, it is as if he damages those who will live there.
Rambam (6:12): A house of partners requires a Mezuzah.
Rashba (Chulin 136a): Why don't we expound "Beisecha" to exclude partnership with a Nochri, like the above Drashos? Mezuzah is Chovas ha'Dar, for Shemirah. Also a partner with a Nochri needs Shemirah.
Tosfos (Menachos 44a DH Talis): Regarding Mezuzah, it is unreasonable to say that Beisecha excludes another's house, for it is for Shemirah. Rather, until 30 days it is not considered his house. One is considered a resident of a city after living there 30 days (Bava Basra 8a). Perhaps Mezuzah after 30 days is mid'Rabanan. A second verse says Beisecha. We say that it is Chovas ha'Dar not to obligate a renter, rather, to exempt the owner.
Mordechai (Avodah Zarah 810 and Chulin 741). R. Avigdor asked about a partner with a Nochri. Chulin 135b connotes that "Beisecha" obligates partnership with a Nochri (note - I do not understand how - PF), but "Lema'an Yirbu Yemeichem" includes only Yisre'elim, for whom the Torah wants both partners to live long lives. We need "Beisecha" to teach that a Mezuzah is placed on the right doorpost. We cannot learn from "Beisecha" in the second Parshah, for that excludes one who borrows or rents, like it says in Menachos. R. Chayim answered that a partner with a Nochri is exempt, even though we do not find a verse to exclude it. In Yoma a verse teaches that Tzara'as applies to a house owned by Yisrael partners. It does not exclude a partner with a Nochri, but since a Nochri's house is exempt, it is as if there is not a full house regarding Tzara'as. Likewise, if a Nochri owns part of a house (or gate), it is not a full house to require a Mezuzah. Therefore, we do not need a verse to exempt. Even without this reason, the law would be the same as regarding Tzara'as.
Mordechai (Menachos 962, citing R. Meir bar Baruch): I am assured that no Mazik can enter any house with a Kosher Mezuzah.
Poskim
Shulchan Aruch (YD 286:1): One must put a Mezuzah in a house of partners.
Beis Yosef (DH b'Perek): We hold like the Rashba, who obligates a partner with a Nochri, unlike the Mordechai.
Rema: Partnership with Yisre'elim is liable. If a Nochri owns part of the house, it is exempt. Also Chatzeros or cities in which some residents are Nochrim are exempt.
Taz (3): When there are Nochrim we exempt due to danger, lest the Nochri think that the Yisrael does witchcraft. This exempts all gates of the city, due to the mayor.
SMA (427:2): The Gemara equates Ma'akah (a wall around the roof) with Mezuzah. Why does the Mechaber exempt houses not for dwelling from Ma'akah, but he obligates them in Mezuzah? Ma'akah is due to danger, and there is no danger in such houses. Mezuzah is so Mitzvas Hash-m will be in front of one's eyes when he comes and goes, so we obligate even in such houses.
Shach (6,7): The Levush exempts because it says "Lema'an Yirbu Yemeichem", and Nochrim do not desire this, for they do not observe Torah. This is wrong. Rather, it is exempt because a Nochri owns part, and due to danger (suspicion of witchcraft). The latter reason is why even in Krako and Prag they did not put a Mezuzah on the gates of the streets of Yisrael, lest the mayor make accusations. Also, surely the Nochrim would take it and disgrace it. We may not cause disgrace to Kisvei ha'Kodesh. Likewise, if one sold much whiskey to a noble and his servants come every day to take it, one should have a Mezuzah only if it is in a guarded place that they cannot take it.
R. Akiva Eiger: The Levush means like Binyamin Ze'ez (167) says (the Torah obligates only when it desires that both partners live, i.e. both are Yisre'elim).
R. Akiva Eiger (Teshuvah 66): A renter is obligated in Mezuzah. This is not because rental acquires, and it is called his house. It acquires only Peros, but not the land itself! Tosfos (44a) leans to say that even after 30 days, the Chiyuv is only mid'Rabanan, for it looks like his house. Tosfos Avodah Zarah (21a DH Ha) and the Rosh hold like this. Partnership with a Nochri depends on this. If residence suffices to obligate, he is obligated, for he needs Shemirah. If we also require his house, it is exempt, for it is not totally your house, like other Drashos there in Chulin. This is why the Rema simply exempts. He is not stringent for the Rashba brought in the Beis Yosef, for Tosfos' conclusion and the Rosh exempt, like the Mordechai. It seems that Rashi (Yoma 11a DH Avulei) agrees. He says that Abaye asked about Mezuzos on gates of a city that is mostly Yisrael, for if it were mostly Nochrim, it would be exempt. One who rents in Chutz la'Aretz is exempt for 30 days. Why does the Shach say that it is not called a residence for 30 days? Perhaps he explains the Mechaber, who must hold that after 30 days the Torah obligates. This is difficult. If the Beis Yosef held that partnership with a Nochri depends on whether the Torah obligates a renter, he would not have ruled like the Rashba against the Mordechai, Rosh and Tosfos. Really, he agrees that the Torah exempts a renter.