Tech. Qs: Booting, tmpfs, mount proc, ramdisk, chroot, etc.

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

Tech. Qs: Booting, tmpfs, mount proc, ramdisk, chroot, etc.

#1 Post by sunburnt »

I'm booting a tiny custom Puppy, doing a login, & then a Samba mount with username & password.
This will provide better security than the usual method of just logging in to a WM.
The file: usr_cram.fs is then mounted over the Samba share from the server.
Then how to jump to the standard Puppy distro., I'm lacking a clear picture of how to do this.

I don't know what tmpfs is ( I guess there's others also ), as well as proc mounting, chroot, etc.
I stare at "init", & I just don't grasp what's happening with these commands:

mount -t proc none /proc ----- top of init =========== What's these lines do?
mount -o remount,rw /

mkdir /new_root -------------- middle
mount tmpfs /new_root -t tmpfs -o size=${SIZEFILLK}k
cp -a /(existing dirs.) /new_root/ ================ Copy from old RD to new?

cd /new_root ------------------ bottom
mkdir old_root
sync
umount /proc ================= unmount /proc to pivot to new RamDisk "/"?
pivot_root . old_root
exec chroot . sh -c "exec /bin/busybox init $INITARGS" <dev/console >dev/console 2>&1

And then at the top of rc.sysinit:

mount /proc ================== after chroot mount /proc again?
mount -o remount,rw /
mount /dev/pts

Is the command: "mount tmpfs /new_root" actually mounting the ramdisk?
So then the: "pivot_root . old_root" & "exec chroot" is setting "/" to the new RD? (please Detail this)
rc.sysinit again mounts /proc after chroot, the next line remounts "/" from R/O to R/W.
And I haven't a clue at all about what "mount /dev/pts" does.

Which brings up the next Q, why does Puppy load one ramdisk & then jump to a second one?
The rest I grasp fairly well (I think), but how to swap the tiny distro's file system for the full one?

The custom tiny distro has it's usr_cram.fs expanded into /usr in the image.gz file.
The idea's to use one kernel for both distros (you can't jump kernels... yet), & swap the "/" fs.
Could I just expand the full distro's image.gz into the existing RD, it's mounted & ready to go.
It looks to be what's happening in the middle of the init file, except this'd be in the same RamDisk.
So maybe the mount/umount of /proc, pivot_root, & exec chroot wouldn't be needed?

Would doing this "screw the pooch" (to coin the phrase), it sure seems like it would work.
If someone would be kind enough to lay out what's going on here during early booting...
And some solid ideas ( & maybe some code ) on accomplishing this task of file system replacement.

Many Thanks for ALL the Help... SunBurnt

Post Reply