Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
12-06-2014, 11:49 AM
|
#1
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Rep:
|
Install OS on a RAM disk
How would I install all of Slackware to a RAM disk, not just the kernel and modules with mkinitrd?
I know Porteus has an option which essentially seems to copy the root, "/", to a RAM disk. How does it do it?
Would I just need to make a huge initrd image? If so, how would I do that?
Specifically: What I would like to do is boot off the Slackware ISO, mount a RAM disk, run the Slackware installer to install to the RAM disk, and then pack the entire RAM disk into an initrd image. How would I do this?
thanks
Last edited by Geremia; 12-13-2014 at 04:17 PM.
Reason: added more detail into a "specifically" section
|
|
|
12-06-2014, 03:49 PM
|
#2
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,154
Rep:
|
Quote:
Originally Posted by Geremia
Would I just need to make a huge initrd image? If so, how would I do that?
|
That's a possibility.
Just unpack the initrd, let's assume the root of the tree be then /tmp/initrd, then to add the packages you want:
Code:
installpkg --root /tmp/initrd <list of /paths/to/the/packages>
Then repack the initrd, rebuild the ISO image and off you go.
PS Of course, check that you have enough RAM to host all that stuff
Last edited by Didier Spaier; 12-06-2014 at 03:52 PM.
|
|
2 members found this post helpful.
|
12-06-2014, 06:41 PM
|
#3
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Original Poster
Rep:
|
Quote:
Originally Posted by Didier Spaier
Just unpack the initrd, let's assume the root of the tree be then /tmp/initrd, then to add the packages you want:
Code:
installpkg --root /tmp/initrd <list of /paths/to/the/packages>
Then repack the initrd, rebuild the ISO image and off you go.
|
This is a really good idea, but how to I pack and unpack an initrd image?
merci
Last edited by Geremia; 12-06-2014 at 06:44 PM.
|
|
|
12-06-2014, 08:35 PM
|
#4
|
Senior Member
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
|
The initrd.img file is a gzipped cpio archive.
# zcat initrd.img | cpio -i
You may want to do this in an empty subdirectory, since it will create the /* files in the pwd.
Last edited by ttk; 12-06-2014 at 08:35 PM.
Reason: oops .. typed -f instead of -i
|
|
1 members found this post helpful.
|
12-06-2014, 08:56 PM
|
#5
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Original Poster
Rep:
|
Quote:
Originally Posted by ttk
# zcat initrd.img | cpio -i
|
My cpio doesn't have an "-i" option...
This site says:
to unpack:
Code:
gzip -dc < /boot/initrd.img | cpio -i
to pack:
Code:
find . -print -depth | cpio -o -H newc > initrd.img
Last edited by Geremia; 12-06-2014 at 09:02 PM.
|
|
|
12-07-2014, 02:11 PM
|
#6
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,154
Rep:
|
Quote:
Originally Posted by Geremia
My cpio doesn't have an "-i" option...
|
Wrong, if it comes from Slackware.
FWIW; here are the small scripts i use:
Code:
#!/bin/sh
if [ ! "$#" = "2" ]; then
echo "unpack an initrd in /tmp/initrd-<suffix>
usage: ./unpack_initrd.sh <path/to/initrd> <suffix>"
exit
fi
if [ ! $UID -eq 0 ]; then
gettext "Please execute this script as root."
echo
exit
fi
TMP=/tmp/initrd-$2
if [ -e $TMP ]; then
echo "$TMP already exists."
exit
fi
mkdir $TMP
( cd $TMP
gunzip -cd $1 | \
cpio -i -d -m -H newc --no-absolute-filenames
) 1>>${TMP}/log.txt 2>>${TMP}/log.txt
Code:
#repack
( cd /root/of/the/unpacked/initrd
find . -print | cpio -o --owner root:root -H newc | gzip -9 > /path/to/initrd.gz
)
Of course this is very simplistic: that works for gzipped initrds only (all Slackware initrds are gzipped).
A more general solution would be to do a "file <name of the initrd>", parse the output and select the compression program accordingly.
Also, sometimes no compression program is used. In that case you can just cat the initrd through a pipe to cpio.
There also the possibility that tar be used instead of cpio.
In short: if the initrd is an alien, always do a "file" on it first.
But, I digress it seems
Last edited by Didier Spaier; 12-07-2014 at 02:45 PM.
|
|
1 members found this post helpful.
|
12-07-2014, 02:46 PM
|
#7
|
Senior Member
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
|
Just an addendum: Checking the Linux source code, initramfs.c appears to error out unless the initrd file is, very specifically, a "newc" (SRV4 sans CRC) formatted file, optionally compressed.
/usr/src/linux-3.10.17/init/initramfs.c on my machine, line 231. Haven't checked newer kernels to see if they've expanded to accept other formats for initramfs.
That's specific to the initramfs method; using the initrd method, a filesystem image may be used instead, formatted to any filesystem supported in the kernel (ext2, ext3, fat, etc).
http://en.wikipedia.org/wiki/Initrd does a pretty good job of explaining the differences between initramfs method (used by Slackware) and initrd method.
|
|
1 members found this post helpful.
|
12-08-2014, 02:05 AM
|
#8
|
Member
Registered: Mar 2004
Location: Sweden
Distribution: Slackware 15
Posts: 523
Rep:
|
This won't answer the question, but might give you an idea on how one can make it work
http://www.slax.org/
And yes, Slax can be installed to RAM as well. And it's based on Slackware.
Checkout the documentation, some nice reading there
|
|
|
12-09-2014, 09:37 AM
|
#9
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Original Poster
Rep:
|
Quote:
Originally Posted by MDKDIO
This won't answer the question, but might give you an idea on how one can make it work
http://www.slax.org/
And yes, Slax can be installed to RAM as well. And it's based on Slackware.
Checkout the documentation, some nice reading there
|
Yes, thank you
I mentioned Porteus, which is similar to Slax, in the OP. I should look into the documentation to see how they do it. thanks
|
|
|
12-10-2014, 11:32 AM
|
#10
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Original Poster
Rep:
|
Quote:
Originally Posted by Didier Spaier
FWIW; here are the small scripts i use:
Code:
#!/bin/sh
if [ ! "$#" = "2" ]; then
echo "unpack an initrd in /tmp/initrd-<suffix>
usage: ./unpack_initrd.sh <path/to/initrd> <suffix>"
exit
fi
if [ ! $UID -eq 0 ]; then
gettext "Please execute this script as root."
echo
exit
fi
TMP=/tmp/initrd-$2
if [ -e $TMP ]; then
echo "$TMP already exists."
exit
fi
mkdir $TMP
( cd $TMP
gunzip -cd $1 | \
cpio -i -d -m -H newc --no-absolute-filenames
) 1>>${TMP}/log.txt 2>>${TMP}/log.txt
Code:
#repack
( cd /root/of/the/unpacked/initrd
find . -print | cpio -o --owner root:root -H newc | gzip -9 > /path/to/initrd.gz
)
|
Couldn't you use rsync to just copy over the modified files to the ramdisk archive?
|
|
|
12-13-2014, 04:16 PM
|
#11
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Original Poster
Rep:
|
Quote:
Originally Posted by Didier Spaier
Code:
installpkg --root /tmp/initrd <list of /paths/to/the/packages>
|
What I would like to do is boot off the Slackware ISO, mount a RAM disk, run the Slackware installer to install to the RAM disk, and then pack the entire RAM disk into an initrd image. How would I do this? thanks
|
|
|
12-13-2014, 05:28 PM
|
#12
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,154
Rep:
|
Quote:
Originally Posted by Geremia
What I would like to do is boot off the Slackware ISO, mount a RAM disk, run the Slackware installer to install to the RAM disk, and then pack the entire RAM disk into an initrd image. How would I do this? thanks
|
That's what you stated in your first post. But re-reading it I don't understand what you mean by "mount a RAM disk". Could you give an example? I'm puzzled because somehow, once loaded in memory the initrd from the installer (file /syslinux/initrd.gz) is a RAM disk, or I misunderstand what a RAM disk is (which is very possible). Why would you need another one?
Also, out of curiosity: why do you want to do all that?
PS Having seen a similar thread you created, I assume you want to speed up you Slackware. Then you can just do this:
Code:
DIRS=$(ls /)
mkdir /ram
find $DIRS -print | cpio -o --owner root:root -H newc | gzip -9 > /ram/initrd.gz
Then write for instance a relevant file isolinux.cfg in /ram alongside a kernel then use the mkisofs command to write a bootable iso file with the content of /ram and make it bootable off USB using the isohybrid command.
PS Bear in mind that as soon as you reboot or shutdown all will be lost
Last edited by Didier Spaier; 12-13-2014 at 06:36 PM.
|
|
|
12-14-2014, 04:17 PM
|
#13
|
Member
Registered: Apr 2011
Distribution: slackware64-current
Posts: 525
Original Poster
Rep:
|
Quote:
Originally Posted by Didier Spaier
That's what you stated in your first post. But re-reading it I don't understand what you mean by "mount a RAM disk". Could you give an example? I'm puzzled because somehow, once loaded in memory the initrd from the installer (file /syslinux/initrd.gz) is a RAM disk, or I misunderstand what a RAM disk is (which is very possible). Why would you need another one?
Also, out of curiosity: why do you want to do all that?
|
To speed things up
Quote:
Originally Posted by Didier Spaier
PS Having seen a similar thread you created, I assume you want to speed up you Slackware. Then you can just do this:
Code:
DIRS=$(ls /)
mkdir /ram
find $DIRS -print | cpio -o --owner root:root -H newc | gzip -9 > /ram/initrd.gz
Then write for instance a relevant file isolinux.cfg in /ram alongside a kernel then use the mkisofs command to write a bootable iso file with the content of /ram and make it bootable off USB using the isohybrid command.
PS Bear in mind that as soon as you reboot or shutdown all will be lost
|
I think you have misunderstood my question. I don't want to store an initrd on a RAM disk. By "mount a RAM disk" I mean use some of my RAM as a filesystem (e.g., as described here, although I don't know how he mounts a RAM disk is the best way in Slackware). I want to copy the contents of the RAM disk (not the initrd image) to my hard disk whenever the machine reboots or shuts down. So, your script above should read something like this:
Code:
DIRS=$(ls /)
mkdir /ram
find $DIRS -print | cpio -o --owner root:root -H newc | gzip -9 > /mnt/internal_hard_drive/initrd_image
Last edited by Geremia; 12-15-2014 at 12:57 PM.
|
|
|
12-14-2014, 04:43 PM
|
#14
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,154
Rep:
|
OK, then just follow the answers to the post you linked to.
You'll have to find by yourself what are the appropriate places to insert the codes snippets in the Slackware init scripts.
But I strongly advise you against doing that, as if your systems hangs or halt without executing the shutdown script for any reason - and believe me, things like that happen -, all you'll have done in RAM will be lost. The speed gain is not worth the risk, IMO.
But it's your machine, so do what you want
|
|
|
12-15-2014, 09:03 AM
|
#15
|
LQ Guru
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792
|
I have to second what Didier says. The likelihood of you losing something is quite high. Also, the copy process on startup/shutdown would be enormous if you're copying several GBs worth of data from hard drive to the RAM or vice versa. And unless you have a lot of RAM, you could be limiting the available RAM to Slackware, which could seriously hinder your performance.
A better option is probably spending some money on a decent SSD (if you want to go even faster, you could get a second drive and use RAID) and then selectively mounting certain things into RAM, like the /tmp directory, or your firefox profile.
However, I am more than willing to give you the warnings to not shoot yourself in the foot, and then hand you the gun... If you really want to look at doing this, you could probably use the basics of loading the firefox profile into RAM and branch out from there. They cover using rsync to sync things with the hard drive to minimize loss. Hopefully you can pull it off without losing any toes
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 12:40 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|