LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-05-2010, 07:25 PM   #1
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Rep: Reputation: 32
Question [chroot] What happens when upgrading?


Hello

While learning about customizing a live ISO file, there's something I'd like to understand about chrooting and then, upgrading the kernel + applications:

1. It appears that (Ubuntu's) "apt-get upgrade" will not only upgrade applications but will also upgrade the kernel. Is this correct? Can I tell "apt-get upgrade" to upgrade applications and leave the kernel alone, so that "chroot" really means local files only?

2. After chrooting to a directory and running the command above, I'm seeing some discrepancy between the kernel files:

Code:
# chroot /mnt/squashfs

# apt-get update
# apt-get upgrade

//This is the host kernel?
# uname -a
Linux ubuntu 2.6.31-22-generic #63-Ubuntu SMP Wed Aug 18 22:54:26 UTC 2010 i686 GNU/Linux

//This is the packages installed in the chroot?
# dpkg-query -W | grep -i linux
linux-headers-2.6.31-22-generic 2.6.31-22.63
linux-headers-generic   2.6.31.22.35

linux-image-2.6.31-20-generic   2.6.31-20.58
linux-image-generic     2.6.31.20.33
linux-generic   2.6.31.20.33
How come the version of the linux-headers and linux-image don't match?

Thank you.
 
Old 09-06-2010, 02:29 AM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
Greetingz!

1) Yes, you are correct. Minor updates (and sometimes major ones) are done to the kernel (2.6.31-22.61, 2.6.31-22.62, 2.6.31-22.63, etc) when you run "apt-get upgrade"

From the apt-get man page;
Quote:
update
update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.

upgrade
upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
2) The reason why is because "2.6.31-22-generic" is the kernel you booted off of, and "2.6.31-22.63" is the newly installed kernel & headers (that were installed with "apt-get update" & "apt-get upgrade").

Basically, there's nothing wrong with doing a full "apt-get upgrade" from within a chrooted environment. As long as your chrooted environment happens to be the hard drive you're installing the OS into.

Quote:
Can I tell "apt-get upgrade" to upgrade applications and leave the kernel alone, so that "chroot" really means local files only?
I wouldn't recommend that if I were you. The official repositories are updated and certain applications, scripts, sources, etc, may expect a given kernel version.
(Translation: That's usually a lot more trouble than you'd think.)

Hope this helps!

P.S: "so that "chroot" really means local files only?" Um, I think you would benefit from reading the chroot man page ("man chroot" at the command prompt). The "chroot" command always uses local files...but that doesn't upgraded anything, it just "changes your root".

Last edited by xeleema; 09-06-2010 at 02:32 AM.
 
Old 09-06-2010, 04:29 AM   #3
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
Thanks for the information.

The problem I'm trying to solve, is that I need to update the kernel + applications contained in a live ISO file. This is done by mounting the ISO file, extract its files (squashfs) in a directory, chroot to it, update the applications, and save the files in a new ISO file.

According to documents like LiveCDCustomization, we just need to chroot to the directory where the squashfs file (ie. the tree that will be used as the live root filesystem) was extracted, and then run "apt-get" to add/remove applications.

So apparently, "apt-get" while in chroot actually updates the underlying host instead of restricting itself to the chroot filesystem?

Thank you.
 
Old 09-06-2010, 05:12 AM   #4
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
I noticed something, though: To avoid typing "sudo" every time, I simply ran the whole thing as root. Maybe this is not right when using chroot?

I also notice something in the document: In Advanced Customizations > Live CD Kernel:

Code:
sudo cp edit/boot/vmlinuz-2.6.15-26-k7 extract-cd/casper/vmlinuz
sudo cp edit/boot/initrd.img-2.6.15-26-k7 extract-cd/casper/initrd.gz
(Note: "edit" = squashfs unpacked from ISO, while "extract-cd" is the ISO minus squashfs)

When chrooted in the extracted squashfs, there is no boot/ since the kernel + initrd are at the root of the ISO image, ie. in extract-cd/.

So what's the right way to update a kernel within an ISO image? I was thinking of downloading a .deb image, extract vmlinuz from its data.tar.bz2, and somehow recompile a initrd.gz (or .lz, rather). I suspect there are dependencies (configuration files, libraries) that make this a bit less straightforward.

Thank you.
 
