automating chroot and mount/unmount


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 05-23-2008
automating chroot and mount/unmount

Hello,

I am trying to automate a task that I believe is easy. It is documented
for manual system administrative purposes here:
Gentoo Linux -- Installing the Gentoo Base System - chapter 6

I am attempting to do the following in a script:

# cd $TOP_OF_ROOT_FS
# mount -t proc none /mnt/gentoo/proc
# chroot . /bin/bash -c "cmd; cmd; exit 0"
# umount ./proc

However I am getting an error:
umount: /proc: device is busy

Does anyone know how to automate this sort of task?

Also, what is the difference between:
mount -t proc none /mnt/gentoo/proc
&
mount -t proc proc /mnt/gentoo/proc

Is "none" or "proc" merely a label for the fstab?

Thanks in advance.
Cheers!
Smilie
# 2  
Old 05-27-2008
No, proc is separate file space, and usually lots of information is being written there. Why do you need to un-mount it ? Try < -f > flag, for force.
# 3  
Old 05-29-2008
Thank you for the info!
Quote:
Why do you need to un-mount it ? Try < -f > flag, for force.
Hey! maybe there is a work-around?...

Perhaps I should describe the goal? That always seems to help. Smilie

The motivation for chroot'ing is that I am not familiar with another way
to run mkinitrd. Honestly, I am surprised there is not -root option such
as with the rpm command or tar's -C, etc. If I could specify my root
file system on the command line then I would not need to chroot to
run mkinitrd.

So, to answer your question, the reason I believe I need to unmount, is
because after chroot exits, I archive the entire file system with tar.
If I do not unmount, tar complains with errors that the file system is
mounted or some such message. I can set up the situation again and
fetch the exact error message.

Through experience, I know that if I unmount properly, I avoid the
tar error when creating the tar archive.

Cheers,
:-D
# 4  
Old 06-02-2008
as usual, the solution seems trivial.
Is there an explanation why the mount and umount are
not "symmetrical" with respect to the chroot. ?

in script:

mount -t proc none /mnt/gentoo/proc
chroot . /bin/bash -c "/root/myscript.sh; umount /proc; exit 0"

####

Do'h!
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Script to unmount and mount by UUID gtr33m Shell Programming and Scripting 4 02-09-2014 06:20 PM
Cygwin bash script to unmount and mount an XP partition LMHmedchem Shell Programming and Scripting 5 11-22-2013 02:27 PM
[Solved] Not able to do a chroot. sai2krishna UNIX for Dummies Questions & Answers 2 01-24-2013 09:32 AM
BIND in chroot h@foorsa.biz Solaris 1 09-13-2012 09:35 AM
if (disk is mounted) unmount if (disk is unmounted) mount hollister Shell Programming and Scripting 2 03-11-2011 07:51 PM
unmount the partition prakashkumar41 UNIX for Dummies Questions & Answers 2 08-26-2010 01:07 PM
openssh and chroot. vettec3 Solaris 4 11-04-2009 06:09 AM
Can't Mount Disk / Image after bad unmount Cranie OS X (Apple) 1 06-13-2009 07:19 PM
/usr out of disk space need to unmount/ expand volume /mount Dirk_ HP-UX 5 04-28-2009 09:35 AM
Cannot unmount mount points?? genzbeat HP-UX 1 02-01-2008 05:11 AM
CHRoot Problem Crazy_murli UNIX for Advanced & Expert Users 2 01-09-2007 03:59 AM
Unbale ot mount chroot /sys/image nicknihal Red Hat 2 09-06-2006 03:52 AM
how do i unmount ? vamshi_k AIX 3 08-29-2005 09:59 AM
chroot environment samurai79 AIX 0 08-10-2005 09:09 PM
chroot? byblyk Linux 0 04-02-2004 10:50 AM