Recent work has shown that pressures inside dsDNA phage capsids can be as high as many tens of atmospheres; it is this pressure that is responsible for initiation of the delivery of phage genomes to host cells. The forces driving ejection of the genome have been shown to decrease monotonically as ejection proceeds, and hence to be strongly dependent on the genome length. Here we investigate the effects of ambient salts on the pressures inside phage-lambda, for the cases of mono-, di-, and tetravalent cations, and measure how the extent of ejection against a fixed osmotic pressure (mimicking the bacterial cytoplasm) varies with cation concentration. We find, for example, that the ejection fraction is halved in 30 mM Mg(2+) and is decreased by a factor of 10 upon addition of 1 mM spermine. These effects are calculated from a simple model of genome packaging, using DNA-DNA repulsion energies as determined independently from x-ray diffraction measurements on bulk DNA solutions. By comparing the measured ejection fractions with values implied from the bulk DNA solution data, we predict that the bending energy makes the d-spacings inside the capsid larger than those for bulk DNA at the same osmotic pressure.