Old 09-06-2010, 06:26 AM   #5
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
Quote:
Originally Posted by littlebigman View Post
So apparently, "apt-get" while in chroot actually updates the underlying host instead of restricting itself to the chroot filesystem?
Um, no. if you're in the 'chrooted environment' then an apt-get upgrade is going to upgrade *that* environment.

Quote:
Originally Posted by littlebigman View Post
I need to update the kernel + applications contained in a live ISO file.
Ah, okay, that makes more sense. However, my advice regarding the updating of both applications+kernel still stands.

Here's a nice trick;
1) jump into your chrooted environment
NOTE: should be something like "chroot /mnt/sysimage /bin/bash"
2) Type "touch OMGlolWTF" (or some other filename that isn't going to exist elswhere)
3) "Exit" the chrooted environment.
4) Run "updatedb && locate OMGlolWTF"

The file OMGlolWTF should pop up in "/mnt/sysimage", and not just plain "/". If for some reason the file DOES pop-up in just plain "/", then you're skipping a step somewhere...
 
Old 09-06-2010, 06:43 AM   #6
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
Thanks for the tip. Sorry for the error: "apt-get ugrade" in chroot does update the chroot, not the underlying host (I added a new driver just to check, and it's not listed when I exit chroot and run "dpkg -l").

I'm taking a further look at updating an ISO file, and I suspect it's going to take a while ;-)

I haven't found information on replacing the kernel within the ISO file, though. I doubt it's just a matter of replacing vmlinuz with the one found in the latest kernel .deb package. Most likely, I need to generate a new initrd.gz based on what's living in /lib/modules after the upgrade, update configuration files, etc.

Has someone successfully updated the kernel of an existing ISO file and could tell me how it's done?

Thank you.
 
Old 09-09-2010, 08:26 AM   #7
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
After further investigation, here's what I see when I mount the live ISO file and chroot to it:

BEFORE apt-get upgrade
0. # uname -r
2.6.31-22-generic
(this is the kernel used by the host)

Ob. # lsb_release -a
Description: Ubuntu 9.10
Codename: karmic

1. No /boot

2. # dpkg-query -W | grep -i linux-
linux-generic 2.6.31.20.33
linux-image-2.6.31-20-generic 2.6.31-20.57
linux-image-generic 2.6.31.20.33
(this is data from the local database of installed applications)

AFTER apt-get upgrade
1. /boot:
System.map-2.6.31-20-generic
abi-2.6.31-20-generic
config-2.6.31-20-generic
initrd.img-2.6.31-20-generic
vmcoreinfo-2.6.31-20-generic
vmlinuz-2.6.31-20-generic
(why no 2.6.31-22?)

2. # dpkg-query -W | grep -i linux-
linux-firmware 1.26
linux-generic 2.6.31.20.33
linux-image-2.6.31-20-generic 2.6.31-20.58
linux-image-generic 2.6.31.20.33

3. # apt-cache search linux-image
linux-image-2.6.31-22-generic

Why doesn't /boot contain the latest kernel image from the Ubuntu repository (2.6.31-22)?

Thank you.

Last edited by littlebigman; 09-09-2010 at 08:29 AM.
 
Old 09-09-2010, 08:45 AM   #8
littlebigman
Member
 
Registered: Aug 2008
Posts: 500

Original Poster
Rep: Reputation: 32
Here's the possible answer:
Code:
# apt-get upgrade
[...]
The following packages have been kept back:
  firefox firefox-3.5 firefox-3.5-branding linux-generic linux-image-generic
I was about to run "apt-get dist-upgrade", but the Knoppix Remastering Howto says:
Quote:
"Warning: apt-get upgrade is a BAD IDEA. It will, quite probably, render your KNOPPIX remaster unbootable, or broken in some way. A far safer method is to only upgrade packages as necessary."
So it looks like the right way is to upgrade required packages individually by running "apt-get install some.already.installed.package" (install will actually upgrade a package if it's already installed).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] in chroot compiled programs do not work in chroot graphit Linux From Scratch 2 04-11-2010 04:04 AM
chroot to run hd-installed distro's programs from chroot in live distro? silencestone Linux - Software 0 10-12-2007 07:29 AM
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 11:30 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 04:57 AM
Upgrading to Badger! Can't login anymore after upgrading? BellaSha87 Ubuntu 1 12-03-2005 01:09 PM


All times are GMT -5. The time now is 10:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration