Groups and user home directories deleted after reboot

Post Reply
troja
Posts: 4
Joined: Wed Aug 05, 2015 1:09 am

Groups and user home directories deleted after reboot

Post by troja » Wed Aug 05, 2015 1:20 am

Hi,

I only yesterday hacked my HMNHD CE, enabling SSH and making the apps partition writeable.

Right now I just can't figure out a problem I have with user and group creation. Apparently, /etc is being synced at shutdown so there is no need to meddle with /boot/images/config. I could verify this: If I touch a file into /etc, it stays. I changed /etc/pam.d/su, it stayed. Also, the passwd entry for new users survives the reboot. However, the user group(s) and home folder of my user(s) don't, they are not there anymore after the reboot, and I just can't figure out why or how to avoid this.

Can someone give me a hint what's happening here?

Thanks a lot.

Cheers,
Troja

Mijzelf
Posts: 6199
Joined: Mon Jun 16, 2008 10:45 am

Re: Groups and user home directories deleted after reboot

Post by Mijzelf » Wed Aug 05, 2015 2:24 pm

With 'home folder' you mean something like /home/<user> ? Or do you mean the entry in /etc/passwd?

troja
Posts: 4
Joined: Wed Aug 05, 2015 1:09 am

Re: Groups and user home directories deleted after reboot

Post by troja » Wed Aug 05, 2015 2:29 pm

Yes, I mean the actual home folder in /home/[user]. The entry in passwd is not changing at all, it's staying the way it should.

Mijzelf
Posts: 6199
Joined: Mon Jun 16, 2008 10:45 am

Re: Groups and user home directories deleted after reboot

Post by Mijzelf » Wed Aug 05, 2015 6:54 pm

The rootfs of an Iomega is actually the initramfs, which is a ramdisk, and volatile by nature. On /etc some file is loopmounted, to give persistent configuration storage. Further on /usr another file is loopmounted, readonly, containing the major part of the firmware.

If you want the home directories to stay you'll have to put them on the data partition (/mnt/pools/A/A0/). Then you can either edit /etc/passwd to match that, or edit /etc/rc.local to exchange /home by a symlink to, for instance /mnt/pools/A/A0/home.

About the groups, can you specify what actually happens?

troja
Posts: 4
Joined: Wed Aug 05, 2015 1:09 am

Re: Groups and user home directories deleted after reboot

Post by troja » Wed Aug 05, 2015 11:50 pm

Thanks for replying.

The file that is loopmounted to /etc is /boot/images/config. As you say yourself, it should give persistent configuration storage and this seems to be the case with most of it.

However, all new entries in /etc/groups are lost after each reboot.

What I do? Simple. I create a new user, i.e. "test", using useradd. This automatically creates:

1. an entry in /etc/passwd with the new user and its group
2. an entry in /etc/group with the new group (=username)
3. a new directory in /home/ with the name of the user

After rebooting the NAS, 2. and 3. are gone.

Your point about the home drive is well taken, I will put it to the data partition. This still leaves the question why the group entry disappears after the reboot..

The same happens to other kind of changes in /etc/group, i.e. adding a user to another group. After the reboot, the changes are lost.

Mijzelf
Posts: 6199
Joined: Mon Jun 16, 2008 10:45 am

Re: Groups and user home directories deleted after reboot

Post by Mijzelf » Thu Aug 06, 2015 9:06 am

I guess the file is dynamically regenerated by the backend. A work around could be to store a copy somewhere, and put it back after booting. Problem is that it probably can't be done from rc.local, as the backend isn't finished yet initializing when rc.local runs.

But maybe you could add a group 'triggergroup', and add something like this to rc.local:

Code: Select all

{
while true 
do
        if grep triggergroup /etc/groups >/dev/null
        then
                sleep 5
                continue
        fi
        sleep 5 # Give backend time to finish it's stuff
        cp /etc/groups.backup /etc/groups
        exit 0
done
} &

Another option is to make it read only, but it is possible that will give a backend panic, leaving you with a half initialized box.

troja
Posts: 4
Joined: Wed Aug 05, 2015 1:09 am

Re: Groups and user home directories deleted after reboot

Post by troja » Sun Aug 09, 2015 11:43 pm

Hi,

Just wanted to say that I'm still working on this but very busy with other things, will post back soon my results (so far without success, even with your latest suggestion but I have some ideas I'd like to try before asking for help again..).

Thanks

Post Reply