brunp
Posts: 9
Joined: Fri Jan 11, 2019 6:10 pm

How do you delete the "work" directories after a build?

Sun Jan 20, 2019 6:35 pm

The Raspbian build keeps generating work directories, one for each day you build. How do you speed up by isolating it to one directory, if for instance you never touch stage 0 and stage1? And how do you go about deleting a work directory? I am unable to due to privileges.

Paul

DirkS
Posts: 9897
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How do you delete the "work" directories after a build?

Sun Jan 20, 2019 8:29 pm

brunp wrote:
Sun Jan 20, 2019 6:35 pm
I am unable to due to privileges.
You need admin privileges; use 'sudo'
From the command line use e.g.

Code: Select all

sudo rm -rf name-of-the-directory
This will recursively remove the content of that directory. Be careful when you use this; it's easy to delete something that is essential for keeping the Pi running

brunp
Posts: 9
Joined: Fri Jan 11, 2019 6:10 pm

Re: How do you delete the "work" directories after a build?

Tue Jan 22, 2019 4:26 am

I am referring to the Raspbian build image. When you run ./build.sh, it generates a work directories based on stage 0 through 3, 4 or 5. Once that is complete, it generates a ZIP file of that image.

My question, how do you delete those "work" directories after a build? Deleting with the "sudo" command results in operation not permitted.

Paul

DirkS
Posts: 9897
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How do you delete the "work" directories after a build?

Tue Jan 22, 2019 5:20 pm

This (again) shows how important it is to give as many details as possible.
Someone wanting to help has to assume several things here, starting with what tool you use to build an image (I assume it's pi-gen)
If it's pi-gen one has to assume it's the standard build and not the docker version (as this works differently)
Then the fact that you already tried using sudo without success...

brunp
Posts: 9
Joined: Fri Jan 11, 2019 6:10 pm

Re: How do you delete the "work" directories after a build?

Tue Jan 22, 2019 10:16 pm

Yes, I could have provided a few more details. I thought it was enough though.

Back on point, do you have any suggestions? Is there a pi-gen specific forum?

Paul

DirkS
Posts: 9897
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How do you delete the "work" directories after a build?

Wed Jan 23, 2019 12:30 am

brunp wrote:
Tue Jan 22, 2019 10:16 pm
Yes, I could have provided a few more details. I thought it was enough though.

Back on point, do you have any suggestions? Is there a pi-gen specific forum?
There is no need for a specific forum. You just need to provide more information in your post.
Keep in mind that Raspbian (the section you're posting in) is not the same as the RPF Raspbian images.
There are several ways to generate Pi compatible Rapbian images, pi-gen is one of them.

If you find problems with pi-gen you should open an issue on github (https://github.com/RPi-Distro/pi-gen/issues)

lkwilson96
Posts: 1
Joined: Mon Jun 03, 2019 2:05 am

Re: How do you delete the "work" directories after a build?

Mon Jun 03, 2019 2:13 am

The problem is that pi-gen mounts things inside of work, so when you try to delete it, it runs into errors deleting these special devices. This can also run the risk of deleting your files since the computer you're using might be mounted somewhere in there through dev, etc. So to delete work, you have to first unmount those.


First Method


You can also use

Code: Select all

mount -l
to see all the mounted file systems, and you can manually unmount the ones in your work directory. Then, unmount each manually.


Second Method


From scripts/common:

Code: Select all

unmount(){
	if [ -z "$1" ]; then
		DIR=$PWD
	else
		DIR=$1
	fi

	while mount | grep -q "$DIR"; do
		local LOCS
		LOCS=$(mount | grep "$DIR" | cut -f 3 -d ' ' | sort -r)
		for loc in $LOCS; do
			umount "$loc"
		done
	done
}
export -f unmount
So after entering the above function into the terminal, type the following:

Code: Select all

# unmount work/stage0
# unmount work/stage1
# unmount work/stage2
...
Once you have everything unmounted, it is safe to delete.

Return to “Raspbian”