Probably the worst thing that can happen to you while flashing custom ROMs is losing your IMEI, which is a result of your EFS partition becoming corrupt. Although this does not happen often, there are times you may need to make sure you have a backup of your EFS by making a backup. The simplest way to do this is to make a backup using TWRP recovery right after you root. To backup up EFS, boot into TWRP, choose backup, then only check EFS, which will backup your EFS partition. Now this backup is usually only 2MB and will not take up much space on your phone but can be instrumental in recovering your IMEI quickly and easily in case it is lost.
Recently while installing Superman ROM, I did not backup my EFS and lost my IMEI. It is usually possible to recover in such case simply by unrooting with ODIN and stock firmware but in this particular case, I have not been able to recover IMEI. Also Qualcomm-based devices are easier to recover IMEI but since my rooted S7 is Exynos-based, the problem is multiplied.
The moral of the story? Just make a backup of EFS using TWRP, put the backup in a safe place. You can even zip the backup folder and email it to yourself since it’s only 2MB big.
If all else fails, there are IMEI specialists who can use a special recovery tool to recover them at around $20 to $50. Your best bet is to save EFS, because when you lose your IMEI, you can easily restore within minutes instead of dealing with all the headaches.