*nix-like OSes that can use a file as root?

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Are there any *nix-like OSes that can use a file instead of a partition as the root? I'd like to create a ~2GB file on my current partition, then boot an alternate OS that can read the filesystem and use the file as a disk image / do a loopback mount for the root.

I suspect it could be done with an initrd, but I don't know the details on that stuff.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
BeOS PE worked like that, but it's probably too old to do much on modern hardware. I think one of the small slackware projects does something like this though.
 

nsafreak

Diamond Member
Oct 16, 2001
7,093
3
81
How about something that just boots from a CD like Knoppix? I don't know of any *nix distributions that will do it currently. Well actually they can, but only with a FAT partition table. Being that I'm guessing you're running Windows XP/2K with NTFS it isn't a good idea to have a *nix distribution write to that.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
You know you can make your own initrd, don't you?

Most of the time it's the kernel, it's modules, a little loopback file system with supporting applications and configurations.

Most of the time they use busybox. It's just a program that has the most important commands and features of system utilities, but instead of being bunches of little programs, it just has approximations of those programs linked to it.

What happens in initrd is that the bootloader loads linux kernel into ram, then that in turn starts init, which in turns loads the loopback filesystem into memory, untars it or uncompresses it or whatnot. In their there is a little linux psuedo-distro that loads whatever modules with whatever options you need to get to the file system.

Once it loads the modules and then mounts the filesystem it does a chroot command and then continues to execute the scripts in the different runlevels till you get a fully functional file system.

I think it wouldn't be to hard to take a normal distro, like a minimalist install or whatever and copy it to a loopback file and then copy that to a windows partition. Then use a existing initrd creation script and modify that to make your own initrd and then use loadlin.exe to boot into linux from a Dos prompt.

People often do sort of the same thing when they want a encrypted root filesystem. They do the encryption to a file that contains the loopback file system and then just boot into it.

I suppose you could run it from a ISO image and mount that into loopback so you can use a existing setup like Lilo. Just goto modify the initrd and then edit the /etc/fstab file.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Originally posted by: nsafreak
How about something that just boots from a CD like Knoppix? I don't know of any *nix distributions that will do it currently. Well actually they can, but only with a FAT partition table. Being that I'm guessing you're running Windows XP/2K with NTFS it isn't a good idea to have a *nix distribution write to that.

NTFS write support works as long as you don't do things like change file sizes. With a disk image, you wouldn't change the size of the image, only its contents.


Originally posted by: drag
You know you can make your own initrd, don't you?
I was hoping to avoid it.

Most of the time they use busybox. It's just a program that has the most important commands and features of system utilities, but instead of being bunches of little programs, it just has approximations of those programs linked to it.
I don't really want a stripped-down setup.

People often do sort of the same thing when they want a encrypted root filesystem. They do the encryption to a file that contains the loopback file system and then just boot into it.
That's true, it might be a good starting point for me to look at.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: CTho9305
Originally posted by: nsafreak
How about something that just boots from a CD like Knoppix? I don't know of any *nix distributions that will do it currently. Well actually they can, but only with a FAT partition table. Being that I'm guessing you're running Windows XP/2K with NTFS it isn't a good idea to have a *nix distribution write to that.

NTFS write support works as long as you don't do things like change file sizes. With a disk image, you wouldn't change the size of the image, only its contents.


Originally posted by: drag
You know you can make your own initrd, don't you?
I was hoping to avoid it.

There are scripts avialbe to build initrds. Gentoo has when that you use automaticly when you build kernels for it, for example. There are others. You find these scripts and change it around a bit and they can build your initrd for you.

Most of the time they use busybox. It's just a program that has the most important commands and features of system utilities, but instead of being bunches of little programs, it just has approximations of those programs linked to it.
I don't really want a stripped-down setup.[/quote]

No you misunderstand. Initrd is just like a little Linux OS like toms root boot rescue disk. It's job is just to load the modules nessicary to give the kernel the ability to read whatever medium the OS the stored on. Weither or not it's a NFS mount or a XFS partition that you need the modules to read XFS stuff. The initrd itself is a little loopback filesystem. In order to keep it small they often use busybox.

Once the initrd boots up and chroot's over to the real root partition on the harddrive then it's as if you booted up without the initrd.