Ferrofluids have promising application potentials for biological, medical, subsurface, and many other industrial purposes. To bring the potentials to reality, it is of utmost importance to characterize the behavior of ferrofluids under different conditions, especially in the presence of more than one phase. In this study, the quasi-static behavior of a non-wetting incompressible and inviscid ferrofluid blob surrounded by a wetting non-magnetic fluid confined in a capillary tube is theoretically and computationally investigated when a uniform magnetic field is applied, assuming isothermal conditions. The effect of geometrical, hydrodynamic, and magnetic properties of the blob on its deformations when subject to a magnetic field is explained. Moreover, the effect of nonlinear magnetization on the ferrofluid blob evolution in the capillary tube is investigated in detail. In the case of a tube with constant circular cross-section, the behavior of the blob before the critical state of detachment is determined numerically, while the post-critical behavior is resolved analytically. To characterize the pre-critical blob deformations, the magnetic field distribution inside the blob for given external magnetic fields is calculated using a commercial finite element software and is employed to calculate the interfacial configuration from balances among magnetic, capillary, and hydrostatic forces. We show that increasing magnetic field intensity above a critical value causes the blob to detach from the tube wall under certain conditions and quantitatively characterize the critical magnetic field as well as blob configurations before and after detachment. Results show that there is a maximum blob length beyond which detachment does not occur, due to the nonlinear magnetization of the ferrofluid blob. This length depends on the relative magnitude of magnetic and capillary forces and also on the geometry of the confining capillary tube. Even if detachment occurs, the nonlinear magnetization prevents the blob from evolving infinitely after detachment. The conditions under which detachment may occur are analytically determined. The simulations confirm that, for sufficiently small magnetic fields, the linear approximate magnetization yields satisfactory results. However, with increasing magnetic field intensity, the deviation between the results with nonlinear magnetization and those with linear approximate magnetization increases significantly. In addition, this deviation is more pronounced for longer blobs. These findings emphasize the importance of incorporating the nonlinear magnetization for relatively large magnetic field intensities. Finally, in order to relax the simple confining geometry assumption, we show preliminary simulations using the level set method in complex solid geometries. The method was previously developed for capillarity and used for realistic rock geometries and now accounts for the magnetic pressures as well.