A halo generation mechanism in the nonperiodic lattices such as the SNS (Spallation Neutron Source) linac MEBT [medium-energy beam transport between radio-frequency quadrupole and DTL (drift tube linac)] is reported. We find that the nonlinear space charge force resulting from large transverse beam eccentricity $\ensuremath{\sim}2:1$ in the $\ensuremath{\sim}1.6\mathrm{m}$-long MEBT chopper section is responsible for halo formation. As a result, the beam distribution, based on the front end emittance measurements and multiparticle simulation studies, develops halo that leads to beam loss and radioactivation of the SNS linac. Designing lattices with transverse beam eccentricity close to 1:1 suppresses this kind of halo generation. Modifying the MEBT optics and introducing adjustable collimators in the MEBT significantly reduced beam losses in the coupled cavity linac, which is a preferred scheme for mitigating halo. It turns out that the DTL collimation does not effectively remove halo and presents a risk of overheating drift tubes.