How to install to Compact Flash directly like Hard Disk

Booting, installing, newbie
Post Reply
Message
Author
ant_llias

How to install to Compact Flash directly like Hard Disk

#1 Post by ant_llias »

I want to install my 512 Mb CF device like hard disk but I want to run / in read only, /var and /tmp in tmpfs, where can I change it, I try in fstab and mtab but it didn't work[/b]

bwongchaowart
Posts: 8
Joined: Mon 08 Aug 2005, 05:54
Location: Pennsylvania

#2 Post by bwongchaowart »

The easiest way to install to a flash card is to simply put the files vmlinuz, image.gz, and usr_cram.fs on it without extracting their contents. This minimizes writes to the flash device. In that case / is not supposed to be read-only. It is normally tmpfs, so /var/ and /tmp/ are also in tmpfs. Please see /sbin/init_ORIG for details. If you need to customize Puppy you can make new image files.

ant_llias

How to install to Compact Flash directly like Hard Disk

#3 Post by ant_llias »

Yes, I did at first time, I install my CF card like usb flash system, but the time to boot is like 30 seconds,( I drop 25 seconds from usb wait from the configuration). When I install my CF card like Hard disk the boot is fast < 15 second. I need to compile a kernel to install Real time system, install several programs, and I need fast boot in my project. I need to install / in read only,/var and /tmp in TMPFS. Can you help me?
thanks

bwongchaowart
Posts: 8
Joined: Mon 08 Aug 2005, 05:54
Location: Pennsylvania

#4 Post by bwongchaowart »

Sorry about not answering you more directly at first. I'm not an expert, but the following might help. Please try at your own risk.

If you look in /etc/rc.d/rc.sysinit, near the top / is remounted read-write:

echo -n "Remounting root rw: ";mount -o remount,rw /;check_status $?

Try deleting this or remounting ro.

You need to copy the contents of /var and /tmp somewhere. Then you mount tmpfs like this:

mount -t tmpfs tmpfs /var
mount -t tmpfs tmpfs /tmp

Move everything back into /var and /tmp.

I have no experience with full hard drive installations, but make sure that you're editing the rc.sysinit that will be present at boot-up, not a fake one as on the live cd (at the bottom of the cd's rc.sysinit /etc gets deleted and replaced).

ant_llias

How to install to Compact Flash directly like Hard Disk

#5 Post by ant_llias »

Yes, it works but I got rootfs / rw, how to make rootfs ro.
thanks

bwongchaowart
Posts: 8
Joined: Mon 08 Aug 2005, 05:54
Location: Pennsylvania

#6 Post by bwongchaowart »

Is it necessary to worry about rootfs? If the real filesystem is mounted read-only on /, then nothing can be written to it. You get a message that says "Read-only file system." What else do you need?

ant_llias

How to install to Compact Flash directly like Hard Disk

#7 Post by ant_llias »

Yes, the / is read only, I just tell it because is strange rootfs is rw. But I understand that is readonly. I think that's all I need.
thank you very much about your help

bwongchaowart
Posts: 8
Joined: Mon 08 Aug 2005, 05:54
Location: Pennsylvania

#8 Post by bwongchaowart »

I didn't say that rootfs is readonly. You need to study the kernel source for this (I haven't), but the information I have is that rootfs is used internally by the kernel during system bootup in mounting the real root filesystem, which is mounted on top of /, hiding rootfs. So rootfs is never used by the user. See, for example, Understanding the Linux Kernel, 2nd Edition by Daniel P. Bovet and Marco Cesati (O'Reilly, 2002) or maybe the kernel mailing lists. According to Understanding the Linux Kernel:
Mounting the root filesystem is a two-stage procedure, shown in the following list.

1. The kernel mounts the special rootfs filesystem, which just provides an empty directory that serves as initial mount point.
2. The kernel mounts the real root filesystem over the empty directory.

[from section 12.4.1, "Mounting the Root Filesystem"]
"File handling in the Linux kernel: VFS layer" by Kevin Boone (http://www.kevinboone.com/linux_kernel_file_1.html) seems to say the same thing.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#9 Post by Flash »

Hey, does that book define 'mounting' in any detailed but reasonably understandable way?

bwongchaowart
Posts: 8
Joined: Mon 08 Aug 2005, 05:54
Location: Pennsylvania

#10 Post by bwongchaowart »

The step-by-step description of how the root filesystem alone is mounted is about 1150 words. That seems reasonably detailed. "Mounting a Generic Filesystem" is a whole section of its own. For mounting to be understandable you need the technical details -- it's a sort of polished pseudocode with long lists of what functions get invoked and why, what gets passed to them, what happens inside them (they invoke more functions of course), what they return.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#11 Post by Flash »

Rats. There's no attempt to begin the technical description of 'mounting' with a plain english explanation of what mounting is, why it's necessary? There's been a lot of questions and discussion in the forum about it. The consensus seems to be that it's just something you have to do, like paying taxes. :(

User avatar
Ian
Official Dog Handler
Posts: 1234
Joined: Wed 04 May 2005, 12:00
Location: Queensland

#12 Post by Ian »

To put it in simple terms, mounting is a means of attaching a file to a directory in Linux so that any data in that file can be read or manipulated.

It is much like going to a library taking a book from a shelf and opening it up.

The permissions determine what you can do with the file, read, write or if it is an executable file, execute (or run a program).

bwongchaowart
Posts: 8
Joined: Mon 08 Aug 2005, 05:54
Location: Pennsylvania

#13 Post by bwongchaowart »

I think I might understand now why rootfs is not read-only. This is from the 2.4.31 kernel:

start_kernel() in init/main.c invokes
vfs_caches_init() in fs/dcache.c, which invokes
mnt_init() in fs/namespace.c, which has:

Code: Select all

init_rootfs();
init_mount_tree();
In fs/ramfs/inode.c:

Code: Select all

static DECLARE_FSTYPE(rootfs_fs_type, "rootfs", ramfs_read_super, FS_NOMOUNT|FS_LITTER);

	[...]

int __init init_rootfs(void)
{
	return register_filesystem(&rootfs_fs_type);
}
init_mount_tree() in fs/namespace.c mounts rootfs:

Code: Select all

mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);

start_kernel() in init/main.c invokes rest_init() in init/main.c, which starts the init process:

Code: Select all

	kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL);
init() in init/main.c invokes
prepare_namespace() in init/do_mounts.c, which has:

Code: Select all

sys_mkdir("/dev", 0700);
sys_mkdir("/root", 0700);
sys_mknod("/dev/console", S_IFCHR|0600, MKDEV(TTYAUX_MAJOR, 1));

[...]

create_dev("/dev/root", ROOT_DEV, NULL);

[...]

mount_root();
So it looks like things are done in rootfs before mount_root() mounts the real root filesystem, at which point you see the message printed by:

Code: Select all

printk("VFS: Mounted root (%s filesystem)%s.\n",
current->fs->pwdmnt->mnt_sb->s_type->name,
(current->fs->pwdmnt->mnt_sb->s_flags & MS_RDONLY) ? " readonly" : "");

mpd
Posts: 13
Joined: Fri 17 Mar 2006, 18:10

Re: How to install to Compact Flash directly like Hard Disk

#14 Post by mpd »

ant_llias wrote:I want to install my 512 Mb CF device like hard disk but I want to run / in read only, /var and /tmp in tmpfs, where can I change it, I try in fstab and mtab but it didn't work[/b]
been searching the forum for this...any updates on how to make an IDE-CF install that boots fast like a hard drive 2 install, yet does not write to CF except on reboot if files changed?

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#15 Post by Flash »


Post Reply