Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
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.
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.
Hi guys I have a quick question I have finished the LFS book now I am wondering is it possible to chroot into my LFS build so i can do the tasks which are in the BLFS book as it will make it easier for me to compile programs as I am still learning the various commands to compile etc it is easier to copy and past to make the process a lot easier so far my LFS system boots and I am rapt I am just wanting to make the next stage a little easier the only other option was I was thinking of preparing shell scripts for each program I need to compile but that is going to take a hell of a lot longer I am happy to accept it if i have to do it the long way by booting into my LFS system cheers in advance...
PS I have learnt so much so far and really enjoyed the challenges I was presented in the first book as things weren't as simple as the book at times but none the less it has been a great learning experience.
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
I personally build a complete desktop in the chroot, but I boot into the new lfs at certain stages just to check that all is well, first as soon a bootable system is available, second after building xorg, then after install a basic desktop ( xfce is my preference ) and finally after all the extras that make a desktop usable, browser, gimp, mail, development files etc.
At which point I start using it full time but keep the old system around in case it all goes pete tong, I also take backups at the above points just in case.
Other people will do different things thats just how I do it.
That is exactly what I am wanting to do to be honest once I have a desktop environment setup I am good to boot in and do the rest from there just quickly how do I chroot is there any special way of doing it after I finished the LFS book I am still new to this and don't want to screw this up but I gather it will be much easier for me to do this especially while I am still learning to compile libraries and programs properly. Thank you for your help so far
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
I always use a small script to chroot so I don't have to type too much and also so that the chrooot environment is set/restored the same every time have a look here
For a basic chroot script, change it as needed but you will almost certainly need /dev, /proc and /sys mounted in the chroot to do anything meaninful, don't forget yto unmount them after leaving the chroot.
Thanks heaps mate I only have one partition sorry for stupid sounding qustions so do I only need to mount/dev/sda1 with the mount -v and mount vt commands for my setup or do you need to follow the script
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
No change the script as needed, if you only have your lfs partition mounted then dont mount the /media stuff, you wont have them any way, but the first bit you should use ie
Code:
LFS=$(pwd)
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
presuming the script is in the root of the mounted lfs partition, hence the first line above, this scrip was actuall designed to be run from a folder within tthe root of the mounted lfs hence the pushd .. command at the front of the script so that should be commented out, mthe script needs updating and is on my 'todo' list just use it as a guide for what you need to do.
Ok I haven't mounted it yet I am just getting my head around how to go about doing this before I do chroot into this as I am new to the whole chrooting thing I only done it for the first time in the LFS book and I also did it a couple of days ago to restore my grub bootloader as I just installed a new hard drive and had to put my LFS setup and my slackware setup back on the new hard drive from disk images...... Ok I am just a little confused I am most likely confusing myself so ust to clarify I only have one partition for my LFS setup and the script is designed for that am i right? sorry for the silly questions I want to do this right without screwing it up
Ok I don't know why but the script didn't work for me I presume it is because I deleted the /tools directory like I was instructed to in the book anyhow I found this on the net and I was able to chroot into the lfs partition and work away as needed http://www.linuxfromscratch.org/hint...and-resume.txt
Quote:
From section 6.62. Cleaning Up to The End
=========================================
From this point till the end of the whole LFS build. Steps to resume
the building
environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap
partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
If this works for you do it this way, but I would suggest sticking it in a script as you are less likely to make a typo that way.
You can and probably should remove the tools folder AFTER you have built the basic system, but before you adjust the tool chain it's a good idea to save the the tools folder, as the lfs book suggests here: http://www.linuxfromscratch.org/lfs/...gingowner.html
I just cd into the tools folder and do:
Code:
tar -zpcvf ../tools-${LFSVERSION}.tar.gz .
Where LFSVERSION is set set to the version of the book I am using, that way if something goes wrong after adjusting thee tool chain I have a clean set of tools I can use.
1. Build everything needed or optional in the LFS book. This includes anything listed during chapters like berkeley db and cracklib as well as anything else listed at the end of the LFS book.
2. I then complete Chapter 3 at least and then import many of the system utilities as well before moving on to Xorg.
3. After Xorg I work on Xfce. It's lightweight enough to be built quickly and get basic stuff inserted.
4. After I get Midori or Firefox built, it's all native B/LFS.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.