Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions tools/baseimage/cmd/gce_install_cuttlefish_packages/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

const (
outImageName = "amended-image"
mountpoint = "/mnt/image"
)

type DebSrcsFlag struct {
Expand Down Expand Up @@ -90,11 +91,8 @@ func fillAvailableSpace(project, zone, insName string) error {
return gce.RunCmd(project, zone, insName, "./fill_available_disk_space.sh")
}

func mountAttachedDisk(project, zone, insName string) (string, error) {
if err := gce.RunCmd(project, zone, insName, "./mount_attached_disk.sh"); err != nil {
return "", err
}
return "/mnt/image/", nil
func mountAttachedDisk(project, zone, insName, mountpoint string) error {
return gce.RunCmd(project, zone, insName, "./mount_attached_disk.sh "+mountpoint)
}

func installCuttlefishDebs(project, zone, insName string, debSrcs []string) error {
Expand Down Expand Up @@ -185,7 +183,7 @@ func amendImageMain(project, zone string, opts amendImageOpts) error {
return fmt.Errorf("fillAvailableSpace error: %v", err)
}

if _, err := mountAttachedDisk(project, zone, insName); err != nil {
if err := mountAttachedDisk(project, zone, insName, mountpoint); err != nil {
return fmt.Errorf("mountAttachedDisk error: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion tools/baseimage/pkg/gce/scripts/create_base_image_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sudo growpart /dev/sdb 1 || /bin/true
sudo e2fsck -f -y /dev/sdb1 || /bin/true
sudo resize2fs /dev/sdb1

./mount_attached_disk.sh
./mount_attached_disk.sh /mnt/image

kmodver_begin=$(sudo chroot /mnt/image/ /usr/bin/dpkg -s linux-image-cloud-amd64 | grep ^Depends: | \
cut -d: -f2 | cut -d" " -f2 | sed 's/linux-image-//')
Expand Down
2 changes: 1 addition & 1 deletion tools/baseimage/pkg/gce/scripts/install_kernel_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ linux_image_deb=$1
sudo apt-get update
sudo apt-get upgrade -y

./mount_attached_disk.sh
./mount_attached_disk.sh /mnt/image

version=$(sudo chroot /mnt/image/ /usr/bin/dpkg -s linux-image-cloud-amd64 | grep ^Depends: | \
cut -d: -f2 | cut -d" " -f2 )
Expand Down
24 changes: 13 additions & 11 deletions tools/baseimage/pkg/gce/scripts/mount_attached_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Mount attached disk `/dev/sdb1` at `/mnt/image`.
# Mount attached disk `/dev/sdb1` at `/mnt/image` (the argument).
set -o errexit -o nounset -o pipefail

sudo mkdir -p /mnt/image
sudo mount /dev/sdb1 /mnt/image
sudo mount -t sysfs none /mnt/image/sys
sudo mount -t proc none /mnt/image/proc
sudo mount --bind /boot/efi /mnt/image/boot/efi
sudo mount --bind /dev/ /mnt/image/dev
sudo mount --bind /dev/pts /mnt/image/dev/pts
sudo mount --bind /run /mnt/image/run
MOUNTPONT=$1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update other tools: create_gce_x86_64_image, create_gce_x86_64_fixed_kernel using this script as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will require more wide refactors. I have however ensured that this mount script gets invoked correctly everywhere, though.


sudo mkdir -p ${MOUNTPOINT}
sudo mount /dev/sdb1 ${MOUNTPOINT}
sudo mount -t sysfs none ${MOUNTPOINT}/sys
sudo mount -t proc none ${MOUNTPOINT}/proc
sudo mount --bind /boot/efi ${MOUNTPOINT}/boot/efi
sudo mount --bind /dev/ ${MOUNTPOINT}/dev
sudo mount --bind /dev/pts ${MOUNTPOINT}/dev/pts
sudo mount --bind /run ${MOUNTPOINT}/run
# resolv.conf is needed on Debian but not Ubuntu
if [ ! -f /mnt/image/etc/resolv.conf ]; then
sudo cp /etc/resolv.conf /mnt/image/etc/
if [ ! -f ${MOUNTPOINT}/etc/resolv.conf ]; then
sudo cp /etc/resolv.conf ${MOUNTPOINT}/etc/
fi
`
Loading