For some reason I found it difficult and confusing to write out the procedure for this before starting. (Yes, I make a written procedure for every session.) Google AI Mode got involved.
Exploring
First I checked out a variety of things to be used in the next sections.
I looked at startup files in ~ and /etc with ls -A, and then less.
I expected these files to not exist because they were not on my other Ubuntu machine, and they didn’t:
~/bash_profile
~/bash_login
These files exist:
Login shell session
~/.profile
/etc/profile
Non-login shell session
~/.bashrc
/etc/bash.bashrc
Here’s what’s in ~ :
Directories: .cache, .config, .fontconfig, .gnupg, .local, .pki, .ssh
Files: .bash_history, .bash_logout, .bashrc, .lesshst, .profile, .sudo_as_admin_successful
I copied the existing startup files (bash.bashrc, .bashrc, .profile, profile) into a new directory in my home called File_Backups. I know that’s not how to do it, but I just wanted a copy somewhere else that would have the exact text of the files.
Then I found the UUID of the LFS partition:
sudo blkid
Environment
For 2.6 Setting the $LFS variable and the umask.
- Set LFS variable
export LFS=mnt/lfs
2. Set file mode creation mask
umask 022
Do I need to add a 0 in Ubuntu? No, umask ignores the prefix digit.
This removes the group and world w. Directory default: 755, Files default: 644
3. Verify them
echo $LFS
umask
4. Now add the following lines:
# Set LFS variable and file mode creation mask for Linux From Scratch
export LFS=/mnt/lfs
umask 022
Into these startup files with nano:
sudo nano /etc/profile
nano ~/.profile
sudo nano /etc/bash.bashrc
nano ~/.bashrc
In /etc/bash.bashrc, must go before “if” test
5. Restart. To see if everything’s ok.
Mounting LFS (temporary)
- Create directory for LFS (apparently on the mount point). [parent, verbose]
mkdir -pv $LFS
2. Make sure I know the device name of the LFS partition. It should be sda3, but it could change on reboot, etc.
lsblk
3. Mount the LFS partition
sudo mount -v -t ext4 /dev/sda3 $LFS
4. Check if it is mounted at the right location
mount
/dev/sda3 on /mnt/lfs type ext4 (rw,relatime)
5. Set owner and permission mode of $LFS directory, i.e. the root directory in the newly created file system for the system.
chown root:root $LFS
chmod 755 $LFS
Notes: Everyone can read, only owner can write. Group and world have permission to enter directly and list contents.
chown newowner:newgroup file
chmod mode directory
755: rwx r-x r-x or 111 101 101
6. Be sure it is not mounted with permissions that are too restrictive. If nosuid or nodev are set, the partition must be remounted.
Find this with
mount
Defaults: Use the default mount options (usually rw, suid, dev, exec, auto, nouser, async)